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 小时前
使用 Traefik、cert-manager 和 DNS-01 为内网 Kubernetes 服务配置 HTTPS
git·kubernetes·flux
小芒果_015 小时前
git常用命令速查
大数据·git·elasticsearch
2501_930472446 小时前
腾讯云助手规范化Git提交记录
git·elasticsearch·腾讯云
风尘小子17 小时前
git的.gitignore文件中文件和目录配置
git
Tanner_SL1 天前
Linux笔记之GIT常用命令
linux·git
醉颜凉1 天前
Jenkins与Git集成完全指南:从基础配置到自动触发构建
运维·git·jenkins
樱花落木兰1 天前
Git 超全零基础教程|三区原理、全套命令、分支协作、冲突解决、IDEA 集成(面试必备)
ide·git·json·github
云和数据.ChenGuang1 天前
git revert回退问题
java·服务器·人工智能·git·fastapi·强化学习
伞伞悦读1 天前
【第12期】Windows 开发环境备份与恢复:软件、环境变量、Git、conda 和 Docker 卷完整方案
git·docker·conda
吨吨ai1 天前
Codex 实战:用 Git 分支 + pytest 构建可回滚的 AI 开发流程(2026年8月27日)
人工智能·git·pytest