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

相关推荐
czhc1140075663几秒前
2026-09-11 一日综合:树的父链、git 概念、三方死锁、静默失败
大数据·git·elasticsearch
ChampaignWolf6 分钟前
abapgit-agent:用 Git 当中介,让 Claude Code 自己完成 ABAP 闭环开发
git·ai·abap·claude·abapgit·mcp
嘴贱欠吻!41 分钟前
如何成为 CJMP 贡献者:AtomGit贡献流程与要求
git·ci/cd
滕州市燕猫虎计算机科技工作室个体工商户2 小时前
.gitignore文件不生效的解决方法
git·.gitignore·.gitignore不生效
hasty3 小时前
一个 Git 分支名,如何穿透到 CI Runner 的 Shell?
git·ci/cd
橘色的喵5 小时前
Claude Code 状态栏脚本:一行显示模型、上下文占用、git 分支和当前目录
linux·git·bash·claude
fangjianj5 小时前
git 常用命令
git
hasty7 小时前
execSync() 拼接 Git 参数的代价:从元数据到供应链执行
git·安全·安全性测试
墨白曦煜1 天前
穿透 IDE 的障眼法:Git 四大工作区与核心数据流转解析
ide·git
idealzouhu1 天前
深入 Git 账户模型:从提交身份到 SSH 多账户隔离的完整实践
git·ssh