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

相关推荐
潘正翔24 分钟前
k8s进阶_Harbor镜像仓库
git·云原生·容器·kubernetes·gitee·github
InfinitePlus2 小时前
Git基本操作-命令行
git
茉莉玫瑰花茶3 小时前
TCP 全连接队列与 tcpdump 抓包
git·github·tcp·tcpdump
炸膛坦客4 小时前
Git 和 GitHub:(十四)rebase 到某个有新提交的远程仓库的分支
git·github
炸膛坦客18 小时前
Git 和 GitHub:(十二)基于远程仓库的某一个分支的某一笔提交创建新分支
git·github
炸膛坦客19 小时前
Git 和 GitHub:(十三)改分支名
git·github
他们叫我秃子19 小时前
Git 使用指南笔记:从入门到团队协作
git
铁锚1 天前
Git设置自动推送到同名远端分支
git
起个破名想半天了1 天前
Git 本地项目关联远程仓库教程
git·github·git教程
lazy H1 天前
Git worktree 怎么用?同时开发多个分支完整教程
大数据·git·后端·学习·搜索引擎·github