diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-09-30 08:47:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-30 08:47:22 -0400 |
commit | 4f4d3daede9b3c57d4d8142e2479fb86f6936f3f (patch) | |
tree | 16b4b08f67de22a5be128628c0a73043b12aa49b /utils/src | |
parent | 04fb927328ebe363abf402dfcf4cea09d9304e56 (diff) | |
parent | 92a9e5547af1c77751fe04ef9f3b849d0885ed03 (diff) | |
download | openshift-4f4d3daede9b3c57d4d8142e2479fb86f6936f3f.tar.gz openshift-4f4d3daede9b3c57d4d8142e2479fb86f6936f3f.tar.bz2 openshift-4f4d3daede9b3c57d4d8142e2479fb86f6936f3f.tar.xz openshift-4f4d3daede9b3c57d4d8142e2479fb86f6936f3f.zip |
Merge pull request #2426 from smunilla/BZ1368414
a-o-i: Allow better setting of host level variables
Diffstat (limited to 'utils/src')
-rw-r--r-- | utils/src/ooinstall/oo_config.py | 26 | ||||
-rw-r--r-- | utils/src/ooinstall/openshift_ansible.py | 27 |
2 files changed, 35 insertions, 18 deletions
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index 8c5f3396b..697ac9c08 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -26,6 +26,19 @@ DEPLOYMENT_VARIABLES_BLACKLIST = [ 'roles', ] +HOST_VARIABLES_BLACKLIST = [ + 'ip', + 'public_ip', + 'hostname', + 'public_hostname', + 'node_labels', + 'containerized', + 'preconfigured', + 'schedulable', + 'other_variables', + 'roles', +] + DEFAULT_REQUIRED_FACTS = ['ip', 'public_ip', 'hostname', 'public_hostname'] PRECONFIGURED_REQUIRED_FACTS = ['hostname', 'public_hostname'] @@ -66,7 +79,7 @@ class Host(object): self.containerized = kwargs.get('containerized', False) self.node_labels = kwargs.get('node_labels', '') - # allowable roles: master, node, etcd, storage, master_lb, new + # allowable roles: master, node, etcd, storage, master_lb self.roles = kwargs.get('roles', []) self.other_variables = kwargs.get('other_variables', {}) @@ -86,11 +99,13 @@ class Host(object): d = {} for prop in ['ip', 'hostname', 'public_ip', 'public_hostname', 'connect_to', - 'preconfigured', 'containerized', 'schedulable', 'roles', 'node_labels', - 'other_variables']: + 'preconfigured', 'containerized', 'schedulable', 'roles', 'node_labels', ]: # If the property is defined (not None or False), export it: if getattr(self, prop): d[prop] = getattr(self, prop) + for variable, value in self.other_variables.iteritems(): + d[variable] = value + return d def is_master(self): @@ -202,7 +217,6 @@ class OOConfig(object): role_list = loaded_config['deployment']['roles'] except KeyError as e: print_read_config_error("No such key: {}".format(e), self.config_path) - print "Error loading config, required key missing: {}".format(e) sys.exit(0) for setting in CONFIG_PERSIST_SETTINGS: @@ -237,6 +251,10 @@ class OOConfig(object): # Parse the hosts into DTO objects: for host in host_list: + host['other_variables'] = {} + for variable, value in host.iteritems(): + if variable not in HOST_VARIABLES_BLACKLIST: + host['other_variables'][variable] = value self.deployment.hosts.append(Host(**host)) # Parse the roles into Objects diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index eb1e61a60..bd0d96d09 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -31,6 +31,15 @@ VARIABLES_MAP = { 'proxy_exclude_hosts': 'openshift_no_proxy', } +HOST_VARIABLES_MAP = { + 'ip': 'openshift_ip', + 'public_ip': 'openshift_public_ip', + 'hostname': 'openshift_hostname', + 'public_hostname': 'openshift_public_hostname', + 'node_labels': 'openshift_node_labels', + 'containerized': 'containerized', +} + def set_config(cfg): global CFG @@ -176,7 +185,6 @@ def write_proxy_settings(base_inventory): pass -# pylint: disable=too-many-branches def write_host(host, role, inventory, schedulable=None): global CFG @@ -184,22 +192,13 @@ def write_host(host, role, inventory, schedulable=None): return facts = '' - if host.ip: - facts += ' openshift_ip={}'.format(host.ip) - if host.public_ip: - facts += ' openshift_public_ip={}'.format(host.public_ip) - if host.hostname: - facts += ' openshift_hostname={}'.format(host.hostname) - if host.public_hostname: - facts += ' openshift_public_hostname={}'.format(host.public_hostname) - if host.containerized: - facts += ' containerized={}'.format(host.containerized) + for prop in HOST_VARIABLES_MAP: + if getattr(host, prop): + facts += ' {}={}'.format(HOST_VARIABLES_MAP.get(prop), getattr(host, prop)) + if host.other_variables: for variable, value in host.other_variables.iteritems(): facts += " {}={}".format(variable, value) - if host.node_labels: - if role == 'node': - facts += ' openshift_node_labels="{}"'.format(host.node_labels) # Distinguish between three states, no schedulability specified (use default), # explicitly set to True, or explicitly set to False: |