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

相关推荐
import_random9 小时前
[git]只有git,没有github, 如何工作
git·github
import_random9 小时前
[git]先创建远程仓库or先创建本地项目
git·github
Linux实战笔记11 小时前
rebase 变基引发提交哈希重写与指针机制分析
git·rebase·提交哈希·分支模型·代码合并
小稀土12312 小时前
私有化研发协同系统并行期:旧 Jira 与新 Git 并存 6 条数据规则
git
Madison-No713 小时前
Git版本控制工具(二)
git
垚垚学技术_聚焦云原生14 小时前
Ansible 变量体系详解:主机变量、组变量、全局变量优先级实战
ansible·自动化运维·devops·变量优先级
Brookty16 小时前
Git 与 GitHub|第一阶段:仓库、版本历史与 Git 对象模型(上篇)
git·github
Kimnol1 天前
我的第一次 Git 贡献:从 fork 到合并 PR #3130
git
鬼手点金1 天前
消息的四种角色
java·前端·人工智能·git·深度学习
齐 飞2 天前
idea中git误操作撤回git reset --hard ‘HEAD@{1}‘
java·git·intellij-idea