handlers – A set of handlers that are triggered by tasks of the role.files – Contains static and custom files that the role uses to perform various tasks.Here we define some sane default variables, but they have the lowest priority and are usually overridden by other methods to customize the role. defaults – Includes default values for variables of the role.For instance, you can group your tasks in separate YAML files according to some characteristic. It’s possible to include additional YAML files in some directories. Collaboration and velocity are also improved since different users can work on separate roles in parallel without modifying the same playbooks simultaneously.Īnsible checks for main.yml files, possible variations, and relevant content in each subdirectory. Lastly, placing our Ansible code into roles lets us organize our automation projects into logical groupings and follow the separation of concerns design principle. This might not be evident in minimal projects but as the number of playbooks grows, so does the complexity of our projects. Organizing our Ansible content into roles provides us with a structure that is more manageable than just using playbooks. We will see an example of how we can accomplish that later with Ansible Galaxy. Since we have our code grouped and structured according to the Ansible standards, it is quite straightforward to share it with others. This way, we can reference and call them in our playbooks with just a few lines of code while we can reuse the same roles over many projects without the need to duplicate our code. They provide a well-defined framework and structure for setting your tasks, variables, handlers, metadata, templates, and other files. Roles enable us to reuse and share our Ansible code efficiently. As new users automate more and more tasks with playbooks and their Ansible skills mature, they reach a point where using just Ansible playbooks is limiting. When starting with Ansible, it’s pretty common to focus on writing playbooks to automate repeating tasks quickly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |