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

相关推荐
Ws_7 小时前
Git + Gerrit 第二课:diff、暂存区与撤销修改
git
snowjlz7 小时前
鸿蒙版SVN来了!!!
git·svn·版本控制
2401_876964139 小时前
27考研余炳森概率论|喻老李良2027资料网课
windows·git·考研·svn·eclipse·github·概率论
爱搬砖的狮子10 小时前
【Git】git repo下载使用
git
cheems952713 小时前
Git基本操作
git
Irissgwe13 小时前
三、Git 文件状态管理:add、commit、status 和 diff
git
Ws_17 小时前
Git + Gerrit 第三课:分支、切换与合并
git·elasticsearch
xlq2232218 小时前
6.git
git
Drache_long19 小时前
Git命令概述
git
console.log('npc')19 小时前
修改git中commit内容
git