Interview Prep/Ansible/Roles, Collections and Project Structure

How do you test that a role does not break when its variable `x` is missing?

IntermediateScenarioRoles, Collections and Project Structure
Answer

Situation read → Validate input handling.

What I'd do → Add an argument_specs file so Ansible validates inputs before the role runs.

# roles/nginx/meta/argument_specs.yml
argument_specs:
  main:
    options:
      nginx_listen_port: { type: int, default: 80 }
      nginx_sites: { type: list, elements: dict, required: true }

Why → Missing or wrongly typed variables fail early with a readable message and documented defaults.

Interview tip → ansible-doc -t role can display those specs.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure