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

相关推荐
弘毅 失败的 mian24 分钟前
Git 远程操作
经验分享·笔记·git
wdfk_prog12 小时前
Git实战指南:如何从另一个分支同步文件时完整保留Commit提交历史
git
In_life 在生活12 小时前
GIT stash 命令的使用
git
SunkingYang13 小时前
如何通过命令和TortoiseGit工具来撤销最后一次提交,包含提交到缓存区,提交到远程仓库
git·tortoisegit·工作区·暂存区·远程仓库·撤销·最后一次提交
南山nash18 小时前
git从入门到熟练
git
夜流冰21 小时前
Git - GitForWindows
git
一个很帅的帅哥1 天前
部署chat-vue
大数据·git·elasticsearch
码农101号1 天前
Ansible - Role介绍 和 使用playbook部署wordPress
android·ansible
芒鸽1 天前
鸿蒙PC使用ffmpeg+electron实现视频中音频的提取
git
SunkingYang1 天前
使用TortoiseGit工具推送(push)时,忘了先拉取(Pull),提示冲突,后续怎么处理冲突?
git·tortoisegit·pull·push·推送·冲突·拉取