Ansible Study Notes (ii)--roles

Source: Internet
Author: User

The previous section outlined the overall layout, which highlights the meaning of the directories under the/etc/ansible/roles/tomcat directory.

此目录的目录结构如下:    .    ├── 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 tomcattemplate模块官方的解释为: 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 Study Notes (ii)--roles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.