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

相关推荐
Star_KeyW8 小时前
【最新】Git简介与完整安装
git
深紫色的三北六号12 小时前
基于 Git 某个分支创建一个全新的仓库(GitHub / GitLab)
git·gitlab·github
-拟墨画扇-13 小时前
Git | 标签操作
git·gitee·github·gitcode
狂龙骄子13 小时前
使用git filter-branch命令修改历史提交
git·filter-branch·迁移仓库历史·所有权转移·修改历史提交
C2X14 小时前
关于Git Graph展示图的理解
前端·git
CryptoRzz14 小时前
StockTV API 对接全攻略(股票、期货、IPO)
java·javascript·git·web3·区块链·github
-拟墨画扇-15 小时前
Git | 远程仓库操作
git·gitee·github
NuageL16 小时前
第一次用Git协作流程记录和踩坑
git
特级业务专家18 小时前
这下发布不需要Jenkins了
linux·git·docker
0和1的舞者18 小时前
Git 实战踩坑:如何让多个 IDE 项目共用一个远程仓库(附子模块问题解决)
git·开发·仓库·码云·子模块·操作·冲突