How To Import Role in Ansible-Galaxy

What is Ansible Galaxy

Ansible Galaxy is a repository for Ansible Roles that are available to drop directly into your Playbooks to streamline your automation projects. It is easy to get up and running with Ansible. Even a new sysadmin could start automating with Ansible in a matter of a few hours. Ansible automates using the SSH protocol.

In this blog, we are going to do how to import a Single Ansible role into an Ansible Galaxy. I hope you all have read the previous article on how to create a role for setting up Kubernetes multi-node cluster using ansible if not you can read it by clicking on the below link.


Login to Ansible Galaxy from below you can login

GitHub even we can upload locally but GitHub login is needed

After Login we can see most popular roles Home menu

Now all setup is set we can create an Ansible-Galaxy

Make sure in your ansible having system installed GIT if not installed here we are using Linux RHEL8.

>> yum install git -y

Then create a ansible-galaxy(role)

ansible-galaxy role init Test_Role

Go to GitHub click on new and create a GitHub repository

Create Repository

In your system type this commands to Initialize a git repo, Connect and push to a GitHub

>> git init
>> git add .
>> git commit -m "...."
>> git branch -M main
>> git remote add origin
>> git push -u origin main

After running the above command your all role file will be pushed to the GitHub repo.

Now go to your ansible-galaxy page and there click on My content and after that click on Add content then select import role from GitHub and after that search for repo name in which your role exists

Click on import GitHub repo and “Ok” then search for ansible role repository select and click ok

Here It’s showing logs of our roles

Below we can see that our role is successfully pushed to an Ansible-Galaxy

By clicking on test_ansible_galaxy that redirect to a role using the below command can be downloaded

That’s it we have successfully pushed our role into ansible-galaxy.

Here is a link for this Ansible-Role: click here

Few more Roles in Ansible Galaxy:

AWS EC2 Provisioning

K8S Master Setup

K8S Slave Setup

To improve Quality Score make sure you follow the below steps

No empty lines

No extra spaces between Hyphen(-) and word

Try to avoide shell and command module

Don’t leave empty lines More than two lines(2>0)

Don’t Use unwanted spaces

Guys, here we come to the end of this blog I hope you all like it and found it informative. If have any query feel free to reach me

Keep Learning !! Keep Sharing !!

ARTH-School of technology, BCA graduate