Skip to content

Commit 5904ca8

Browse files
fix(ansible): install community.general collection in container (#13)
The dev-toolchain container ships ansible-core but not the community.general collection, which is required for the yaml callback plugin, json_query filter, and many commonly-used modules. Projects using stdout_callback = yaml in ansible.cfg fail with "No module named ansible_collections.community". Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4d4c8ab commit 5904ca8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

scripts/install-ansible.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
# Dependencies: python3, pip, lib/log.sh, lib/platform.sh
77
#
88
# Tools installed:
9-
# - ansible-lint (Ansible playbook/role linter — pulls ansible-core as dependency)
10-
# - molecule (Ansible role testing framework)
9+
# - ansible-lint (Ansible playbook/role linter — pulls ansible-core as dependency)
10+
# - molecule (Ansible role testing framework)
11+
# - community.general (Ansible collection — yaml callback, json_query, common modules)
1112

1213
set -euo pipefail
1314

@@ -69,4 +70,14 @@ else
6970
log_info "molecule installed successfully"
7071
fi
7172

73+
# Install community.general collection (idempotent)
74+
# Required for yaml callback plugin, json_query filter, and many common modules
75+
if ansible-galaxy collection list community.general &>/dev/null; then
76+
log_info "community.general collection is already installed, skipping"
77+
else
78+
log_info "Installing community.general Ansible collection"
79+
ansible-galaxy collection install community.general
80+
log_info "community.general collection installed successfully"
81+
fi
82+
7283
log_info "Ansible tooling installation complete"

tests/test-ansible.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ check_tool() {
5050
check_tool "ansible-lint" "--version"
5151
check_tool "molecule" "--version"
5252

53+
# Verify community.general collection is installed
54+
if ansible-galaxy collection list community.general &>/dev/null; then
55+
log_info "community.general collection — OK"
56+
else
57+
log_error "community.general Ansible collection is not installed"
58+
FAILURES=$((FAILURES + 1))
59+
fi
60+
5361
if [[ "${FAILURES}" -gt 0 ]]; then
5462
log_error "Ansible tooling validation failed: ${FAILURES} tool(s) missing or broken"
5563
exit 1

0 commit comments

Comments
 (0)