创建playbook
Tower playbook 项目默认存在 /var/lib/awx/projects/
su - awx
cd projects/
mkdir ansible-for-devops && cd ansible-for-devops
cat main.yml << EOF
---
- hosts: all
gather_facts: no
tasks:
- name: Check the date on the server.
command: date
- name: Check the eth0 ip on the server.
command: ifconfig eth0
EOF
创建登陆凭据
![](http://upload-images.jianshu.io/upload_images/3629406-755329a7a7001304.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
创建项目
![](http://upload-images.jianshu.io/upload_images/3629406-0b0a38c2210d4a39.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
创建主机清单
![](http://upload-images.jianshu.io/upload_images/3629406-fea7a6dae4a494e5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
在主机清单里添加主机
点击主机清单名称,就可以进入添加主机的页面
![](http://upload-images.jianshu.io/upload_images/3629406-95a29edd6df14575.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
点击 +ADD HOST
![](http://upload-images.jianshu.io/upload_images/3629406-cb3f86552d11073c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
本次添加了2个主机
![](http://upload-images.jianshu.io/upload_images/3629406-ca5b94914ee16adb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
创建任务模板
Inventory 选择 ops_主机清单
PROJECT 选择 Test_Project
PALYBOOK 选择 man.yml
MACHINE CREDENTIAL 选择 ssh登陆账号
其他默认
![](http://upload-images.jianshu.io/upload_images/3629406-21d7ad7922777022.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
运行模板
点击任务右侧得火箭按钮
![](http://upload-images.jianshu.io/upload_images/3629406-b2c78ccc7ee3c801.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
查看任务运行情况
![](http://upload-images.jianshu.io/upload_images/3629406-819ff36fa335680f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
DETAILS 里面可以查看任务得详细信息
转自
Ansible Tower系列 三(使用tower执行一个任务) - 简书
http://www.jianshu.com/p/804832965259