Short note on ansible/ansible galaxy:
- ansible-galaxy takes care of install the roles. Regardless if defined via a requirements.yaml or defined via the “dependencies:” section in the meta/main.yaml of a role.
- ansible-playbook/ansible-pull doesn’t care about installation of roles, it just wants the defined dependencies (same meta/main.yaml) to be present. Here is the role_path important.
Knowing this it allows you to fulfill many usage- and development patterns. Like developing company wide reusable ansible roles with multiple teams (DevOps).
Shared roles using gitlab repositories
Define the role dependencies in the corresponding section of the role’s meta/main.yml.
- src: https://gitlab%2Bdeploy-token-13:email@example.com/ansible/shared/nginx.git
- src: https://gitlab%2Bdeploy-token-13:firstname.lastname@example.org/ansible/shared/postfix.git
The installation of roles (and their dependencies) and running the playbook becomes a simple two-liner:
# install roles and their dependencies
ansible-galaxy install "git+https://gitlab+deploy-token-19:email@example.com/ansible/products/product.git,master" --force
# apply the playbook (using the defined and installed dependencies)
ansible-playbook -i localhost, /root/.ansible/roles/product/product/playbook.yml