Junior — Middle
What are the main components included in a properly structured role in Ansible?
sobes.tech AI
Answer from AI
A properly structured role in Ansible typically includes the following main components:
- tasks/ — directory with the main tasks of the role, usually a main.yml file where automation steps are described.
- handlers/ — handlers that are called upon changes, such as restarting services.
- templates/ — file templates (usually Jinja2) that are filled with parameters.
- files/ — static files that are copied to target hosts.
- vars/ — role variables defined in main.yml or other files.
- defaults/ — default variable values that can be overridden.
- meta/ — role metadata, including dependencies on other roles.
This separation helps keep the code clean, reusable, and easy to maintain.