Interview Prep/Ansible/Vault, Performance and Execution Behaviour

`--start-at-task "Deploy app"` fails with `'artifact_url' is undefined`

IntermediateTroubleshootingVault, Performance and Execution Behaviour
Answer

Likely causes → --start-at-task skips everything before that task, including the set_fact, register or include_vars tasks that define later variables.

Fix → Tag the tasks that define variables with always, so they run even when skipped over:

- ansible.builtin.set_fact:
    artifact_url: "{{ repo_url }}/{{ app_version }}/app.tgz"
  tags: [always]

Alternatively, use --tags deploy with well-tagged roles instead of --start-at-task.

Prevent → Compute derived variables in vars or defaults (evaluated lazily) instead of in set_fact where possible.

All Ansible questions Roadmap: Ansible

More on Vault, Performance and Execution Behaviour