Junior — Middle
Where can variables be set in role definitions?
sobes.tech AI
Answer from AI
In role definitions (for example, in Ansible roles), variables can be set in several places:
- Inside the
defaults/main.ymldirectory — these are variables with the lowest priority, which can be overridden. - Inside the
vars/main.ymldirectory — variables with a higher priority than defaults. - In files within
vars/— additional variable files can be created. - In playbooks that invoke the role — variables can be passed directly when calling the role.
- In inventory files or group variables — variables applied to hosts or groups.
- Through the command line or external variable files.
Thus, variables can be set both inside the role itself (in defaults and vars) and outside, when calling the role or in the inventory.