How we can convert our ansible PlayBook to Role ? 🤔

Shashwat Singh
2 min readMar 27, 2021

We Will Also Going To See steps for uploading it on Ansible Galaxy !! 🤔

Let’s Start 😁

Wants to Check How Many Role Do you Have ?

$ ansible-galaxy role

Initialize an new Role For the Webserver

$ ansible-galaxy init role_name

Now, As you can see that for every part which we are writing in same playbook now those are divided into folders ….
Like Here :
files → Static file which we used for copy
tasks → the config tasks which we wants to assign
templates → In this folder we will kept the files which are dynamic
vars → It help us to keep all the variables which are related to our role
…… and many-more WoW😮

→ Under Task Section Assign the work
→ If you have any variables then you may now what you have to do …

For More You Can See The Roles Which I have Created For You All To Understand it in practical manner . . . .
→ Link : https://github.com/Shashwatsingh22/haproxy_sh/

Now , you might have one question ok we have created the Roles like For Starting the Ec2 instances , config of webserver or config of load-balancer … etc …
How We Will Use These Roles ? 🤔 or How they are make our work easy ?

So , I will tell in short form Now you have make an environment just like plug play … its wow 😁😎

Example :

Lets Try To Upload On Ansible Galaxy !!

  1. You Have To Make An Specific Repo On SCM(GitHub) For the Role .

2. Now U just need to Go On Ansible Galaxy And Import It

Hope You Like This Blog !!

--

--