ansible学习笔记(二) -- roles
2016-05-10 18:09
453 查看
上一节把整个布局大概列了一下,这节重点记录一下 /etc/ansible/roles/tomcat 这个目录下的各目录的意义
此目录的目录结构如下: . ├── files │ └── tomcat-initscript.sh ├── handlers │ └── main.yml ├── tasks │ └── main.yml └── templates ├── iptables-save ├── server.xml └── tomcat-users.xml
tasks/main.yml 里面有如下行: - name: Configure Tomcat server template: src=server.xml dest=/usr/share/tomcat/conf/ notify: restart tomcat - name: Configure Tomcat user template: src=tomcat-users.xml dest=/usr/share/tomcat/conf/ notify: restart tomcat template模块官方的解释为: Templates a file out to a remote server. 大概意思就是当 src=config_file 这些文件发生变化的时候,触发notify的动作 templates目录就是存放这些文件用的(一般都是一些配置文件) handlers目录里有一个main.yml文件,就是用来执行notify动作的 大概的流程为: templates/config_file 发生变化 --> 触发notify: action --> action定义在 handlers/main.yml 中 notify后面的动作名字必须与handlers/main.yml里面的name后面的名字一致,例: - name: Configure Tomcat user template: src=tomcat-users.xml dest=/usr/share/tomcat/conf/ notify: restart tomcat handlers: - name: restart tomcat service: name=tomcat state=restart 而files目录下存放的是一些脚本, 通过copy模块可以transport到remote hosts上的,而后触发notify动作之后执行的脚本
相关文章推荐
- 基于 ANSIBLE 自动化运维实践
- 集群运维自动化工具ansible之使用playbook安装zabbix客户端
- linux 自动化运维工具ansible的使用详细教程
- Python利用ansible分发处理任务
- Puppet,Chef,Ansible的共性
- Ansible中Playbook方法的标准输出定义
- Ansible之playbook自动完成硬盘分区,格式化,挂盘,并远程创建用户
- 自动化运维学习--python
- ansible常用模块用法
- ansible学习笔记(四):when在include中使用
- 浅谈开源工具自动化运维阶段
- linux ansible 自动化部署工具
- 节点配置文件(Inventory) 详解
- Ansible 安装与简单使用
- 自动化运维工具ansible学习+使用ansible批量推送公钥到远程主机[学习马哥]
- Operations-ansible-01
- Ansible
- AIX 6.1安装python
- ansible 连接 windows (通过powershell)