diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2015-11-20 16:30:55 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2015-11-20 16:30:55 -0500 |
commit | 318ed58dc07e592e0f8cff9c14848e63a559f2b5 (patch) | |
tree | ab483084ed7a7acbbea9a632fef44456fae1f2a5 | |
parent | f0d13819c35727300101a7e31b8ff9b0022e683f (diff) | |
parent | 41121519de65d79f8ef018d061afa0964c5de500 (diff) | |
download | openshift-318ed58dc07e592e0f8cff9c14848e63a559f2b5.tar.gz openshift-318ed58dc07e592e0f8cff9c14848e63a559f2b5.tar.bz2 openshift-318ed58dc07e592e0f8cff9c14848e63a559f2b5.tar.xz openshift-318ed58dc07e592e0f8cff9c14848e63a559f2b5.zip |
Merge pull request #950 from kwoodson/clonegroupfix
Fixing clone groups in multi_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 |