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

相关推荐
Sagittarius_A*3 小时前
Web 安全之 Git 泄露:原理剖析 + CTFHub Log/Stash/Index 全题型解法
git·安全·web安全
lazy H4 小时前
从入门到日常开发,一篇文章掌握 Git 核心操作
git·后端·学习·github
zzqssliu12 小时前
煤炉自动代拍系统的队列设计与超时控制机制
git·github
一支绝命钩12 小时前
FPGA工程Git常用操作手册
git
不搞学术柒柒16 小时前
Git新功能完整开发提交流程
git
码上上班19 小时前
Ansible课程
ansible
午安~婉21 小时前
Git中SSH连接
前端·git·gitee
888CC++21 小时前
VS Code Git 工作树:解锁多分支并行开发新体验
git
阿虎儿21 小时前
Git exclude 功能解析
git
隔窗听雨眠1 天前
VS Code Git工作树:多分支并行开发的完整实践方案
git