Interview Prep/Ansible/Roles, Collections and Galaxy

How do you install roles from Galaxy and keep them reproducible?

BeginnerConceptRoles, Collections and Galaxy
Answer

List them in requirements.yml with pinned versions and install into the project.

roles:
  - name: geerlingguy.docker
    version: 7.4.1
  - src: https://github.com/example-org/ansible-role-hardening.git
    scm: git
    version: v2.3.0
    name: hardening
ansible-galaxy role install -r requirements.yml -p roles/

Pinning a version or Git tag stops an upstream change from breaking your next run.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Galaxy