Ansible Galaxy is your source for community content for Ansible, a popular multipurpose automation tool. In Ansible Galaxy, you can find roles and collections for just about any configuration management scenario. Don't see a role or collection that meets your needs, but have the know-how to build a solution? You can also share your creations with the broader community. In this article, I will teach you how to get started with Ansible Galaxy.

Ansible Galaxy enables you to discover new roles or collections quickly and easily to help you deploy infrastructure and applications faster. I'll also show you how you can share your own roles and collections with others in the Ansible community.

How to use Ansible Galaxy

Ansible comes out of the box with a core set of modules that handle most basic system configuration needs. However, there's much more that Ansible can configure through the use of roles and collections.

Imagine, for a moment, that you need to automate the configuration of the firewall on an Ubuntu server. You have some familiarity with Ansible and would like to build a playbook to accomplish this task. You just don't know where to start.

Here's where Ansible Galaxy comes in.

Discovering roles and collections

It's best to begin by heading over to the Ansible Galaxy search page. From the search page, you can apply and combine filters to help narrow the terms you are searching for. You can also adjust the results to further enhance your search. From the search page, you have access to both partner and community content.

Recall that you need to configure the firewall on a new Linux server using ufw. Let's walk through how to discover some community-provided roles and collections that can help accomplish your goal.

Start by clicking Search in the left menu on the Ansible Galaxy home page.

Searching in Ansible Galaxy

Searching in Ansible Galaxy

Next, type in a search term for the role or collection you need. For this example, you are searching for "UFW." You may also choose to apply filters, but let's keep things simple for now. Click the magnifying glass to search or press the Enter key.

Searching for UFW

Searching for UFW

Notice that the results return both Collections and Roles.

UFW search results

UFW search results

UFW search results

From here, you can inspect some of the collections and roles a bit further and read their installation instructions and code examples.

Community contributed role details

Community contributed role details

Community contributed role documentation

Community contributed role documentation

Installing roles and collections

Now that you have found a suitable role, it's time to make the role or collection available to Ansible by installing it. To do so, follow these steps:

Assuming you already have Ansible installed and have an internet connection on your host, you can install the module using the installation instructions provided in the role contributor's documentation, as shown below:

Ansible-galaxy install markahesketh.ufw

Community role installation

Community role installation

From here, you can begin writing Ansible playbooks that use the UFW role you downloaded to configure UFW for a Linux host.

Note: Ansible comes with many built-in community modules and roles out of the box. For example, you could use community.general.ufw to manage the UFW firewall settings instead of downloading them from Ansible Galaxy.

You can repeat the steps above for other roles or collections that you may find interesting. Always be sure to read over the provided documentation to fully understand how the role or collection is used, as not all will contain the options you may need.

You can read more about installing roles and collections in the Ansible Galaxy Documentation.
But what if you have written a role that contains every option a SysAdmin would need for a task? Glad you asked. Keep reading!

How to contribute to Ansible Galaxy

Contributors are what make Ansible Galaxy a great online community that shares reusable automation content. There are a few guidelines for contributing to Ansible Galaxy that you should follow when considering releasing your creation for community consumption. Here's what you need to do to get started.

Join the community

Joining the Ansible Galaxy community is as simple as linking an existing GitHub account.

Start by clicking Login in the top ribbon menu.

Logging into the community

Logging into the community

Next, click the GitHub logo to begin linking your account with Ansible Galaxy. (You can sign up for a free GitHub account if you do not already have one.)

Linking the GitHub account

Linking the GitHub account

Now authorize Ansible Galaxy to have read-only permission to your GitHub profile.

Authorizing Ansible Galaxy

Authorizing Ansible Galaxy

Once linked, you will see two additional menu items on the left nav bar.

New menu options

New menu options

And that's it! Now that your account has been created and linked to a GitHub profile, all you have to do now is share the repository that contains your Ansible role or collection.

Sharing your creations

Let's assume you have already created a role that is available in a GitHub repository. To share this role, you must add it from either your GitHub repository or by uploading a collection.

Add Content menu

Add Content menu

Import content from source

Import content from source

Once you've imported your role or collection, you'll be able to search for the namespace and share the link to your contribution with the rest of the world!

Subscribe to 4sysops newsletter!

What's next

The Ansible Community is where it's at today because of current and future contributors like you. This is just one aspect of what you can do with Ansible Galaxy. If you are interested in other ways to contribute, check out the How can I help? documentation. You can also simply answer online questions through some of the official channels.

0 Comments

Leave a reply

Please enclose code in pre tags

Your email address will not be published.

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account