Ansible Playbooks vs Roles

后端 未结 5 1170
暖寄归人
暖寄归人 2021-01-29 20:38

According to the Ansible docs, a Playbook is:

...the basis for a really simple configuration management and multi-machine deployment system, unlike any that

5条回答
  •  时光说笑
    2021-01-29 20:51

    Simply put:

    A playbook is like the main program, it contents complete instructions to finish the job. However, for big projects, it is not desirable to actually put every detail in it. So you need role.

    A role is a subroutine and usually achieves one goal, e.g. setup a database server. You can put it in roles/ directory, or download 3rd party roles by providing URIs in rolesfile.yml and ask ansible-galaxy to download them for you.

    The [database] is a host group defined in inventory file that lists hosts that belong to the database group. You can also specify a group of web servers by specifying something like

    [web]
    web1.example.com
    web2.example.com
    

    Group web or database can then be used in playbooks or roles to specify the hosts to apply.

    The groups can also be used in command ansible to run ad-hoc commands.

提交回复
热议问题