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

相关推荐
小钟不想敲代码4 小时前
GitFlow
git·gitflow
阎*水7 小时前
Ansible 核心要点总结
ansible
云和数据.ChenGuang10 小时前
git commit复合指令
大数据·git·elasticsearch
-拟墨画扇-13 小时前
Git | 文件提交操作
git·gitee·github·gitcode
小安运维日记13 小时前
RHCA - DO374 | Day09:自定义内容集和执行环境
linux·运维·服务器·系统架构·ansible·改行学it
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2025-12-25)
git·ai·开源·llm·github
-拟墨画扇-15 小时前
Git | 文件修改操作
大数据·git·gitee·github·gitcode
-拟墨画扇-15 小时前
Git | 版本控制操作
大数据·git·gitee·github
-dcr16 小时前
48.Ansible自动化
自动化·ansible·dubbo
GA66666616 小时前
PowerWiki:基于 Git 的知识管理系统
git