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

相关推荐
JiaWen技术圈1 小时前
增量静态再生(ISR)详解:Next.js 中的实现与应用
javascript·git·ubuntu
The Chosen One9853 小时前
【Linux】深入理解Linux进程(二):进程的状态
linux·运维·服务器·开发语言·git
TimberWill3 小时前
git worktree实现分支管理
git
普修罗双战士3 小时前
项目设计-文章系统发布文章完整前后端设计
java·数据库·vue.js·spring boot·git·intellij-idea
bzmK1DTbd13 小时前
Git版本控制:Java项目中的分支管理与合并策略
java·开发语言·git
OYangxf17 小时前
Git基础概念
git
weixin_4022784520 小时前
VS code 本地推送github添加SSH设置
运维·git·ssh
笑望灬星辰1 天前
VS Code 编辑器 Git 工具 - 分支操作【保姆级教程】
git·vscode·编辑器
shisanjin1231 天前
关于 IDEA2025 版本中对 git 的操作与使用
git·github·idea
熬夜敲代码的小N1 天前
鸿蒙PC开发者必备!GitNext深度测评:一站式Git管理工具
git·华为·harmonyos