From 8bc1b69c58eb7a9ad33ade9f4a803ad81948f674 Mon Sep 17 00:00:00 2001 From: Gregory Duchatelet Date: Sun, 2 Dec 2012 10:18:58 +0100 Subject: [PATCH] Add a unit test to subset limiting via a regex, and some doc in man page. --- docs/man/man1/ansible.1 | 5 +++++ test/TestInventory.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/man/man1/ansible.1 b/docs/man/man1/ansible.1 index e12f8730b8a..9438af7abe0 100644 --- a/docs/man/man1/ansible.1 +++ b/docs/man/man1/ansible.1 @@ -156,6 +156,11 @@ is mostly useful for crontab or kickstarts\&. .RS 4 Further limits the selected host/group patterns\&. .RE +.PP +\fB\-l\fR \fI~REGEX\fR, \fB\-\-limit=\fR\fI~REGEX\fR +.RS 4 +Further limits hosts with a regex pattern\&. +.RE .SH "INVENTORY" .sp Ansible stores the hosts it can potentially operate on in an inventory file\&. The syntax is one host per line\&. Groups headers are allowed and are included on their own line, enclosed in square brackets that start the line\&. diff --git a/test/TestInventory.py b/test/TestInventory.py index 5c444d9e966..6d0a086eed8 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -158,6 +158,14 @@ class TestInventory(unittest.TestCase): print "EXPECTED=%s" % sorted(expected_hosts) assert sorted(hosts) == sorted(expected_hosts) + def test_regex_exclude(self): + inventory = self.complex_inventory() + hosts = inventory.list_hosts("~rtp_[ac]") + expected_hosts = ['rtp_a', 'rtp_c'] + print "HOSTS=%s" % sorted(hosts) + print "EXPECTED=%s" % sorted(expected_hosts) + assert sorted(hosts) == sorted(expected_hosts) + def test_complex_enumeration(self):