Develop a private collection
Learn how to develop a private collection that provisions a KVM guest on an IBM Z and LinuxONE LPAR.
-
Create and
cdto this directory structure (this structure is required for the Ansible sanity checking later):mkdir -p ansible_collections/example cd ansible_collections/example -
Download the sample collection from here. Rename the folder to
rhel_kvm_roles:git clone https://github.com/ansible-collections/collection_template.git # renaming the folder to rhel_kvm_roles: mv collection_template rhel_kvm_roles cd rhel_kvm_roles -
Edit
galaxy.yml.-
Change
namespaceto:example -
Change
name to:rhel_kvm_roles -
Add a few tags, so people can search for collections
Note: For proof of concept and demo purposes no further changes are made.# See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html namespace: example name: rhel_kvm_roles version: 0.1.0 readme: README.md authors: - YOUR NAME (github.com/YOURGITHUB) description: null license_file: LICENSE tags: # tags so people can search for collections https://galaxy.ansible.com/search # tags are all lower-case, no spaces, no dashes. - libvirt - kvm - provisioning - provision repository: https://github.com/ansible-collections/community.REPO_NAME #documentation: https://github.com/ansible-collection-migration/community.REPO_NAME/tree/main/docs homepage: https://github.com/ansible-collections/community.REPO_NAME issues: https://github.com/ansible-collections/community.REPO_NAME/issues build_ignore: # https://docs.ansible.com/ansible/devel/dev_guide/developing_collections_distributing.html#ignoring-files-and-folders - .gitignore - changelogs/.plugin-cache.yaml -
-
Create a new folder called
roles. Download and unpack guest_install.zip into that directory.mkdir roles cd roles curl https://www.ibm.com/docs/en/linuxonibm/pdf/guest_install.zip unzip guest_install.zip rm guest_install.zip -
Go to the
rhel_kvm_rolesfolder and run the sanity check:cd .. ansible-test sanity -
Build the collection tarball:
ansible-galaxy collection buildExpected output:
Created collection for example.rhel_kvm_roles at /path/to/rhel_kvm_roles/example-rhel_kvm_roles-0.1.0.tar.gz
Upload to private automation hub
-
Go to Collections -> Namespaces. Click Create to create a namespace, and name it
example:

Note: You can also use any existing namespace. -
In the example namespace, click upload collection:

-
Select the collection tarball. Click upload:

-
After the import is complete, the collection resides in the repository
Staging. By default, there is a pipeline defined that you can use to test the collections before they are published to thePublishedrepository. To move the collection fromStagingtoPublished, click Collections -> Approval:
-
In the Approval dashboard, click approve to move the collection from the staging repository to the published repository:

For future uploads you can also use the following command as described here:
ansible-galaxy collection publish path/to/my_namespace-my_collection-1.0.0.tar.gz --api-key=SECRET
To use this collection directly from the Ansible Automation Controller (AAC) continue with running a playbook.
If you want to use the collection from a command line interface (CLI), go to the published
repository (Collections -> Repositories -> published), click Copy CLI
configuration and place the information in /etc/ansible.cfg on the system that
needs access to this collection:

To learn more about the CLI, have a look at Configuring Red Hat Automation Hub as the primary source for content.