The short answer is:  maybe, but it's probably more important that it's
considered a feature.

Often in configuring sets of machines, needing to run things locally is
required to do some steps once and then apply them to a batch.

Thus, almost never do you treat the control machine as "one of the regular
nodes".  For instance, if configuring webservers, you do not run ansible
*from* one of the webservers, so the behavior of the localhost in that play
should be innocous relative to the hosts being configured.

I think removing this would break some rather fundamental use cases with
--limit.

I do understand it's common to run configuration against localhost in
development or for testing, and in this case I'd recommend splitting
inventories.




On Thu, Sep 11, 2014 at 12:01 AM, Matt Schurenko <[email protected]> wrote:

> Is this the correct behavior of using --limit:
>
> {
> $ cat test_inv
> [localhost]
> localhost
>
> [foobar]
> localhost
>
> $ cat test.yml
> ---
> - hosts:
>     - localhost
>   connection: local
>   gather_facts: no
>   tasks:
>     - name: localhost
>       debug: msg=localhost
>
> - hosts:
>     - foobar
>   connection: local
>   gather_facts: no
>   tasks:
>     - name: foobar
>       debug: msg=foobar
>
> $ ansible-playbook -i test_inv test.yml --list-hosts --limit foobar
>
> playbook: test.yml
>
>   play #1 (localhost): host count=1
>     localhost
>
>   play #2 (foobar): host count=1
>     localhost
> }
>
> I thought that by using "--limit foobar" that it would only match the
> foobar host group? Even if "--limit" can only work on one host section in a
> play isn't this still a bug or something?
>
> BTW my ansible version is 1.8
>
> Thanks
>
> --
> 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/580ecdd7-4145-4b4b-a979-085a4527a29e%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/580ecdd7-4145-4b4b-a979-085a4527a29e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgy7rrUM%3DGCrTTA9xiYOXjBdsTS59zdxBux3J-96xjL-_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to