ansible 2.4 reports an error when extra var is passed

Hi

ansible playbook reports an error when one of the value of the yaml config file imported as var is passed on the command line using -e

Yaml Config File

`

ansible playbook reports an error when one of the value of the yaml config
file imported as var is passed on the command line using -e

Yaml Config File

#
# Istio
#
istio:
  github_url: https://api.github.com/repos
  repo: istio/istio

  # Could be a tag "0.2.12" version or be empty "", then in this case, the
latest release will be downloaded
  release_tag_name: "0.2.12"
  
  # Folder where you want to install the distro on your machine. By
default, we will install it here ~/.istio
  dest: "$HOME/.istio"

Command

ansible-playbook ansible/main.yml --extra-vars "{'istio':
{'release_tag_name': 0.3.0}}" -t install-istio -v

Result

TASK [Define var containing Istio dir]
*************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The task includes
an option with an undefined variable. The error was: 'dict object' has no
attribute 'dest'\n\nThe error appears to have been in
'/Users/dabou/Code/istio/installation/ansible/istio/set_istio_distro_dir.yml':
line 7, column 3, but may\nbe elsewhere in the file depending on the exact
syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Define
var containing Istio dir\n ^ here\n\nexception type: <class
'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no
attribute 'dest'"}

So, for a reason that I don't know, ansible is not able to find the
istio.dest variable

Because you overwritten the variable on the command line.

The playbook doesn't report error when no '-e' var is passed to the
command !!!!!

I guess it has default dict that include dest.

What could be the issue ?

When you overwrite a dict you need to provide everything since it's not possible to just change part of it.

Which strategy do you propose then to be able to override a key=value defined within a yaml ?

Instead of using dict, flatten it and use key value.

istio:
   dest: something
   release_tab_name: 0.2.12

Becomes
istio_dest: something
istro_release_tab_name: 0.2.12

Then you can easily override the individual variables.