Interview Prep/Ansible/Roles, Collections and Project Structure

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.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure