Roles provide a framework for fully independent, or interdependent collections of variables, tasks, files, templates, and modules.
In Ansible, the role is the primary mechanism for breaking a playbook into multiple files. This simplifies writing complex playbooks, and it makes them easier to reuse. The breaking of playbook allows you to logically break the playbook into reusable components.
[ansadmin@controller myroles]$ ansible-galaxy init webserver
- Role webserver was created successfully
/home/ansadmin/myroles/webserver
[ansadmin@controller webserver]$ ls -l
total 4
drwxrwxr-x 2 ansadmin ansadmin 22 Sep 22 18:21 defaults
drwxrwxr-x 2 ansadmin ansadmin 6 Sep 22 18:21 files
drwxrwxr-x 2 ansadmin ansadmin 22 Sep 22 18:21 handlers
drwxrwxr-x 2 ansadmin ansadmin 22 Sep 22 18:21 meta
-rw-rw-r-- 1 ansadmin ansadmin 1328 Sep 22 18:21 README.md
drwxrwxr-x 2 ansadmin ansadmin 22 Sep 22 18:22 tasks
drwxrwxr-x 2 ansadmin ansadmin 6 Sep 22 18:21 templates
drwxrwxr-x 2 ansadmin ansadmin 39 Sep 22 18:21 tests
drwxrwxr-x 2 ansadmin ansadmin 22 Sep 22 18:21 vars
No comments:
Post a Comment