Hi all.

I often write plays that require extra vars.  eg "ansible-playbook user -e 
user=bob"

In that play, I'll start off with 

- fail: msg="You forgot to set the user variable"
  when: user is not defined or user == ""

And I was thinking it might be nice to write an external, reusable play 
that would be called like this:

- include: check_defined.yaml checkvar=user

and look something like this

----
- hosts: all
  tasks:
  - fail: msg="{{ you forgot to specify a checkvar }}"
    when: checkvar is not defined or checkvar == ""
  - fail: msg="you forgot to set {{ checkvar }}"
    when: ?????? is not defined or ?????? == ""

The first fail is just to catch myself if I include check_defined.yaml 
without setting checkvar
the second fail is the thing I actually am curious about.  The ????? are 
the bits I don't know how to do.

Okay, I admit this is pretty silly, since I could write the is not defined 
checks for about 20 playbooks in the time it took to write this email.  And 
including the play is one line when the play itself ( or task) is 2.  But 
still, I think I'd understand ansible and jinja2 better if I knew the 
answer to this.  

Thanks
-Dylan

-- 
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/a1dd35e3-6ea3-4482-991f-e979456bdc28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to