2023-Nov-03-R11.1a

Define Playbook

Use either of the following ways to define a playbook

Information Note Please follow Ansible’s best practice for the project structure/directory layout (only applicable to Sync Up Playbook from SCM):

https://docs.ansible.com/ansible/latest/user_guide/sample_setup.html#sample-directory-layout

https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html#directory-layout

Use or Install Ansible Role/Collection

One crucial way to organize your playbook content is Ansible’s “roles” organization feature. You can embed your role content in your project directory (Refer to https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html for the best practice of setting up role directory structure) or trigger the installation of the roles/collections on Ansible by including the roles in a requirements.yml file and defining the file in your Ansible project directory. 

You can trigger the installation of roles and collections from the same requirements.yml file. For the syntax please follow Ansible’s documentation: https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-roles-and-collections-from-the-same-requirements-yml-file
Information Note: if you are using older Ansible versions prior to (including) Ansible 2.9, to trigger the installation of collections, please contact NetBrain to apply a small patch.
Information

Note: The requirements file path must be /roles/requirements.yml in your Git Ansible repo.

References:

Sample directory layout from Ansible Documentation:

https://docs.ansible.com/ansible/latest/user_guide/sample_setup.html#sample-directory-layout

Directory layout from Ansible’s best practice:

https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html#directory-layout

Syntax of installing roles and collections from requirements.yml file:

https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html#directory-layout