ansible-tower连接git实现简单执行playbook

前提:安装好ansible-tower和git,其中git存放ansible得剧本

其中git中得内容为:

bash 复制代码
---
- name: yjxtest
  hosts: yin
  remote_user: root
  gather_facts: no
  roles:
    - test


roles/test/tasks/main.yml #文件内容
---
#- name: Perform Test Task
#  tasks:
    - name: create /tmptest 
      file:
        path: /tmptest
        state: directory

    - name: test job 1
      shell: ps aux | grep node

    - name: test job 2
      shell: mkdir -p /tmptest && echo "123" > /tmptest/test.txt



hosts文件内容
[yin]
192.168.50.155
192.168.50.156

ansible-tower中得配置

1.在inventories中新增一个testinventory。需要保存inventory后才能点击sources,并且在sources中新增一个sources

2 credentials中的配置,新增一个credentials,其中credential中的用户名填的是ansible-tower这台机器的用户名和密码(不一定是root用户)

3.新增projects,填写对应的git地址,也要带上git的用户名和密码。注意点:密码不要带特殊字符,数字+字母就可以了。

4 template修改

5 当修改git的后,需要再重新刷新一下.sources中会重新读取hosts中文件的内容

6 执行结果

参考:

https://blog.csdn.net/weixin_43902588/article/details/116105793

相关推荐
上单带刀不带妹4 小时前
Git rm 命令与系统 rm 命令的区别详解
git
我的收藏手册8 小时前
性能监控shell脚本编写
前端·git·github
Yvonne爱编码9 小时前
简述ajax、node.js、webpack、git
前端·git·ajax·webpack·node.js·visual studio
YC运维10 小时前
Ansible题目全解析与答案
java·算法·ansible
2501_920047031 天前
git在Linux中的使用
linux·git·elasticsearch
小马哥编程1 天前
DNS解析中的服务器协作机制
服务器·git·github
--运维实习生--1 天前
自动化运维之ansible
运维·自动化·ansible
白帽小野1 天前
SVN和Git两种版本管理系统对比
git·svn·版本控制系统
rivercoder1 天前
Gitea:轻量级的自托管Git服务
git·gitlab·gitea
呜喵王阿尔萨斯2 天前
git命令解析
c++·git