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

相关推荐
Amber_373 小时前
git 查看已经commit但是还没有push的所有文件变动内容
git
Strawberry_ahh3 小时前
You are not allowed to push code to this project
git
yqj2343 小时前
Git提示信息 Pulling is not possible because you have unmerged files.
git
我是果子哥5 小时前
Git的安装 + 基本操作
linux·git
不是二师兄的八戒5 小时前
工具探讨?
git·vscode·编辑器·idea
aimmon8 小时前
Superset二次开发之Git篇git fetch 异常信息汇总
git·二次开发·fetch·bi·superset
PeterJXL9 小时前
Git - 初识版本库
git·安装
胡少侠712 小时前
python 获取当前git的repo地址
开发语言·git·python
竹外884813 小时前
git 基本原理
git