diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2015-11-20 16:17:47 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2015-11-20 16:29:59 -0500 |
commit | 41121519de65d79f8ef018d061afa0964c5de500 (patch) | |
tree | 7c23541b8195af718ffd1c258681c6f827e1c612 /inventory | |
parent | 191bfbaa614b1eeafe4785edd295e1e0b3498175 (diff) | |
download | openshift-41121519de65d79f8ef018d061afa0964c5de500.tar.gz openshift-41121519de65d79f8ef018d061afa0964c5de500.tar.bz2 openshift-41121519de65d79f8ef018d061afa0964c5de500.tar.xz openshift-41121519de65d79f8ef018d061afa0964c5de500.zip |
Fixing clone group functionality. Also separating extra_vars from extra_groups
Diffstat (limited to 'inventory')
-rwxr-xr-x | inventory/multi_inventory.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/inventory/multi_inventory.py b/inventory/multi_inventory.py index 354a8c10c..232f2402d 100755 --- a/inventory/multi_inventory.py +++ b/inventory/multi_inventory.py @@ -288,26 +288,30 @@ class MultiInventory(object): results = self.all_inventory_results[acc_config['name']] results['all_hosts'] = results['_meta']['hostvars'].keys() - # Update each hostvar with the newly desired key: value from extra_* - for _extra in ['extra_vars', 'extra_groups']: - for new_var, value in acc_config.get(_extra, {}).items(): - for data in results['_meta']['hostvars'].values(): - self.add_entry(data, new_var, value) - - # Add this group - if _extra == 'extra_groups': - results["%s_%s" % (new_var, value)] = copy.copy(results['all_hosts']) - - # Clone groups goes here - for to_name, from_name in acc_config.get('clone_groups', {}).items(): - if results.has_key(from_name): - results[to_name] = copy.copy(results[from_name]) + # Extra vars go here + for new_var, value in acc_config.get('extra_vars', {}).items(): + for data in results['_meta']['hostvars'].values(): + self.add_entry(data, new_var, value) - # Clone vars goes here + # Clone vars go here for to_name, from_name in acc_config.get('clone_vars', {}).items(): for data in results['_meta']['hostvars'].values(): self.add_entry(data, to_name, self.get_entry(data, from_name)) + # Extra groups go here + for new_var, value in acc_config.get('extra_groups', {}).items(): + for data in results['_meta']['hostvars'].values(): + results["%s_%s" % (new_var, value)] = copy.copy(results['all_hosts']) + + # Clone groups go here + # Build a group based on the desired key name + for to_name, from_name in acc_config.get('clone_groups', {}).items(): + for name, data in results['_meta']['hostvars'].items(): + key = '%s_%s' % (to_name, self.get_entry(data, from_name)) + if not results.has_key(key): + results[key] = [] + results[key].append(name) + # store the results back into all_inventory_results self.all_inventory_results[acc_config['name']] = results |