Ansible-playbook's roles and include

Source: Internet
Author: User
Tags vars

Include:

In a large complex architecture, the first problem is the growing playbook file size, a large playbook difficult to understand and maintain, the end method is to use include, your plays break down into different segments and then include them in the other plays . Different segments are categorized according to different purposes. All are included in the main plays .

There are four types of inclusions:

1. Variable contains: allows you to place the variable in an external YAML file

Example:

Vars_files:-Vars.yml-vars1.yml

2.playbook contains: A large project can contain multiple plays

3. tasks include : Place tasks in normal files and include them when needed

Example:

Tasks:vars_files:-Vars.yml-vars1.yml-include:takes/foo.yml

4.handler contains: Allows you to put all handlers handlers in one place

Example:

Handlers:-Include:

Roles:

and if your playbook growth to include does not solve the problem, or you already have a huge number of templates, you might be able to use Roles up. It allows you to group files according to a defined format, essentially, it is an inclusion with some automation capabilities, androles can help you organize your database well.

Rolesallows you to add variables, files, tasks, templates,handlesput them in a folder and then include them. After establishing an effective dependency, you can alsoRolescontains a differentRoles. As with inclusions, you can pass variables toRoles. With these features, you can create a self-containedRolesand it's easy to share it with others.

· For example, to use the template module, to copy a file to the remote host, you need to put this file in the template directory

Example:

-name:copy httpd conf template:src httpd.confdest=/etc/http/httpd.conf owner=root group=root mode=0755

· For example, to use Copy module, copy a file to the remote host, you need to put this file in the Files directory

Example:

-Name Copy:src index.jsp dest=/data/www owner=root group=root mode=0755

---------------------------------------------------------------------------------

├── ansible.cfg├── group_vars│   └── all├── init.yml      #定义所有主机执行roles下的create-sudo-user├── inventory│   ├── test.ini│    └── test_public.ini├── main.yml├── README.md├── roles│   ├──  bamboo│   │   ├── files│   │   │    └── dataman-bamboo-0.9.0.tar.gz│   │   ├── tasks│    │   │   └── main.yml│   │   └──  templates│   │       ├── install.sh.j2│    │       └── supervisor-bamboo.j2│   ├──  chronos│   │   ├── tasks│   │   │    └── main.yml│   │   └── templates│   │       └──  supervisor-chronos.j2│   ├── common│   │   ├──  tasks│   │   │   └── main.yml│   │    └── templates│   │       ├──  dataman.repo.j2│   │       └── docker.j2│    ├── copy-authorized-key│   │   ├── files│   │    │   └── id_rsa_ansible.pub│   │   └──  tasks│   │       └── main.yml│    ├── create-sudo-user│   │   ├── files│   │    │   └── mesos│   │   └── tasks│   │        └── main.yml│   ├── marathon│   │   ├──  tasks│   │   │   └── main.yml│   │    └── templates│   │       ├──  hostname.j2│   │       ├── http_port.j2│    │       ├── master.j2│   │        └── zk.j2│   ├── mesos-master│   │    ├── tasks│   │   │   └── main.yml│    │   └── templates│   │       ├──  cluster.j2│   │       ├── hostname.j2│   │        ├── ip.j2│   │       ├── quorum.j2│    │       └── zk.j2│   ├── mesos-slave│    │   ├── tasks│   │   │    └── main.yml│   │   └── templates│   │        ├── hostname.j2│   │        ├── ip.j2│   │       └── zk.j2│    └── zookeeper│       ├── tasks│        │   └── main.yml│       └──  Templates│           ├── cloudera-cdh5.repo.j2│            ├── myid.j2│            └── zoo.cfg.j2├── test.json└── vagrantfile


This article is from the "Ming Linux blog" blog, be sure to keep this source http://zhaijunming5.blog.51cto.com/10668883/1715634

Ansible-playbook's roles and include

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.