Ansibleexit code > 0
AnsibleUndefinedVariable: '...' is undefined
$fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'my_var' is undefined"}
Analysis
You are referencing a variable in a template or task that hasn't been set.
Common Triggers
- ●Typo in variable name.
- ●Forgot to include the
vars_file. - ●Variable conditional logic failed.
Debug Checks
- $Grep for the variable name in your playbooks.
Resolution
1
Define the variable in
defaults/main.yml or group_vars.2
Use
default filter: {{ my_var | default('value') }}.Metadata
- Tool
- Ansible
- Severity
- High
- Tags
- #ansible#iac#variable