A teammate wants to publish an internal collection. What goes in it and how do you build it?
IntermediateScenarioRoles, Collections and Project Structure
Answer
Situation read → Packaging for sharing.
What I'd do →
ansible-galaxy collection init acme.platform
# add roles/, plugins/, playbooks/, galaxy.yml
ansible-galaxy collection build
ansible-galaxy collection publish acme-platform-1.4.2.tar.gz --server internal
Add galaxy.yml metadata with namespace, name, version, dependencies.
Why → A tarball is versioned and installable anywhere.
Interview tip → Lint with ansible-lint and sanity-test with ansible-test sanity before publishing.
More on Roles, Collections and Project Structure
You have a 600-line playbook that sets up web, db and monitoring. How do you restructure it?BeginnerWhere do you put a variable users of your role are expected to override?BeginnerTwo roles need to run in a fixed order, such as `common` before `nginx`.BeginnerA role is used twice with different parameters in one play, but only runs once.IntermediateYou want to share roles across several repos and teams.IntermediateHow do you pin Ansible itself so a CI run today behaves like one last month?Intermediate