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

相关推荐
aoxiang_ywj2 小时前
tig 的untracked changes和unstaged changes含义?
git
2501_916766549 小时前
【Git学习】Git的tag标签
git·学习
CoderJia程序员甲9 小时前
GitHub 热榜项目 - 日榜(2025-12-11)
git·ai·开源·llm·github
aoxiang_ywj9 小时前
git add 和git commit之后怎么撤销?
git
winner888110 小时前
告别“这个分支是干啥的?”:Git分支层级命名实战
git·git push -u·分支关联·层级分支命名
真上帝的左手10 小时前
3. 代码管理-Git实战
git
lin625342213 小时前
Android仿小米视频播放器的缩放滚轮
android·git·github
互亿无线明明13 小时前
在 Go 项目中集成国际短信能力:从接口调试到生产环境的最佳实践
开发语言·windows·git·后端·golang·pycharm·eclipse
world_in_world13 小时前
git常见场景命令
git
码上成长14 小时前
长耗时接口异步改造总结
前端·git·后端