If you are seeing role conflicts or version errors when using ansible-galaxy, here is how to resolve them.
Common Error Messages
ERROR! the role 'geerlingguy.docker' was not foundERROR! Unexpected Exception, this is probably a bug: cannot install role
'geerlingguy.docker' because a role with that name already existsERROR! Version conflict: role 'nginx' version 3.0.0 is already installed
but version 4.0.0 is requiredFix 1: Force Reinstall
# Force reinstall a specific role
ansible-galaxy role install --force geerlingguy.docker
# Force reinstall all roles from requirements
ansible-galaxy role install -r requirements.yml --forceFix 2: Clear Role Cache
# Remove the conflicting role
rm -rf ~/.ansible/roles/geerlingguy.docker
# Reinstall
ansible-galaxy role install geerlingguy.dockerFix 3: Use Collections Instead of Roles
Modern Ansible prefers collections over standalone roles:
# requirements.yml
collections:
- name: community.docker
version: ">=3.0.0"
- name: community.general
version: ">=8.0.0"ansible-galaxy collection install -r requirements.ymlFix 4: Specify Roles Path
# Install to a specific directory
ansible-galaxy role install -p ./roles geerlingguy.docker
# Or set in ansible.cfg
# [defaults]
# roles_path = ./roles:~/.ansible/rolesFix 5: Pin Versions in Requirements
# requirements.yml
roles:
- name: geerlingguy.docker
version: "7.1.0"
- name: geerlingguy.nginx
version: "3.2.0"ansible-galaxy role install -r requirements.yml --forcePrevention
- Always pin role versions in
requirements.yml - Migrate from roles to collections where possible
- Use
ansible-galaxy role listto check installed roles and versions - Include
requirements.ymlin your Git repository for reproducibility

