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

相关推荐
sylvia_081514 小时前
git add 后pull 放弃本地所有修改
git
五阿哥永琪14 小时前
Git 开发常用命令速查手册
大数据·git·elasticsearch
Xyz996_15 小时前
Ansible进行Nginx编译安装的详细步骤
运维·ansible
柒壹漆15 小时前
用Python制作一个USB Hid设备数据收发测试工具
开发语言·git·python
爱吃番茄鼠骗17 小时前
git命令使用教程
git
黑牛先生19 小时前
【Git】解决远程仓库备注错误问题
git
rockmelodies20 小时前
Git冲突解决实用指南
git·git冲突
bj_zhb20 小时前
Git 回退到某个 commit
git·github
凯子坚持 c20 小时前
Git分支实战指南:如何优雅地管理版本、修复Bug并解决合并冲突
git·bug
openinstall全渠道统计21 小时前
开发者指南:广告投放系统搭建与前后端数据打通全流程
windows·git·oracle·eclipse·sqlite·github