Sobes.tech
Junior — Middle

What does a role in Ansible include and how is it organized?

sobes.tech AI

Answer from AI

The role in Ansible is a way to structure and reuse configurations. It includes a standard directory with specific components:

  • tasks/ — main tasks (playbook) of the role, usually the main.yml file.
  • handlers/ — event handlers, such as restarting a service.
  • templates/ — template files with variables that will be copied to target machines.
  • files/ — regular files that are copied without changes.
  • vars/ — role variables.
  • defaults/ — default variables.
  • meta/ — role metadata, dependencies on other roles.

Organizing roles allows for easy integration and combination in playbooks, improving code readability and maintainability.