Prevent misspelled variables passed to Ansible roles I'm looking for strategies to mitigate silent errors related to misspelled or otherwise mistyped variables being passed to Ansible roles.

So for example, I have a role with a defaults/main.yml:

foo_version: "1.0"


Within the tasks/main.yml:

- get_url:
    url: "https://foo.com/foo-{{ foo_version }}.tar.gz"
    dest: /tmp/


Now in my main playbook, if I do this, it will install the default version, 1.0:

- include_role: name=foo


If I do this, it will install version 2.0:

- include_role: name=foo
  vars:
    foo_version: "2.0"


So far so good. But if I do this by accident, it will install 1.0 without my realizing it:

- include_role: name=foo
  vars:
    fooo_version: "2.0"


The only "solution" I've thought of is to remove the defaults/main.yml, in which case it would fail in the last case because foo_version would remain undefined. But then I can't take advantage of the benefits of having defaults.

Are there other solutions? Thanks!
Q: " Prevent misspelled variables passed to Ansible roles ... remove the defaults/main.yml, ... But then I can't take advantage of the benefits of having defaults. Are there other solutions?


A: Yes. Tell include_role to read other file defaults_from. Fit the content of this file to your needs. For example

- include_role:
    name: foo
    defaults_from: main_special.yml
  vars:
    fooo_version: "2.0"