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

相关推荐
ganshenml19 小时前
【GIT】Git 本地无法识别远程分支的原因与解决方法 not a valid ref
大数据·git·elasticsearch
lizz66620 小时前
在Git提交中,常见的提交类型(基于Angular提交规范,已被广泛采用)
git
涵涵(互关)20 小时前
git基础操作(按图一步一步来,有案例)
git
我是苹果,不是香蕉21 小时前
git remote报错解决办法
git
SHIPKING39321 小时前
【git命令操作指南】
git
LT_10291 天前
如何初始化一个本地的项目到远程git仓库?
git·源代码管理
小付爱coding1 天前
Claude Code安装教程【windows版本】
java·git·python
BIBI20491 天前
Windows 下 Git 常规操作教程:命令行与 TortoiseGit
windows·git·tortoisegit·配置·版本控制·入门指南
ylmzfun1 天前
基于Ansible的自动化运维实战:从入门到企业级应用
运维·架构·ansible
The Straggling Crow1 天前
熟练版本控制 (Git)、CI/CD 流程。
git·elasticsearch·ci/cd