From 6659d1e4fa14f5100458608337468e513374a385 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Mon, 23 Nov 2015 11:56:27 -0500 Subject: Handling preconfigured load balancers The preconfigured load balancers, previously denoted by having 'run_on' set to false, cannot have their facts gathered which results in a stack trace. Later when we write out the inventory we have to fake out the hostname and just use 'connect_to'. We're likely going to have the concept of other types of "plug-in" hosts where we don't run ansible. We should make sure we abstract this properly so it's easy to add additional types of hosts. Also in the commit: - Renamed 'run_on' to 'preconfigured' and inverted the logic as needed - Output tally of Masters and Nodes as well as remaining Masters required for HA - Minor rewording in a few places - Currently only prompting for the load balancer after all other hosts have been entered - Removed spurious echo --- utils/src/ooinstall/openshift_ansible.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'utils/src/ooinstall/openshift_ansible.py') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 86c707b17..ed1ba2c77 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -19,7 +19,7 @@ def generate_inventory(hosts): global CFG masters = [host for host in hosts if host.master] nodes = [host for host in hosts if host.node] - proxy = next((host for host in hosts if host.master_lb), None) + proxy = determine_proxy_configuration(hosts) multiple_masters = len(masters) > 1 base_inventory_path = CFG.settings['ansible_inventory_path'] @@ -66,13 +66,24 @@ def generate_inventory(hosts): scheduleable = False write_host(node, base_inventory, scheduleable) - if getattr(proxy, 'run_on', False): + if not getattr(proxy, 'preconfigured', True): base_inventory.write('\n[lb]\n') write_host(proxy, base_inventory) base_inventory.close() return base_inventory_path +def determine_proxy_configuration(hosts): + proxy = next((host for host in hosts if host.master_lb), None) + if proxy: + if proxy.hostname == None: + proxy.hostname = proxy.connect_to + proxy.public_hostname = proxy.connect_to + print('asd09o') + return proxy + + return None + def write_inventory_children(base_inventory, multiple_masters, proxy): global CFG @@ -81,7 +92,7 @@ def write_inventory_children(base_inventory, multiple_masters, proxy): base_inventory.write('nodes\n') if multiple_masters: base_inventory.write('etcd\n') - if getattr(proxy, 'run_on', False): + if not getattr(proxy, 'preconfigured', True): base_inventory.write('lb\n') def write_inventory_vars(base_inventory, multiple_masters, proxy): -- cgit v1.2.3