Squashed commit of the following:
commit 48069adf0f47b09f675a9ba59360ca216b695ceb
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 10:13:08 2012 +0100
Removing this plugin from this branch.
commit 15400fffe643ad3e66d6b5a296fe62d36d9a617a
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 09:53:16 2012 +0100
Enhance _match function in inventory with regex.
--limit ~regex could be used to filter hosts or group with a regex.
Tested on cli and ansible-playbook.
commit 63c1b2e17ec6daa282e0a3af2249bda8f734dcd3
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 09:03:41 2012 +0100
Revert pull request #1684
commit 7c2c6fee3a856c52c1960b96ec2e7ca1112c35a1
Merge: f023a2f dd5a847
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Tue Nov 27 08:52:53 2012 +0100
Merge remote branch 'upstream/devel' into devel
commit f023a2f3df4a4c2ab2dfcc5aa42c57c02358a47a
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Mon Nov 26 20:52:27 2012 +0100
Add an inventory plugin to fetch groups and host from our CMDB.
commit c64193b4c67053e6e197b89c7143b9770cf71f23
Author: Gregory Duchatelet <skygreg@gmail.com>
Date: Mon Nov 26 20:43:30 2012 +0100
Added possibility to filter hosts from a group, with a regex, separating
groupname and regex with a ~
Usage in group pattern: group~filterpattern
Samples:
ansible group~server-0[1236] -m ping
ansible web~proxy -m ping
ansible web~(proxy|frontend) -m ping
pull/4420/head
parent
24dadb3c27
commit
dde01dabc3
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import ansible.constants as C
|
import ansible.constants as C
|
||||||
|
@ -92,6 +93,9 @@ class Inventory(object):
|
||||||
raise errors.AnsibleError("YAML inventory support is deprecated in 0.6 and removed in 0.7, see the migration script in examples/scripts in the git checkout")
|
raise errors.AnsibleError("YAML inventory support is deprecated in 0.6 and removed in 0.7, see the migration script in examples/scripts in the git checkout")
|
||||||
|
|
||||||
def _match(self, str, pattern_str):
|
def _match(self, str, pattern_str):
|
||||||
|
if pattern_str.startswith('~'):
|
||||||
|
return re.search(pattern_str[1:], str)
|
||||||
|
else:
|
||||||
return fnmatch.fnmatch(str, pattern_str)
|
return fnmatch.fnmatch(str, pattern_str)
|
||||||
|
|
||||||
def get_hosts(self, pattern="all"):
|
def get_hosts(self, pattern="all"):
|
||||||
|
@ -164,7 +168,7 @@ class Inventory(object):
|
||||||
a tuple of (start, stop) or None
|
a tuple of (start, stop) or None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not "[" in pattern:
|
if not "[" in pattern or pattern.startswith('~'):
|
||||||
return (pattern, None)
|
return (pattern, None)
|
||||||
(first, rest) = pattern.split("[")
|
(first, rest) = pattern.split("[")
|
||||||
rest = rest.replace("]","")
|
rest = rest.replace("]","")
|
||||||
|
|
Loading…
Reference in New Issue