Ansible - Post - 12 - Ansible Roles :
In this blog post, we will see how to use ansible roles to execute tasks on remote machines, it is nothing but segregating templates, vars, tasks and handlers in separate folder for better flexibility and visibility. you can assign a role to the target server and when executed it implements the tasks defined under that role.
I have attached the demo9.tar file at the bottom of this post,
As usual we define the ansible configuration file and the inventory file.
You can see the folder structure defined under the roles folder. Each individual folder will contain the YML file and you can see the contents of the yml file under tasks, handlers and vars.
Now we will execute the individual roles and the common roles using the webservers.yml, dbservers.yml and the common.yml file.
You can see that the packages are successfully installed the required services are started.
Thanks for viewing the post,
please post your comments below.
Please Like & Follow us on Facebook & Twitter,