summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.tito/packages/openshift-ansible2
-rwxr-xr-xinventory/multi_inventory.py75
-rw-r--r--openshift-ansible.spec10
3 files changed, 63 insertions, 24 deletions
diff --git a/.tito/packages/openshift-ansible b/.tito/packages/openshift-ansible
index ba0a6d69d..e6a0b6e80 100644
--- a/.tito/packages/openshift-ansible
+++ b/.tito/packages/openshift-ansible
@@ -1 +1 @@
-3.0.57-1 ./
+3.0.58-1 ./
diff --git a/inventory/multi_inventory.py b/inventory/multi_inventory.py
index 20fc48aa9..57be259f7 100755
--- a/inventory/multi_inventory.py
+++ b/inventory/multi_inventory.py
@@ -25,6 +25,9 @@ class MultiInventoryException(Exception):
'''Exceptions for MultiInventory class'''
pass
+# pylint: disable=too-many-public-methods
+# After a refactor of too-many-branches and placing those branches into
+# their own corresponding function, we have passed the allowed amount of functions(20).
class MultiInventory(object):
'''
MultiInventory class:
@@ -282,35 +285,63 @@ class MultiInventory(object):
else:
return data.get(keys, None)
- def apply_account_config(self, acc_config):
- ''' Apply account config settings
- '''
- results = self.all_inventory_results[acc_config['name']]
- results['all_hosts'] = results['_meta']['hostvars'].keys()
-
+ def apply_extra_vars(self, inventory, extra_vars):
+ ''' Apply the account config extra vars '''
# Extra vars go here
- for new_var, value in acc_config.get('extra_vars', {}).items():
- for data in results['_meta']['hostvars'].values():
+ for new_var, value in extra_vars.items():
+ for data in inventory.values():
self.add_entry(data, new_var, value)
+ def apply_clone_vars(self, inventory, clone_vars):
+ ''' Apply the account config clone vars '''
# Clone vars go here
- for to_name, from_name in acc_config.get('clone_vars', {}).items():
- for data in results['_meta']['hostvars'].values():
+ for to_name, from_name in clone_vars.items():
+ for data in inventory.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():
+ def apply_extra_groups(self, inventory, extra_groups):
+ ''' Apply the account config for extra groups '''
+ _ = self # Here for pylint. wanted an instance method instead of static
+ for new_var, value in extra_groups.items():
+ for _ in inventory['_meta']['hostvars'].values():
+ inventory["%s_%s" % (new_var, value)] = copy.copy(inventory['all_hosts'])
+
+ def apply_clone_groups(self, inventory, clone_groups):
+ ''' Apply the account config for clone groups '''
+ for to_name, from_name in clone_groups.items():
+ for name, data in inventory['_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)
+ if not inventory.has_key(key):
+ inventory[key] = []
+ inventory[key].append(name)
+
+ def apply_group_selectors(self, inventory, group_selectors):
+ ''' Apply the account config for clone groups '''
+ _ = self # Here for pylint. wanted an instance method instead of static
+ for selector in group_selectors:
+ if inventory.has_key(selector['from_group']):
+ inventory[selector['from_group']].sort()
+ inventory[selector['name']] = inventory[selector['from_group']][0:selector['count']]
+ for host in inventory[selector['from_group']]:
+ if host in inventory[selector['name']]:
+ inventory['_meta']['hostvars'][host][selector['name']] = True
+ else:
+ inventory['_meta']['hostvars'][host][selector['name']] = False
+
+ def apply_account_config(self, acc_config):
+ ''' Apply account config settings '''
+ results = self.all_inventory_results[acc_config['name']]
+ results['all_hosts'] = results['_meta']['hostvars'].keys()
+
+ self.apply_extra_vars(results['_meta']['hostvars'], acc_config.get('extra_vars', {}))
+
+ self.apply_clone_vars(results['_meta']['hostvars'], acc_config.get('clone_vars', {}))
+
+ self.apply_extra_groups(results, acc_config.get('extra_groups', {}))
+
+ self.apply_clone_groups(results, acc_config.get('clone_groups', {}))
+
+ self.apply_group_selectors(results, acc_config.get('group_selectors', {}))
# store the results back into all_inventory_results
self.all_inventory_results[acc_config['name']] = results
diff --git a/openshift-ansible.spec b/openshift-ansible.spec
index 358c346a1..bad7e68b2 100644
--- a/openshift-ansible.spec
+++ b/openshift-ansible.spec
@@ -5,7 +5,7 @@
}
Name: openshift-ansible
-Version: 3.0.57
+Version: 3.0.58
Release: 1%{?dist}
Summary: Openshift and Atomic Enterprise Ansible
License: ASL 2.0
@@ -279,6 +279,14 @@ Atomic OpenShift Utilities includes
%changelog
+* Tue Mar 15 2016 Kenny Woodson <kwoodson@redhat.com> 3.0.58-1
+- Group selector feature added (kwoodson@redhat.com)
+- nfs: replace yum with dnf (efreiber@redhat.com)
+- Move common common facts to openshift_facts (jdetiber@redhat.com)
+- perform oc client config tasks only once when ansible_ssh_user is root
+ (jdetiber@redhat.com)
+- OSE/Origin < 3.2/1.2 should not get Docker 1.9 (sdodson@redhat.com)
+
* Mon Mar 14 2016 Brenton Leanhardt <bleanhar@redhat.com> 3.0.57-1
- Docker stderr can break this script if ansible executes it remotely
(bleanhar@redhat.com)