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

相关推荐
T - mars1 小时前
Git在Pycharm中的使用
git
sunarmy1 小时前
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104
git
典学长编程3 小时前
高效学习之一篇搞定分布式管理系统Git !
大数据·git·搜索引擎
是2的10次方啊3 小时前
.gitignore失效自救指南:原理揭秘与工程师实战排查全流程
git
海外空间恒创科技4 小时前
香港站群服务器与普通香港服务器对比
服务器·git·github
Wetoria6 小时前
管理 git 分支时,用 merge 还是 rebase?
前端·git
泰勒朗斯21 小时前
如何在新机器上设置github完成内容git push
git·github
小妖6661 天前
git branch -a 还有一些已经删除了的分支
git
&Sinnt&2 天前
Git 版本控制完全指南:从入门到精通
git·后端
Tiny2142 天前
多人协同开发时Git使用命令
git