Required variables in var in inline vars

Hey,

(I’m using Ansible 1.9.2)

I’ve got a playbook like this:

`

  • hosts:
    vars:
    var_required_by_role:
  • name: “{{ variable }}”
    user: “foo”
    roles:
  • myrole

`

My issue is that no error is raised if ‘variable’ is undefined; Ansible outputs a changed line like:

=> … ‘name’: u’{# variable #}’

I’m constructing a more complex variable form a simple value passed in with -e and I don’t want to define the complex variable on the command line.

Is there a better way to do this, or to force error checking? I tried the mandatory filter, but I don’t think it gets parsed.

Thanks.

You make an variable mandatory to throw an error if a var is not defined:

`

  • hosts:
    vars:
    var_required_by_role:
  • name: “{{ variable | mandatory }}”
    user: “foo”
    roles:
  • myrole
    `

Alternatively you can edit ansible.cfg to change this setting to True

`
error_on_undefined_vars = False

`