I'm trying to define Ansible variables this way:
user:
name: First Last
nick: '{{ vars["user"]["name"] | regex_replace("\W", "_") }}'
email: '{{ vars["user"]["nick"] }}@example.com'
And the result email
is: "{{ vars[\"user\"][\"name\"] | regex_replace(\"\\W\", \"_\") }}@example.com
.
I also tried to set email
like this: {{ lookup("vars", "user.nick") }}@example.com
or {{ lookup("vars", "user")["nick"] }}@example.com
,
and it says An unhandled exception occurred while running the lookup plugin 'vars'
.
Is there a way to get resulting variable values as:
user:
name: First Last
nick: First_Last
email: First_Last@example.com
?
ansible 2.9.10, python version = 3.8.5