From ec293f371046a99b0f737a59b4a9f3f001af3279 Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Wed, 12 Aug 2015 20:02:05 -0300 Subject: Custom Project Config --- roles/openshift_facts/library/openshift_facts.py | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 4e0989c5f..0fde372ed 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -349,6 +349,33 @@ def set_identity_providers_if_unset(facts): return facts +def set_project_config_if_unset(facts): + """ Set project_config fact if not already present in facts dict + + Args: + facts (dict): existing facts + Returns: + dict: the facts dict updated with the generated identity providers + facts if they were not already present + """ + if 'master' in facts: + if 'project_config' not in facts['master']: + config = dict( + projectConfig=dict( + defaultNodeSelector='', + projectRequestMessage='', + projectRequestTemplate='', + securityAllocator=dict( + mcsAllocatorRange='s0:/2', + mcsLabelsPerProject=5, + uidAllocatorRange='1000000000-1999999999/10000' + ) + ) + ) + facts['master']['project_config'] = [config] + + return facts + def set_url_facts_if_unset(facts): """ Set url facts if not already present in facts dict @@ -700,6 +727,7 @@ class OpenShiftFacts(object): facts['current_config'] = get_current_config(facts) facts = set_url_facts_if_unset(facts) facts = set_fluentd_facts_if_unset(facts) + facts = set_project_config_if_unset(facts) facts = set_identity_providers_if_unset(facts) facts = set_registry_url_if_unset(facts) facts = set_sdn_facts_if_unset(facts) -- cgit v1.2.3 From 0bc39b7f4ad53344d19d0d783fd6eec4d3b424ef Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Wed, 12 Aug 2015 22:53:10 -0300 Subject: Update PR #458 from comments --- roles/openshift_facts/library/openshift_facts.py | 28 ------------------------ 1 file changed, 28 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 0fde372ed..4e0989c5f 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -349,33 +349,6 @@ def set_identity_providers_if_unset(facts): return facts -def set_project_config_if_unset(facts): - """ Set project_config fact if not already present in facts dict - - Args: - facts (dict): existing facts - Returns: - dict: the facts dict updated with the generated identity providers - facts if they were not already present - """ - if 'master' in facts: - if 'project_config' not in facts['master']: - config = dict( - projectConfig=dict( - defaultNodeSelector='', - projectRequestMessage='', - projectRequestTemplate='', - securityAllocator=dict( - mcsAllocatorRange='s0:/2', - mcsLabelsPerProject=5, - uidAllocatorRange='1000000000-1999999999/10000' - ) - ) - ) - facts['master']['project_config'] = [config] - - return facts - def set_url_facts_if_unset(facts): """ Set url facts if not already present in facts dict @@ -727,7 +700,6 @@ class OpenShiftFacts(object): facts['current_config'] = get_current_config(facts) facts = set_url_facts_if_unset(facts) facts = set_fluentd_facts_if_unset(facts) - facts = set_project_config_if_unset(facts) facts = set_identity_providers_if_unset(facts) facts = set_registry_url_if_unset(facts) facts = set_sdn_facts_if_unset(facts) -- cgit v1.2.3 From 8468d25fae71c80277c10ad975641cb1ba230fd8 Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Mon, 17 Aug 2015 17:38:23 -0300 Subject: Get default values from openshift_facts --- roles/openshift_facts/library/openshift_facts.py | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 4e0989c5f..97a839e8e 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -323,6 +323,33 @@ def set_fluentd_facts_if_unset(facts): facts['common']['use_fluentd'] = use_fluentd return facts +def set_project_config_facts_if_unset(facts): + """ Set Project Configuration facts if not already present in facts dict + dict: + Args: + facts (dict): existing facts + Returns: + dict: the facts dict updated with the generated Project Configuration + facts if they were not already present + + """ + + config={ + 'default_node_selector': '', + 'project_request_message': '', + 'project_request_template': '', + 'mcs_allocator_range': 's0:/2', + 'mcs_labels_per_project': 5, + 'uid_allocator_range': '1000000000-1999999999/10000' + } + + if 'master' in facts: + for key,value in config.items(): + if key not in facts['master']: + facts['master'][key] = value + + return facts + def set_identity_providers_if_unset(facts): """ Set identity_providers fact if not already present in facts dict @@ -699,6 +726,7 @@ class OpenShiftFacts(object): facts = merge_facts(facts, local_facts) facts['current_config'] = get_current_config(facts) facts = set_url_facts_if_unset(facts) + facts = set_project_config_facts_if_unset(facts) facts = set_fluentd_facts_if_unset(facts) facts = set_identity_providers_if_unset(facts) facts = set_registry_url_if_unset(facts) -- cgit v1.2.3 From 7eefcf8a04251da4d10deb936273847d47ccb609 Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Thu, 22 Oct 2015 16:48:24 -0400 Subject: Move version greater_than_fact into openshift_facts --- roles/openshift_facts/library/openshift_facts.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 3570de693..d0388e6fe 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -20,6 +20,7 @@ EXAMPLES = ''' import ConfigParser import copy import os +from ansible.runner.filter_plugins.core import version_compare from distutils.util import strtobool @@ -501,7 +502,12 @@ def set_deployment_facts_if_unset(facts): if deployment_type in ['enterprise', 'online']: data_dir = '/var/lib/openshift' facts['common']['data_dir'] = data_dir - facts['common']['version'] = get_openshift_version() + facts['common']['version'] = version = get_openshift_version() + if deployment_type == 'origin': + version_gt_3_1_or_1_1 = version_compare(version, '1.0.6', '>') + else: + version_gt_3_1_or_1_1 = version_compare(version, '3.0.2', '>') + facts['common']['version_greater_than_3_1_or_1_1'] = version_gt_3_1_or_1_1 for role in ('master', 'node'): if role in facts: @@ -632,7 +638,7 @@ def get_openshift_version(): Returns: version: the current openshift version """ - version = '' + version = None if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) -- cgit v1.2.3 From 05458ecde01c9c1ade9d1a5216bc7621a92b9d6f Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Mon, 26 Oct 2015 09:00:59 -0400 Subject: Use standard library for version comparison. --- roles/openshift_facts/library/openshift_facts.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index d0388e6fe..ece272c78 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -20,8 +20,8 @@ EXAMPLES = ''' import ConfigParser import copy import os -from ansible.runner.filter_plugins.core import version_compare from distutils.util import strtobool +from distutils.version import LooseVersion def hostname_valid(hostname): @@ -503,10 +503,13 @@ def set_deployment_facts_if_unset(facts): data_dir = '/var/lib/openshift' facts['common']['data_dir'] = data_dir facts['common']['version'] = version = get_openshift_version() - if deployment_type == 'origin': - version_gt_3_1_or_1_1 = version_compare(version, '1.0.6', '>') + if version is not None: + if deployment_type == 'origin': + version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('1.0.6') + else: + version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('3.0.2') else: - version_gt_3_1_or_1_1 = version_compare(version, '3.0.2', '>') + version_gt_3_1_or_1_1 = True facts['common']['version_greater_than_3_1_or_1_1'] = version_gt_3_1_or_1_1 for role in ('master', 'node'): -- cgit v1.2.3 From aff1356306adf8d02efe06ccbb322b68bef0995d Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Fri, 23 Oct 2015 14:08:40 -0400 Subject: make storage plugin dependency installation more flexible --- roles/openshift_facts/library/openshift_facts.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 3570de693..95ee822a9 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -469,6 +469,21 @@ def set_aggregate_facts(facts): return facts +def set_node_plugin_facts_if_unset(facts): + """ Set Facts for node storage plugin dependencies if not set. + + Args: + facts (dict): existing facts + Returns: + dict: the facts dict updated with the generated storage plugin + dependency facts + """ + if 'node' in facts: + if 'storage_plugin_deps' not in facts['node']: + facts['node']['storage_plugin_deps'] = ['ceph', 'glusterfs'] + + return facts + def set_deployment_facts_if_unset(facts): """ Set Facts that vary based on deployment_type. This currently includes common.service_type, common.config_base, master.registry_url, @@ -814,6 +829,7 @@ class OpenShiftFacts(object): facts = set_identity_providers_if_unset(facts) facts = set_sdn_facts_if_unset(facts) facts = set_deployment_facts_if_unset(facts) + facts = set_node_plugin_facts_if_unset(facts) facts = set_aggregate_facts(facts) return dict(openshift=facts) -- cgit v1.2.3 From 0944fc8957085bc14b93ed91fc1d74bf4ec12f44 Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Mon, 26 Oct 2015 16:58:23 -0400 Subject: Pylint fixes --- roles/openshift_facts/library/openshift_facts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 4880e0bcb..3afbbbbb3 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -362,7 +362,7 @@ def set_metrics_facts_if_unset(facts): facts['common']['use_cluster_metrics'] = use_cluster_metrics return facts -def set_project_config_facts_if_unset(facts): +def set_project_cfg_facts_if_unset(facts): """ Set Project Configuration facts if not already present in facts dict dict: Args: @@ -373,7 +373,7 @@ def set_project_config_facts_if_unset(facts): """ - config={ + config = { 'default_node_selector': '', 'project_request_message': '', 'project_request_template': '', @@ -383,7 +383,7 @@ def set_project_config_facts_if_unset(facts): } if 'master' in facts: - for key,value in config.items(): + for key, value in config.items(): if key not in facts['master']: facts['master'][key] = value @@ -834,7 +834,7 @@ class OpenShiftFacts(object): facts = merge_facts(facts, local_facts) facts['current_config'] = get_current_config(facts) facts = set_url_facts_if_unset(facts) - facts = set_project_config_facts_if_unset(facts) + facts = set_project_cfg_facts_if_unset(facts) facts = set_fluentd_facts_if_unset(facts) facts = set_node_schedulability(facts) facts = set_master_selectors(facts) -- cgit v1.2.3 From 8bfcf17c0355464123146685e31e06a27182b1a9 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Tue, 27 Oct 2015 13:34:53 -0400 Subject: make storage_plugin_deps conditional on deployment_type --- roles/openshift_facts/library/openshift_facts.py | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 95ee822a9..220dce702 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -469,25 +469,10 @@ def set_aggregate_facts(facts): return facts -def set_node_plugin_facts_if_unset(facts): - """ Set Facts for node storage plugin dependencies if not set. - - Args: - facts (dict): existing facts - Returns: - dict: the facts dict updated with the generated storage plugin - dependency facts - """ - if 'node' in facts: - if 'storage_plugin_deps' not in facts['node']: - facts['node']['storage_plugin_deps'] = ['ceph', 'glusterfs'] - - return facts - def set_deployment_facts_if_unset(facts): """ Set Facts that vary based on deployment_type. This currently includes common.service_type, common.config_base, master.registry_url, - node.registry_url + node.registry_url, node.storage_plugin_deps Args: facts (dict): existing facts @@ -529,6 +514,14 @@ def set_deployment_facts_if_unset(facts): registry_url = 'aep3/aep-${component}:${version}' facts[role]['registry_url'] = registry_url + if 'node' in facts: + deployment_type = facts['common']['deployment_type'] + if 'storage_plugin_deps' not in facts['node']: + if deployment_type in ['openshift-enterprise', 'atomic-enterprise']: + facts['node']['storage_plugin_deps'] = ['ceph', 'glusterfs'] + else: + facts['node']['storage_plugin_deps'] = [] + return facts @@ -829,7 +822,6 @@ class OpenShiftFacts(object): facts = set_identity_providers_if_unset(facts) facts = set_sdn_facts_if_unset(facts) facts = set_deployment_facts_if_unset(facts) - facts = set_node_plugin_facts_if_unset(facts) facts = set_aggregate_facts(facts) return dict(openshift=facts) -- cgit v1.2.3 From a9143d5d0e7245e12e0597fa5105fdcbb85e0846 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Thu, 29 Oct 2015 23:42:31 -0400 Subject: Disable OpenShift features if installing Atomic Enterprise --- roles/openshift_facts/library/openshift_facts.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 795f38341..748cc59cf 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -508,8 +508,9 @@ def set_deployment_facts_if_unset(facts): dict: the facts dict updated with the generated deployment_type facts """ - # Perhaps re-factor this as a map? - # pylint: disable=too-many-branches + # disabled to avoid breaking up facts related to deployment type into + # multiple methods for now. + # pylint: disable=too-many-statements, too-many-branches if 'common' in facts: deployment_type = facts['common']['deployment_type'] if 'service_type' not in facts['common']: @@ -550,6 +551,17 @@ def set_deployment_facts_if_unset(facts): registry_url = 'aep3/aep-${component}:${version}' facts[role]['registry_url'] = registry_url + if 'master' in facts: + deployment_type = facts['common']['deployment_type'] + openshift_features = ['Builder', 'S2IBuilder', 'WebConsole'] + if 'disabled_features' in facts['master']: + if deployment_type == 'atomic-enterprise': + curr_disabled_features = set(facts['master']['disabled_features']) + facts['master']['disabled_features'] = list(curr_disabled_features.union(openshift_features)) + else: + if deployment_type == 'atomic-enterprise': + facts['master']['disabled_features'] = openshift_features + if 'node' in facts: deployment_type = facts['common']['deployment_type'] if 'storage_plugin_deps' not in facts['node']: -- cgit v1.2.3 From 00521b2a5cccff48a3cedd70d4add267bf92d14e Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Fri, 30 Oct 2015 09:43:03 -0400 Subject: Use more specific enterprise version for version_greater_than_3_1_or_1_1. --- roles/openshift_facts/library/openshift_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 795f38341..ac19fac5f 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -534,7 +534,7 @@ def set_deployment_facts_if_unset(facts): if deployment_type == 'origin': version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('1.0.6') else: - version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('3.0.2') + version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('3.0.2.900') else: version_gt_3_1_or_1_1 = True facts['common']['version_greater_than_3_1_or_1_1'] = version_gt_3_1_or_1_1 -- cgit v1.2.3