Day-13 Refactoring Ansible Playbooks into Roles π
Source: Dev.to
The Playbook
- name: Installing and running apache2
hosts: all
roles:
- httpd
Leveling Up with Roles
I created my first role structure:
roles/
βββ my-app/
βββ tasks/
β βββ main.yml
βββ handlers/
β βββ main.yml
βββ vars/
βββ main.yml
This makes the code reusable. If I need this configuration again, I just call the role!
The Code
Check it out here: https://github.com/JayanthDasari7/Ansible-Roles
Has anyone else here struggled with the directory structure of Roles initially? Let me know in the comments! π