To create a collection:
Create a collection skeleton with the
ansible-galaxy collection initcommand.
Add modules and other content to the collection.
Build the collection into a collection artifact with ansible-galaxy collection build.
Publish the collection artifact to Galaxy with ansible-galaxy collection publish.
A user can then install your collection on their systems.
Create your collection skeleton in a path that includes
ansible_collections, for example collections/ansible_collections/.
To start a new collection, run the following command in your collections directory:
ansible_collections#> ansible-galaxy collection init my_namespace.my_collection
Both the namespace and collection names use the same strict set of requirements. See Galaxy namespaces on the Galaxy docsite for those requirements.
It will create the structure
If Git is used for version control, the corresponding repository should be initialized in the collection directory.
Once the skeleton exists, you can populate the directories with the content you want inside the collection. See ansible-collections GitHub Org to get a better idea of what you can place inside a collection.
ansible-galaxy collection command
ansible-galaxy collection command implements the following sub commands:
init: Create a basic collection skeleton based on the default template included with Ansible or your own template.
build: Create a collection artifact that can be uploaded to Galaxy or your own repository.
publish: Publish a built collection artifact to Galaxy.
install: Install one or more collections.
To learn more about the
ansible-galaxy command-line tool, see the ansible-galaxy man page.