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 小时前
零基础小白自学 Git_Github 教程,Git 命令行操作2,笔记19
笔记·git·github
我是若尘2 小时前
Git Rebase深度解析:优雅重写提交历史的艺术
git
我是若尘2 小时前
Git合并踩坑记:当master回退后,如何正确合并分支?
git·代码规范
摇滚侠3 小时前
零基础小白自学 Git_Github 教程,Action CI/CD 完整实践,笔记23
笔记·git·ci/cd
minji...5 小时前
linux 进程控制(一) (fork进程创建,exit进程终止)
linux·运维·服务器·c++·git·算法
系夏普5 小时前
Git 入门教程:初始化、修改与提交
git
laplaya5 小时前
Git 使用技巧
git
奶油松果5 小时前
git amend记录
git
庸俗今天不摸鱼6 小时前
git提交代码失败?本地代码被清空了?git代码丢了怎么办?三步帮你找回来
git
摇滚侠6 小时前
零基础小白自学 Git_Github 教程,Git 命令行操作3,笔记20
笔记·git·github