Implement vmware plugin host filtering

This commit is contained in:
AlanCoding 2020-04-17 14:52:38 -04:00
parent 84d863ff9d
commit e2f5aa987d
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B
4 changed files with 11 additions and 4 deletions

View File

@ -2320,8 +2320,12 @@ class vmware(PluginFileInjector):
host_filters = vmware_opts.get('host_filters')
if host_filters:
pass
# ret['resources'] = host_filters.split(',') # does not follow same pattern
ret.setdefault('host_filters', [])
for hf in host_filters.split(','):
striped_hf = hf.replace('{', '').replace('}', '').strip() # make best effort
if not striped_hf:
continue
ret['host_filters'].append(striped_hf)
groupby_patterns = vmware_opts.get('groupby_patterns')
if groupby_patterns:

View File

@ -1,3 +1,6 @@
host_filters:
- config.name == "only_my_server"
- somevar == "bar"
keyed_groups:
- key: fouo
prefix: ''

View File

@ -5,6 +5,6 @@ username = fooo
password = fooo
server = https://foo.invalid
base_source_var = value_of_var
host_filters = foobaa
host_filters = {{ config.name == "only_my_server" }},{{ somevar == "bar"}}
groupby_patterns = fouo

View File

@ -16,7 +16,7 @@ DATA = os.path.join(os.path.dirname(data.__file__), 'inventory')
TEST_SOURCE_FIELDS = {
'vmware': {
'instance_filters': 'foobaa',
'instance_filters': '{{ config.name == "only_my_server" }},{{ somevar == "bar"}}',
'group_by': 'fouo'
},
'ec2': {