ansible-playbook --limit limitations?

509 views
Skip to first unread message

Dick Davies

unread,
May 16, 2014, 11:13:18 AM5/16/14
to ansible list
Hi,

I've got a fairly complex playbook which uses Ansibles
orchestration features
(i.e. "for n in groups['some group'] ....") and a big enough stack
that I'd like to pass '--limit' to my plays as we build out configs etc.

An example: several servers lookup members of the 'zookeepers'
group to generate their config files
(this is just one example; different hosts have different dependencies).

So if i try

ansible-playbook -i inventory site.yml --limit nonzkhost

the run fails with:

fatal: [nonzkhost1] => {'msg': "One or more undefined variables: 'dict
object' has no attribute 'ansible_eth1'", 'failed': True}

To use the '--limit' flag, I have to remember to also list all
zookeepers in a play.
Similar issues happen with Ansibles 'retry' feature.

I think my issue is that I need actual facts gathered from those hosts
rather than just their names (which are accessible in the inventory of course).

Is there a flag I can pass to get a full 'GATHER FACTS' pass before
only running a play against selected nodes, or am I just Doing It Wrong here?

Michael DeHaan

unread,
May 16, 2014, 7:19:59 PM5/16/14
to ansible...@googlegroups.com
If you use limit it won't gather facts from machines not in the limit group.

(There have been a few threads about this)




--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK5eLPTkZk-o0egFBu9kgZDKHrbOW1W5JvxFA_fDj2rBa0RGkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Dick Davies

unread,
May 17, 2014, 7:32:11 AM5/17/14
to ansible list
Thanks Michael

Yeah so it seems - is that by design?

This can actually be dangerous (if for example all zookeepers aren't
explicitly specified, configurations will drop some from the client configs
and bounce services, potentially leading to cluster splits),
would be good if there was some workaround.

Is there any way to make orchestration and limit play nicely together,
or do you feel they're mutually exclusive?
> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzp-CQUqp%3DoXHcRZPvxBq4XmwTteTQRoBehzAmKumjfcA%40mail.gmail.com.

Brian Coca

unread,
May 17, 2014, 11:27:49 AM5/17/14
to ansible...@googlegroups.com
there are other ways to do this, but not with --limit



- hosts: all
  name: this just gathers facts

- hosts: "some_group{{limit|default('')}}"


then from command line you can do  -e 'limit=:!other_group'

--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

Michael DeHaan

unread,
May 18, 2014, 10:55:00 PM5/18/14
to ansible...@googlegroups.com
This.


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Michael Peters

unread,
May 19, 2014, 9:39:47 AM5/19/14
to ansible...@googlegroups.com
I know I'm new here, but this has bitten me several times already. It
seems that fact gathering of other hosts not in the play loop is such
a common thing that there should be a more explicit way to do this
besides just the side effect of a play with no tasks. Because you have
to set things up to always have to pass an extra variable on the
command line which increases the amount you need to memorize just to
execute every play. And then if things change such that you need to
include other groups in the task gathering that are not included in
the execution you have to retrain everyone for every invocation that
isn't global.

I appreciate that there is a work around for the general case, but
fact gathering of other hosts seems like such a common thing that
there should be a way to do it not as a side effect that needs
invocation hurdles.

Just my 2¢
> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgywXVWhW11SzYeJp%3Dgh3yTWkXzSTf0Z%3Dk%2BrRL3t3ox-Rg%40mail.gmail.com.

Michael DeHaan

unread,
May 21, 2014, 5:47:40 PM5/21/14
to ansible...@googlegroups.com
It's a popular request.

We're aware of it - but also chasing about 500 other things people want and have to balance these things :)

Stay tuned!



Reply all
Reply to author
Forward
0 new messages