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

相关推荐
liuyao_xianhui19 小时前
版本控制器git--gdb/cgdb
linux·运维·服务器·git
徐同保20 小时前
如何使用GitKraken把git项目迁移到另一个平台,并保存所有提交记录,例如把github上的项目,迁移到gitee
git·gitee·github
高小秋21 小时前
项目开发使用 git工作流插件 -- jgitflow开发实践
git
tealcwu21 小时前
【软件工程】浅析Git message, version, changelog之间的关系
git
五号厂房1 天前
Git Worktree 使用指南
git
秦jh_1 天前
【git】企业级开发模型
git
y***54881 天前
Git在开源项目中的协作
git
老友記1 天前
git cherry-pick使用
git
练习时长一年1 天前
git常用命令总结
大数据·git·elasticsearch
hadage2331 天前
--- git 的一些使用 ---
开发语言·git·python