AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Crafting and Publishing Your Custom Ansible Collection on Automation Hub

By Luca Berton · Published 2024-01-01 · Category: collections-galaxy

Learn to create and publish a custom Ansible Collection "test.test" on Automation Hub. Follow steps to initialize, customize, build, and upload your collection.

Crafting and Publishing Your Custom Ansible Collection on Automation Hub

Introduction

In the ever-evolving landscape of automation, creating customized solutions becomes paramount. Ansible Automation Hub provides a platform to showcase and share these custom creations with the world. In this guide, we’ll walk you through the process of crafting your custom Ansible Collection, named “test.test,” and publishing it on Ansible Automation Hub.

See also: Creating a New Ansible Collection: A Step-by-Step Guide

Links

Ansible Automation Hub • https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html

Step by step

1. Create the Custom Collection

Begin your journey by creating the “test.test” collection using the ansible-galaxy command-line utility:
ansible-galaxy collection init test.test

You’ll receive a confirmation that the “test.test” collection has been successfully created.

- Collection test.test was created successfully

The command generates the following directory tree in the current directory:

.
└── test
    └── test
        ├── docs
        ├── galaxy.yml
        ├── meta
        │   └── runtime.yml
        ├── plugins
        │   └── README.md
        ├── README.md
        └── roles

6 directories, 4 files

2. Customize the Collection Content

Navigate into the collection directory and modify the “runtime.yml” file located at “test/test/meta/runtime.yml”. You can customize by adding additional modules, plugins, roles, etc.

Here, set the “requires_ansible” parameter to specify the minimum Ansible version required:

---
# Collections must specify a minimum required ansible version to upload
# to galaxy
requires_ansible: '>=2.9.10'

3. Build the Ansible Artifact

The following command creates the “test-test-1.0.0.tar.gz” archive that we can publish in Automation Hub. Generate the “test-test-1.0.0.tar.gz” archive using the following command:
ansible-galaxy collection build

Upon execution, the generated archive is ready to be published on Automation Hub.

Created collection for test.test at /home/luca/collection/test/test/test-test-1.0.0.tar.gz

4. Create a Namespace

Access the Automation Hub interface and navigate to Collections > Namespace > Create. Enter “test” as the namespace name. Create the “test” namespace via the Collections > Namespace > Create menu and insert the “test” in the name pop-up window as shown in the following Figure: Automation Hub Create a Namespace

5. Create the Collection

Within the newly created namespace, select the “Upload collection” button. Proceed by uploading the “test-test-1.0.0.tar.gz” file, created earlier with the ansible-galaxy command. Inside the namespace, select the “Upload collection” button to populate the “test.test” collection with the generated file. Automation Hub New Collection

Upload the “test-test-1.0.0.tar.gz” file generated by the ansible-galaxy command.

Automation Hub Upload Collection

An automatic procedure is going to check the correctness of our artifact.

Automation Hub Collection Check

Now the “test.test” collection is in the “staging” area.

Automation Hub Staging

6. Approval Process

At this point, your “test.test” collection resides in the “staging” area. Automation Hub administrators hold the power to approve or reject it. Admins can navigate to Collections > Approval to make their decisions. An Automation Hub administrator can approve or reject the “test.test” collection in the staging area using the Collections > Approval menu as shown in the following Figure. Automation Hub Approval

7. Publish and Share

With approval granted, your “test.test” collection is now available for usage in the “published” repository. Share this accomplishment with the Ansible community, and let your creation empower automation enthusiasts worldwide. Automation Hub Published

Once approved, the “test.test” collection is available for usage in the “published” repository.

See also: Streamline Ansible Development with Auto-Fixing FCQN Violations

Conclusion

Creating and publishing your custom Ansible Collection on Automation Hub signifies your dedication to innovation and collaboration. It’s an opportunity to make a lasting impact on the automation landscape while joining a community that thrives on creativity. Start your journey today, and let your custom collection pave the way for smarter automation solutions. The world of automation thrives on collective innovation. Your journey doesn’t end here — it’s an ongoing exploration of what’s possible when technology, collaboration, and imagination converge. So, let your custom collection be a beacon of inspiration, guiding others to harness the potential of automation and drive meaningful change in their endeavors. Start crafting, sharing, and creating your automation legacy today!

Related Articles

collection versioning with Ansible Galaxyprivilege escalation with Ansible becomeAnsible roles guide

Category: collections-galaxy

Watch the video: Crafting and Publishing Your Custom Ansible Collection on Automation Hub — Video Tutorial

Browse all Ansible tutorials · AnsiblePilot Home