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

相关推荐
小龙报7 分钟前
《算法每日一题(1)--- 连续因子》
c语言·开发语言·c++·windows·git·算法·visual studio
今禾2 小时前
Git完全指南(中篇):GitHub团队协作实战
前端·git·github
flow_code15 小时前
切换git账户
git
春生野草19 小时前
Gituee
git·gitee
222you19 小时前
Git推送本地仓库到远程
git
小贾要学习21 小时前
如何在Linux操作系统环境下使用git命令提交文件到远程仓库
linux·运维·git
J2虾虾21 小时前
WebStorm的项目绑定Git并上传到gitee
git·gitee·webstorm
虾说羊21 小时前
git分支管理介绍和stash命令
git
71-31 天前
git 和 tortoisegit的快速使用教学(上传至gitee或GitHub)
git·gitee
唐青枫1 天前
为什么 .gitignore 不生效?其实你忘了用 git rm --cached!
git