I have the following scenarion
I have definied a variable named old_var_name inside group_vars/all/common.yml the following way
group_vars/all/common.yml
old_var_name: some_text
I have a foo.yml and a bar.yml files defined the following way:
foo.yml
- name: Do stuff
vars:
new_var_name: “{{ old_var_name }}”
include: bar.yml
bar.yml
- name: Debug var
debug: msg={{ new_var_name}}
If I call the tasks from the command line and try to pass old_var_name with "-e “old_var_name=command_line_text” I expect the result to be:
ok: [ab-linuxbpc-2.sit] => {
“msg”: “command_line_text”
}
but instead I get
ok: [ab-linuxbpc-2.sit] => {
“msg”: “some_text”
}
If I pass "-e “new_var_name=command_line_text” I do get the desired result.
In addition If I move the declaration of old_var_name from group_vars/all/common.yml to the defaults of the role where foo.yml is definied I also get the desired result.
It seems the command line varialbe cannot overwrite just the group one.
Is this expected? Or I should file a bug?