add the limit option, which can be used to further confine the patterns selected by "hosts:" in ansible-playbooks

to an additional pattern (a subset) specified on the command line.  For instance, a playbook could be reusable
and target "webservers" and "dbservers", but you want to test only in the stage environment, or a few boxes at a time.
This commit is contained in:
Michael DeHaan 2012-08-10 02:45:29 -04:00
commit 1c81ddf8d4
6 changed files with 38 additions and 8 deletions

View file

@ -57,7 +57,8 @@ class PlayBook(object):
sudo = False,
sudo_user = C.DEFAULT_SUDO_USER,
extra_vars = None,
only_tags = None):
only_tags = None,
subset = C.DEFAULT_SUBSET):
"""
playbook: path to a playbook file
@ -104,7 +105,8 @@ class PlayBook(object):
self.private_key_file = private_key_file
self.only_tags = only_tags
self.inventory = ansible.inventory.Inventory(host_list)
self.inventory = ansible.inventory.Inventory(host_list)
self.inventory.subset(subset)
if not self.inventory._is_script:
self.global_vars.update(self.inventory.get_group_variables('all'))