Ansible Playbooks vs Roles

后端 未结 5 1183
暖寄归人
暖寄归人 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 21:04

    Also keep in mind a playbook can call more than one role if a meta file is used that is intended to affect the different roles.

    Example Playbook: dual_role-playbook.yml

    - name: Some Action for two roles
      hosts: localhost
    
      vars_files:
        - roles/dual_role/meta/main.yml
    
      roles:
        - dual_role/container-1
        - dual_role/container-2
    

    The role folder and files scheme will look like this:

    dual_role-playbook.yml
      -- roles
         -- dual_role
            -- meta/main.yml
            -- container-1
               -- tasks/main.yml
               -- templates/template.j2
            -- container-2
               -- tasks/main.yml
               -- templates/template.j2
    

提交回复
热议问题