I've got a strange situation today. I called one of my variables in a playbook environment
. If I dump variables using debug
instruction, it is shown ok
"environment": "development",
But if I try to access it from a script using {{ environment }}
it is always assigned a value of {}
. I renamed it and it worked ok. Why is that? Is environment
a reserved name in Ansible? I checked variable dump - there is no clashes with defined vars.
I found a statement regarding environment
in the Google group:
Yes, environment is a restricted keyword. Initially specific within playbooks, but it gets injected in the runner:
inject['environment'] = self.environment
so it will erase whatever value was set by inventory of vars.
There is a yet unaddressed feature request to warn if reserved variables are used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With