It should be enough to just check:

when: ansible_ssh_host

However it may be good to come at it from a little different direction and
use something like:

set_fact:
    uberHost: "{{ ansible_ssh_host|default(inventory_hostname, True) }}"

The True in default() will tell jinja2 to use pythons truthyness checks, so
an empty string evaluates as false as well.


On Tuesday, January 19, 2016, Michael Baydoun <[email protected]>
wrote:

> pre 2.0
>
> set_fact:
>   uberHost: "{{ ansible_ssh_host }}"
> when: ansible_ssh_host is defined
>
> set fact:
>   uberHost: "{{ inventory_hostname }}"
> when: ansible_ssh_host is not defined
>
>
> Post 2.0, changed to use ansible_host
> uberHost is always getting set to null
> ansible_host is defined and set to null even when it's not present in the
> inventory file
> I haven't figured out how to test to see if ansible_host is null in a when
> clause.
>
>
> --
> 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]
> <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ce3c97d5-f321-4ab6-868f-e83a11aa863f%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ce3c97d5-f321-4ab6-868f-e83a11aa863f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v8bGu5GQSjKHJfKpXeir8vBnxoR0jhH6f6%2Bgkp3qAOOYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to