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


On Monday, September 14, 2015 at 8:20:07 AM UTC-4, Andrew Wade wrote:
>
> 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 received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8cdcbd66-9902-41cf-a8d6-512c841412c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to