diff options
Diffstat (limited to 'inventory/multi_ec2.py')
-rwxr-xr-x | inventory/multi_ec2.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/inventory/multi_ec2.py b/inventory/multi_ec2.py index 23cf5ecf1..98dde3f3c 100755 --- a/inventory/multi_ec2.py +++ b/inventory/multi_ec2.py @@ -241,23 +241,24 @@ class MultiEc2(object): ''' results = self.all_ec2_results[acc_config['name']] - # Update each hostvar with the newly desired key: value - for new_var, value in acc_config.get('extra_vars', {}).items(): - # Verify the account results look sane - # by checking for these keys ('_meta' and 'hostvars' exist) - if results.has_key('_meta') and results['_meta'].has_key('hostvars'): - for data in results['_meta']['hostvars'].values(): - data[str(new_var)] = str(value) - - # Add this group - if results.has_key(acc_config['all_group']): - results["%s_%s" % (new_var, value)] = \ - copy.copy(results[acc_config['all_group']]) + # Update each hostvar with the newly desired key: value from extra_* + for _extra in ['extra_groups', 'extra_vars']: + for new_var, value in acc_config.get(_extra, {}).items(): + # Verify the account results look sane + # by checking for these keys ('_meta' and 'hostvars' exist) + if results.has_key('_meta') and results['_meta'].has_key('hostvars'): + for data in results['_meta']['hostvars'].values(): + data[str(new_var)] = str(value) + + # Add this group + if _extra == 'extra_groups' and results.has_key(acc_config['all_group']): + results["%s_%s" % (new_var, value)] = \ + copy.copy(results[acc_config['all_group']]) # Clone groups goes here - for name_from, name_to in acc_config.get('clone_groups', {}).items(): - if results.has_key(name_from): - results[name_to] = copy.copy(results[name_from]) + 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]) # Clone vars goes here for to_name, from_name in acc_config.get('clone_vars', {}).items(): |