"I want to throw a warning or error if the variable is not set to one of
the two,"
- debug: msg="Hey, this might sound crazy, but this variable is not set to
duck or goose"
when: "var_name != 'duck and variable != 'goose'"
"or even optionally just use the ansible_ssh_host or
ansible_inventory_hostname if there is no match. "
{{ var_name | default(ansible_ssh_host) }}
only_if has been a deprecated feature for ages, and when absolutely does
everything you want.
On Wed, Nov 20, 2013 at 2:08 PM, Ryan Mitchell <[email protected]>wrote:
> Sorry if this has been answered somewhere but I couldn't find anything
> that really addressed this, or I'm really dense about how best to solve
> this problem.
>
> I have a variable that should be either a fully-qualified domain name or
> an IP address. I want to throw a warning or error if the variable is not
> set to one of the two, or even optionally just use the ansible_ssh_host or
> ansible_inventory_hostname if there is no match. I'm not sure how to
> actually do the conditional check, though. The "when:" conditional
> statement doesn't seem to give me the options I want natively, so should I
> be dropping into only_if and jinja2/python syntax instead? Any other
> suggestions?
>
> --
> 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].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
Michael DeHaan <[email protected]>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/
--
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].
For more options, visit https://groups.google.com/groups/opt_out.