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

相关推荐
一勺-_-10 小时前
.git文件夹
大数据·git·elasticsearch
TT哇12 小时前
【git】本地代码上传到gitee仓库(保姆级教程)idea和vscode等通用
git·gitee·intellij-idea
人在旅途我渐行渐远12 小时前
idea 通过git撤销commit但未push的操作
java·git·intellij-idea
Serene_Dream12 小时前
IDEA中多人项目中如何将自己的本地分支调整到远程的最新分支下
git·github
中冕—霍格沃兹软件开发测试13 小时前
Git版本控制在测试项目管理中的应用
人工智能·git·科技·开源·appium·bug
嘻哈baby14 小时前
Ansible自动化运维入门:从手工到批量部署
运维·自动化·ansible
一个不秃头的 程序员16 小时前
配置git仓库的地址
git
coderCatIce17 小时前
git(带流程图)
git
Warren9818 小时前
面试和投简历闲聊
网络·学习·docker·面试·职场和发展·eureka·ansible
Jonathan Star18 小时前
git commit --amend 是 Git 中用于修改最后一次提交的核心命令
前端·chrome·git