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

相关推荐
db_cy_20622 小时前
Git对服务器配置文件进行版本控制
运维·服务器·git
乾元3 小时前
SDN 与 AI 协同:控制面策略自动化与策略一致性校验
运维·网络·人工智能·网络协议·华为·系统架构·ansible
好好研究3 小时前
Git - Git分支管理
git
冬-梦4 小时前
iPad Obsidian Git 同步 Gitee 仓库完整指南
git·gitee·ipad·obsidian·efficiency
醇氧4 小时前
【git】 撤回一个本地提交
大数据·git·elasticsearch
空空kkk5 小时前
Git——分支管理
git
Micknee7 小时前
Windows环境下配置git和github
windows·git·github
测试人社区—52727 小时前
你的单元测试真的“单元”吗?
前端·人工智能·git·测试工具·单元测试·自动化·log4j
weixin_462446237 小时前
macOS 安装 git-lfs
git·macos
CoderJia程序员甲7 小时前
GitHub 热榜项目 - 日榜(2025-12-7)
git·ai·开源·llm·github