Skip to content

[SETUP] Fix Ansible Collections Path for apt-installed Ansible #9

@pierreribeiro

Description

@pierreribeiro

[SETUP] Fix Ansible Collections Path for apt-installed Ansible

Problem Statement

Severity: HIGH
Impact: Blocks ansible-lint validation, affects Phase 2, 4, and all Homebrew-dependent phases

Discovery

During Phase 4 validation (2025-11-04), discovered that apt-installed Ansible does not automatically detect system-level collections installed in /usr/lib/python3/dist-packages/ansible_collections.

Symptoms

$ ansible-lint roles/language_runtimes/

[WARNING]: Error loading plugin 'community.general.homebrew': 
No module named 'ansible_collections.community'

WARNING: Unable to load module homebrew at 
roles/language_runtimes/tasks/python.yml:13 for options validation

Root Cause

When Ansible is installed via apt, it uses system Python and stores collections in:

/usr/lib/python3/dist-packages/ansible_collections/

However, Ansible's default collection search path does not include this location.

Verification

Collections ARE installed, but not in search path:

$ ls /usr/lib/python3/dist-packages/ansible_collections
amazon     community     google      ...

Permanent Solution

Update scripts/phase-0-bootstrap.sh to configure paths after Ansible installation:

# Add to shell config
export ANSIBLE_COLLECTIONS_PATH=~/.ansible/collections:/usr/lib/python3/dist-packages/ansible_collections:/usr/share/ansible/collections

# Add to ansible.cfg
collections_path = ~/.ansible/collections:/usr/lib/python3/dist-packages/ansible_collections:/usr/share/ansible/collections

Testing Validation

# Verify paths
ansible --version | grep "collection location"

# Test module loads
ansible-doc community.general.homebrew

# Test lint
ansible-lint roles/language_runtimes/

Priority

Priority: HIGH
Blocking: Phase 4 validation
Effort: LOW (15 minutes)

Discovered by: @pierreribeiro
Date: 2025-11-04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghigh-priorityLevel of prioritization, importance, and relevance of the activity.phase-0This refers to the phase of the project to which the code belongs.setupThis refers to the code relevant to the section with the same name in the label.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions