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

相关推荐
427724006 小时前
IDEA使用git不提示账号密码登录,而是输入token问题解决
java·git·intellij-idea
利刃大大13 小时前
【Git】五、多人协作
git
逸Y 仙X20 小时前
Git常见命令--助力开发
java·大数据·git·java-ee·github·idea
wgslucky1 天前
pipeline 使用git parameter插件实现动态选择分支构造
git
likeyou~coucou1 天前
自动化之ansible(二)
运维·自动化·ansible
明阳mark1 天前
Ansible 学习笔记
笔记·学习·ansible
DC_BLOG1 天前
Linux-Ansible模块进阶
linux·运维·服务器·ansible
春天姐姐1 天前
vue3项目开发总结
前端·vue.js·git
{⌐■_■}1 天前
【git】工作流实战:从本地仓库到远程仓库,git pull 与git rebase使用讲解,案例解析
git
大溪地C1 天前
Git 合并冲突解决与状态分析笔记
笔记·git