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

相关推荐
我爱学习好爱好爱7 小时前
Ansible 常用模块详解:yum、service/systemd、copy实战
linux·服务器·ansible
吴声子夜歌12 小时前
TypeScript——泛型
前端·git·typescript
春日见13 小时前
3三分彻底了解Git Graph极其应用
git
淼淼爱喝水14 小时前
Ansible 配置与环境搭建超全教程(自动化运维基础)
运维·自动化·ansible
风.foxwho14 小时前
jenkins使用 ED25519密钥 拉取Git 代码 配置
git·servlet·jenkins
ruanCat15 小时前
前端工程化工具链从零配置:simple-git-hooks + lint-staged + commitlint
前端·git·代码规范
木子小喵17 小时前
Git的使用介绍!超通俗!
git
coderYYY17 小时前
git push报错Authentication failed for ‘xxx’也不会弹要求输入用户名密码的最终解决方法
前端·git·gitee·github
@PHARAOH17 小时前
WHAT - git worktree 开发的并发模型
大数据·git·elasticsearch
苦瓜小生19 小时前
【Git】| 将拉下来的代码上传到自己的 Gitee 仓库(手把手教学)
git·gitee