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

相关推荐
云攀登者-望正茂1 小时前
使用 Ansible 在 Windows 服务器上安装 SSL 证书
ansible
Jooolin11 小时前
【编程史】Git是如何诞生的?这可并非计划之中...
linux·git·ai编程
Lw老王要学习15 小时前
VScode 使用 git 提交数据到指定库的完整指南
windows·git·vscode
去旅行、在路上15 小时前
Git & Svn
git·svn
abcnull16 小时前
github中main与master,master无法合并到main
git·github
养意1 天前
git提交代码和解决冲突修复bug
git·bug
码农黛兮_461 天前
Git 常用命令大全
git
一弓虽1 天前
git 学习
git·学习
tianyuanwo2 天前
Ansible自动化运维全解析:从设计哲学到实战演进
运维·自动化·ansible
哆啦A梦15882 天前
在golang中如何将已安装的依赖降级处理,比如:将 go-ansible/[email protected] 更换为 go-ansible/@v1.1.7
开发语言·golang·ansible