Is this the correct behavior of using --limit:
{
$ cat test_inv
[localhost]
localhost
[foobar]
localhost
$ cat test.yml
Is this the correct behavior of using --limit:
{
$ cat test_inv
[localhost]
localhost
[foobar]
localhost
$ cat test.yml
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.