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

相关推荐
CNRio5 小时前
Day 56:Git的高级技巧:使用Git的filter-branch重写历史
大数据·git·elasticsearch
CNRio5 小时前
Day 57:Git的高级技巧:使用Git的rebase交互式修改历史
大数据·git·elasticsearch
njsgcs6 小时前
仓库子文件夹设置不公开 git submodule add
git
扑火的小飞蛾6 小时前
【Ansible学习笔记01】 批量执行 shell 命令
笔记·学习·ansible
oMcLin6 小时前
如何在 Red Hat Linux 服务器上使用 Ansible 自动化部署并管理多节点 Hadoop 集群?
linux·服务器·ansible
草莓熊Lotso6 小时前
Python 库使用全攻略:从标准库到第三方库(附实战案例)
运维·服务器·汇编·人工智能·经验分享·git·python
CNRio6 小时前
Day 51:Git的高级技巧:使用Git的reflog恢复丢失的提交
大数据·git·elasticsearch
ZeroNews内网穿透7 小时前
轻量级自托管Git服务:Gitea私有化部署与公网访问
服务器·网络·数据库·git·gitea
rannn_11121 小时前
【Java项目】中北大学Java大作业|电商平台
java·git·后端·课程设计·中北大学
wordbaby1 天前
公私分明:为什么你不应该共用 SSH Key(附多账号最佳实践指南)
前端·git·ssh