Ansible "Found variable using reserved name" warning in CI
Ansible warns that a variable you defined uses a name it reserves for its own use (such as environment, name, or tags). The value may be ignored or shadow a built-in, producing surprising behaviour, and CI that treats warnings as errors will fail the job.
What this error means
The run prints "[WARNING]: Found variable using reserved name: environment". Pipelines with -W error or warning gates turn this into a failure.
[WARNING]: Found variable using reserved name: environmentCommon causes
A user variable named like an Ansible keyword
Defining environment, name, or another reserved key as a variable collides with Ansible internals, which triggers the warning.
A role default reusing a reserved word
A role ships a variable whose name overlaps a built-in, so every play that includes it emits the warning.
How to fix it
Rename the variable
- Find the reserved name the warning reports.
- Rename it with a role or app prefix to avoid the collision.
- Update every reference and re-run.
# before: environment: prod
myapp_environment: prodPrefix all role variables
Adopt a rolename_ prefix convention so role variables never overlap Ansible reserved names.
How to prevent it
- Prefix variables with the role or app name.
- Avoid Ansible reserved words like environment, name, tags as variable names.
- Lint for reserved-name usage before merge.