Where do you put a variable users of your role are expected to override?
BeginnerScenarioRoles, Collections and Project Structure
Answer
Situation read → Public vs internal role variables.
What I'd do → defaults/main.yml for the public interface, vars/main.yml for internal constants.
# roles/nginx/defaults/main.yml
nginx_worker_processes: auto
nginx_listen_port: 80
Why → Defaults have the lowest precedence, so any inventory or play var wins; vars/ is high precedence and hard to override.
Interview tip → Prefix variables with the role name to avoid collisions.
More on Roles, Collections and Project Structure
You have a 600-line playbook that sets up web, db and monitoring. How do you restructure it?BeginnerTwo roles need to run in a fixed order, such as `common` before `nginx`.BeginnerA role is used twice with different parameters in one play, but only runs once.IntermediateYou want to share roles across several repos and teams.IntermediateHow do you pin Ansible itself so a CI run today behaves like one last month?IntermediateA role installs a package and writes a config, but must support Ubuntu and Rocky Linux.Intermediate