首页 > 其他 > 详细

ansible-playbook

时间:2017-12-28 13:14:50      阅读:246      评论:0      收藏:0      [点我收藏+]

语言格式:yml

  单个yml文件示例:

 

---
 - hosts: webservers          #主机组
   vars:                             ##变量设置
     http_port: 80
     max_clients: 200
   remote_user: root
   tasks:                            ###主要任务
   - name: ensure apache is at the latest version
     yum: pkg=httpd state=latest
   - name: write the apache config file
     template: src=/srv/httpd.j2 dest=/etc/httpd.conf
     notify:                                 ##条件触发
     - restart apache                      ##重启服务
   - name: ensure apache is running
     service: name=httpd state=started
   handlers:                                 ##在发生改变时执行的操作
     - name: restart apache
       service: name=httpd state=restarted

 ‘notify’ 下列出的即是 handlers.

 

ansible-playbook基本介绍 

 

项目结构:

技术分享图片
site.yml
webservers.yml
fooservers.yml
roles/
   common/
     files/
     templates/
     tasks/
     handlers/
     vars/
     defaults/
     meta/
   webservers/
     files/
     templates/
     tasks/
     handlers/
     vars/
     defaults/
     meta/
View Code

 

ansible-playbook

原文:https://www.cnblogs.com/FRESHMANS/p/8134893.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!