summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts/library
diff options
context:
space:
mode:
authorJason DeTiberus <jdetiber@redhat.com>2015-11-20 15:45:39 -0500
committerScott Dodson <sdodson@redhat.com>2015-12-15 15:45:45 -0500
commit043d6b3a7e3c6b799ddf4157ccdf2b2b67451d81 (patch)
tree7fdcdd862d1d959702054a40b8990bfaf8e4be34 /roles/openshift_facts/library
parent8e7c5c970b8adc83fd6d5cad115f4edb06b36d98 (diff)
downloadopenshift-043d6b3a7e3c6b799ddf4157ccdf2b2b67451d81.tar.gz
openshift-043d6b3a7e3c6b799ddf4157ccdf2b2b67451d81.tar.bz2
openshift-043d6b3a7e3c6b799ddf4157ccdf2b2b67451d81.tar.xz
openshift-043d6b3a7e3c6b799ddf4157ccdf2b2b67451d81.zip
fixes
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py126
1 files changed, 70 insertions, 56 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 8e733a3a2..b5454dd81 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -647,14 +647,14 @@ def set_deployment_facts_if_unset(facts):
for cat in ['additional', 'blocked', 'insecure']:
key = 'docker_{0}_registries'.format(cat)
if key in facts['common']:
- facts['common'][key] = set(facts['common'][key]) - set([''])
+ facts['common'][key] = list(set(facts['common'][key]) - set(['']))
if deployment_type in ['enterprise', 'atomic-enterprise', 'openshift-enterprise']:
- addtl_regs = facts['common']['docker_additional_registries']:
- ent_reg = 'registry.access.redhat.com'
- if ent_reg not in addtl_regs
- facts['common']['docker_additional_registries'].append(ent_reg)
+ addtl_regs = facts['common'].get('docker_additional_registries', [])
+ ent_reg = ['registry.access.redhat.com']
+ if ent_reg not in addtl_regs:
+ facts['common']['docker_additional_registries'] = addtl_regs + ent_reg
for role in ('master', 'node'):
@@ -934,6 +934,7 @@ def save_local_facts(filename, facts):
os.makedirs(fact_dir)
with open(filename, 'w') as fact_file:
fact_file.write(module.jsonify(facts))
+ os.chmod(filename, 0o600)
except (IOError, OSError) as ex:
raise OpenShiftFactsFileWriteError(
"Could not create fact file: %s, error: %s" % (filename, ex)
@@ -969,6 +970,69 @@ def get_local_facts_from_file(filename):
return local_facts
+def set_container_facts_if_unset(facts):
+ """ Set containerized facts.
+
+ Args:
+ facts (dict): existing facts
+ Returns:
+ dict: the facts dict updated with the generated containerization
+ facts
+ """
+ deployment_type = facts['common']['deployment_type']
+ if deployment_type in ['enterprise', 'openshift-enterprise']:
+ master_image = 'openshift3/ose'
+ cli_image = master_image
+ node_image = 'openshift3/node'
+ ovs_image = 'openshift3/openvswitch'
+ etcd_image = 'registry.access.redhat.com/rhel7/etcd'
+ elif deployment_type == 'atomic-enterprise':
+ master_image = 'aep3_beta/aep'
+ cli_image = master_image
+ node_image = 'aep3_beta/node'
+ ovs_image = 'aep3_beta/openvswitch'
+ etcd_image = 'registry.access.redhat.com/rhel7/etcd'
+ else:
+ master_image = 'openshift/origin'
+ cli_image = master_image
+ node_image = 'openshift/node'
+ ovs_image = 'openshift/openvswitch'
+ etcd_image = 'registry.access.redhat.com/rhel7/etcd'
+
+ facts['common']['is_atomic'] = os.path.isfile('/run/ostree-booted')
+ if 'is_containerized' not in facts['common']:
+ facts['common']['is_containerized'] = facts['common']['is_atomic']
+ if 'cli_image' not in facts['common']:
+ facts['common']['cli_image'] = cli_image
+ if 'etcd' in facts and 'etcd_image' not in facts['etcd']:
+ facts['etcd']['etcd_image'] = etcd_image
+ if 'master' in facts and 'master_image' not in facts['master']:
+ facts['master']['master_image'] = master_image
+ if 'node' in facts:
+ if 'node_image' not in facts['node']:
+ facts['node']['node_image'] = node_image
+ if 'ovs_image' not in facts['node']:
+ facts['node']['ovs_image'] = ovs_image
+
+ # shared /tmp/openshift vol is for file exchange with ansible
+ # --privileged is required to read the config dir
+ # --net host to access openshift from the container
+ # maybe -v /var/run/docker.sock:/var/run/docker.sock is required as well
+ runner = ("docker run --rm --privileged --net host -v "
+ "/tmp/openshift:/tmp/openshift -v {datadir}:{datadir} "
+ "-v {confdir}:{confdir} "
+ "-e KUBECONFIG={confdir}/master/admin.kubeconfig "
+ "{image}").format(confdir=facts['common']['config_base'],
+ datadir=facts['common']['data_dir'],
+ image=facts['common']['cli_image'])
+
+ if facts['common']['is_containerized']:
+ facts['common']['client_binary'] = '%s cli' % runner
+ facts['common']['admin_binary'] = '%s admin' % runner
+
+ return facts
+
+
class OpenShiftFactsUnsupportedRoleError(Exception):
"""Origin Facts Unsupported Role Error"""
pass
@@ -1046,7 +1110,7 @@ class OpenShiftFacts(object):
facts = set_version_facts_if_unset(facts)
facts = set_aggregate_facts(facts)
facts = set_etcd_facts_if_unset(facts)
- facts = self.set_containerized_facts_if_unset(facts)
+ facts = set_container_facts_if_unset(facts)
return dict(openshift=facts)
def get_defaults(self, roles):
@@ -1213,56 +1277,6 @@ class OpenShiftFacts(object):
self.changed = changed
return new_local_facts
- def set_containerized_facts_if_unset(self, facts):
- deployment_type = facts['common']['deployment_type']
- if deployment_type in ['enterprise','openshift-enterprise']:
- master_image = 'openshift3/ose'
- cli_image = master_image
- node_image = 'openshift3/node'
- ovs_image = 'openshift3/openvswitch'
- etcd_image = 'registry.access.redhat.com/rhel7/etcd'
- elif deployment_type == 'atomic-enterprise':
- master_image = 'aep3_beta/aep'
- cli_image = master_image
- node_image = 'aep3_beta/node'
- ovs_image = 'aep3_beta/openvswitch'
- etcd_image = 'registry.access.redhat.com/rhel7/etcd'
- else:
- master_image = 'openshift/origin'
- cli_image = master_image
- node_image = 'openshift/node'
- ovs_image = 'openshift/openvswitch'
- etcd_image = 'registry.access.redhat.com/rhel7/etcd'
-
- facts['common']['is_atomic'] = os.path.isfile('/run/ostree-booted')
- if 'is_containerized' not in facts['common']:
- facts['common']['is_containerized'] = facts['common']['is_atomic']
- if 'cli_image' not in facts['common']:
- facts['common']['cli_image'] = cli_image
- if 'master' in facts:
- if 'master_image' not in facts['master']:
- facts['master']['master_image'] = master_image
- if 'node' in facts:
- if 'node_image' not in facts ['node']:
- facts['node']['node_image'] = node_image
- if 'ovs_image' not in facts ['node']:
- facts['node']['ovs_image'] = ovs_image
- if 'etcd' in facts:
- if 'etcd_image' not in facts['etcd']:
- facts['etcd']['etcd_image'] = etcd_image
-
- # shared /tmp/openshift vol is for file exchange with ansible
- # --privileged is required to read the config dir
- # --net host to access openshift from the container
- # maybe -v /var/run/docker.sock:/var/run/docker.sock is required as well
- runner = "docker run --rm --privileged --net host -v /tmp/openshift:/tmp/openshift -v {datadir}:{datadir} -v {confdir}:{confdir} -e KUBECONFIG={confdir}/master/admin.kubeconfig {image}".format(confdir=facts['common']['config_base'], datadir=facts['common']['data_dir'], image=facts['common']['cli_image'])
-
- if facts['common']['is_containerized']:
- facts['common']['client_binary'] = '%s cli' % runner
- facts['common']['admin_binary'] = '%s admin' % runner
-
- return facts
-
def main():
""" main """