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

相关推荐
小龙9 小时前
[Git 报错解决]本地分支落后于远程分支(`non-fast-forward`)
大数据·git·elasticsearch·github
爱敲代码的婷婷婷.10 小时前
git 指定版本回退、临时保存 等操作
git
闲云一鹤11 小时前
Git 焚决!一个绝招助你找回丢失的代码文件!
前端·git
DKunYu11 小时前
2.分支管理
大数据·git·elasticsearch·搜索引擎·gitee
DKunYu12 小时前
1.基本操作
git·gitee
小龙12 小时前
【Git 报错解决】SSH 公钥认证失败(`Permission denied (publickey)`)
运维·git·ssh
哆啦code梦13 小时前
Git Flow架构图解:分支策略全解析
git·git flow·分支策略
Albert Edison13 小时前
【Git】远程操作
git·svn·github
脾气有点小暴14 小时前
Git指令大全(常见版)
前端·git
DKunYu15 小时前
3.远程操作
大数据·git·elasticsearch·搜索引擎·gitee