diff options
author | Andrew Butcher <abutcher@redhat.com> | 2016-10-25 13:45:56 -0400 |
---|---|---|
committer | Andrew Butcher <abutcher@redhat.com> | 2016-10-26 11:51:51 -0400 |
commit | 33da79e7389a3fceeaf735663fd8051a0a2fe057 (patch) | |
tree | 3d0199f6931e67f0deaea88502046f285970d5c3 /roles/openshift_facts | |
parent | 1f28e81f3e5704f21e26b905fcbadcd7d87482a4 (diff) | |
download | openshift-33da79e7389a3fceeaf735663fd8051a0a2fe057.tar.gz openshift-33da79e7389a3fceeaf735663fd8051a0a2fe057.tar.bz2 openshift-33da79e7389a3fceeaf735663fd8051a0a2fe057.tar.xz openshift-33da79e7389a3fceeaf735663fd8051a0a2fe057.zip |
Default hosted_registry_insecure true when insecure registry present in existing /etc/sysconfig/docker.
Diffstat (limited to 'roles/openshift_facts')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index f281b1303..bf23786c2 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -55,7 +55,6 @@ def migrate_docker_facts(facts): facts['docker'][param] = facts[role].pop(old_param) if 'node' in facts and 'portal_net' in facts['node']: - facts['docker']['hosted_registry_insecure'] = True facts['docker']['hosted_registry_network'] = facts['node'].pop('portal_net') # log_options was originally meant to be a comma separated string, but @@ -1138,6 +1137,24 @@ def get_docker_version_info(): } return result +def get_hosted_registry_insecure(): + """ Parses OPTIONS from /etc/sysconfig/docker to determine if the + registry is currently insecure. + """ + hosted_registry_insecure = None + if os.path.exists('/etc/sysconfig/docker'): + try: + ini_str = unicode('[root]\n' + open('/etc/sysconfig/docker', 'r').read(), 'utf-8') + ini_fp = io.StringIO(ini_str) + config = ConfigParser.RawConfigParser() + config.readfp(ini_fp) + options = config.get('root', 'OPTIONS') + if 'insecure-registry' in options: + hosted_registry_insecure = True + except: + pass + return hosted_registry_insecure + def get_openshift_version(facts): """ Get current version of openshift on the host. @@ -1790,13 +1807,15 @@ class OpenShiftFacts(object): if 'docker' in roles: docker = dict(disable_push_dockerhub=False, - hosted_registry_insecure=True, options='--log-driver=json-file --log-opt max-size=50m') version_info = get_docker_version_info() if version_info is not None: docker['api_version'] = version_info['api_version'] docker['version'] = version_info['version'] docker['gte_1_10'] = LooseVersion(version_info['version']) >= LooseVersion('1.10') + hosted_registry_insecure = get_hosted_registry_insecure() + if hosted_registry_insecure is not None: + docker['hosted_registry_insecure'] = hosted_registry_insecure defaults['docker'] = docker if 'clock' in roles: |