Ok, so there are quite a few things you can use now to limit the hosts
you run to.
A)
hosts: $hosts
and ansible-playbook foo.yml --extra-vars="hosts=patternGoesHere"
This allows you to use a playbook and not code the name of the hosts in it.
B)
ansible-playbook.yml --limit somePatternMatchingASubSetOfHosts
Allows you to specify a group in the playbook with the "hosts:" line
and then run on only a subset of those groups/hosts.
C)
ansible-playbook.yml foo.yml -i "host1.example.com,host2.example.com2"
# note if you have only one host and want to do this, they must end in a comma
# note the inventory file variables and groups is ignored if you do this
I want a nicer syntax for this hack, and we'll have one, but this
works for now. I just want something that makes it clear it's not
selecting those hosts out of your inventory file.
(If you want that, use --limit)
D)
depending on complexity, you could write your own tool using the
Playbook API, looking at /usr/bin/ansible-playbook as a reference.
The API is generally stable.
Hope that helps!
--Michael