ansible-galaxy install Command Reference
Install Ansible roles and collections from a requirements file.
ansible-galaxy install fetches the roles and collections your playbooks depend on, typically from a requirements.yml. It is the dependency step that runs before ansible-playbook in CI.
What it does
ansible-galaxy install downloads roles (and, with the collection subcommand, collections) from Galaxy or a Git source into a roles/collections path. Pinning versions in requirements.yml makes playbook runs reproducible across runners.
Common flags and usage
- -r requirements.yml: install everything listed in the requirements file
- ansible-galaxy collection install -r requirements.yml: install collections
- -p PATH / --collections-path PATH: install into a specific directory
- --force: reinstall even if already present
- --ignore-errors: continue past individual install failures
Example
- name: Install Ansible dependencies
run: |
ansible-galaxy install -r requirements.yml
ansible-galaxy collection install -r requirements.ymlIn CI
Run ansible-galaxy install before ansible-playbook so roles and collections are present; pin versions in requirements.yml for reproducibility. Cache the install path between runs to speed up pipelines, and install both roles and collections when your requirements file declares both.
Key takeaways
- ansible-galaxy install fetches roles and collections from requirements.yml.
- Pin versions so playbook runs are reproducible across CI runners.
- Run it before ansible-playbook and cache the install path for speed.