Programmatically checking if a particular host is still a target.

28 views
Skip to first unread message

ja...@ioctl.org

unread,
Jul 30, 2015, 11:20:10 AM7/30/15
to ansible...@googlegroups.com
So I've a situation where I want to delegate_to a host. That host is one
(arbitrarily chosen) of a group.

Rather than

delegate_to: "{{ GROUP[0] }}"

I'd like to confirm that the host is actually up, first - or rather, pick
an arbitrary member of GROUP that's successfully had facts gathered
against it (and no previous play fail on it).

Is that kind of status derivable from any of the information that ansible
currently exposes as a variable to the J2 engine? (Or any other way: if I
need to write a custom filter for this job I have no objection to doing
so.)


Cheers,
jan

--
ja...@ioctl.org http://ioctl.org/jan/ Short, dark, ugly: pick any three
Goedel would be proud - I'm both inconsistent _and_ incomplete.

KSS

unread,
Jul 30, 2015, 11:54:36 AM7/30/15
to Ansible Project, ja...@ioctl.org
I think this may help;

{{ play_hosts[0] }}

That should pick the first host in the current play (so no previous failures)

ja...@ioctl.org

unread,
Aug 4, 2015, 12:25:45 PM8/4/15
to KSS, Ansible Project
Hrm, it would, but the group that's being targeted by the top-level
playbook is not the same as the group that contains candidate hosts that
I'd like to delegate to - unless I misunderstand what play_hosts is doing.





On Thu, 30 Jul 2015, KSS wrote:

> I think this may help;
>
> {{ play_hosts[0] }}
>
> That should pick the first host in the current play (so no previous
> failures)
>
> On Thursday, 30 July 2015 16:20:10 UTC+1, Jan Grant wrote:
> >
> > So I've a situation where I want to delegate_to a host. That host is one
> > (arbitrarily chosen) of a group.
> >
> > Rather than
> >
> > delegate_to: "{{ GROUP[0] }}"
> >
> > I'd like to confirm that the host is actually up, first - or rather, pick
> > an arbitrary member of GROUP that's successfully had facts gathered
> > against it (and no previous play fail on it).
> >
> > Is that kind of status derivable from any of the information that ansible
> > currently exposes as a variable to the J2 engine? (Or any other way: if I
> > need to write a custom filter for this job I have no objection to doing
> > so.)
> >
> >
> > Cheers,
> > jan
> >
> > --
> > ja...@ioctl.org <javascript:> http://ioctl.org/jan/ Short, dark, ugly:
> > pick any three
> > Goedel would be proud - I'm both inconsistent _and_ incomplete.
> >
>

--
ja...@ioctl.org http://ioctl.org/jan/ Short, dark, ugly: pick any three
Whenever I see a dog salivate I get an insatiable urge to ring a bell.
Reply all
Reply to author
Forward
0 new messages