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

相关推荐
苍煜1 小时前
Git Worktree 多工作树实战教学-工作多分支实用教程
git
RainingTime5 小时前
新版IDEA使用传统用户名、密码登录Git
git
DevangLic15 小时前
【诡异的空文件夹 和 git:冲突合并】最新的尝试
git
舒一笑17 小时前
Windows + WSL2 完整复现 Avernet WAIC 6 Bot 协作演示
人工智能·git·开源
生戎马 平安京策1 天前
git寻根——^和~的区别
git
技术小结-李爽1 天前
【工具】git远程分支合并
git·gitee
RootKai1 天前
Git命令与基本使用流程
git
AdaTina1 天前
关于git的初始操作
git
Coder-LiyG1 天前
Git 常用操作指南:从初始化到回退的高频命令速查
git