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 --- inventory/byo/hosts.example | 3 +++ roles/openshift_facts/library/openshift_facts.py | 28 ++++++++++++++++++++++ roles/openshift_master/tasks/main.yml | 2 ++ roles/openshift_master/templates/master.yaml.v1.j2 | 10 +------- .../templates/v1_partials/projectConfig.j2 | 1 + 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 roles/openshift_master/templates/v1_partials/projectConfig.j2 diff --git a/inventory/byo/hosts.example b/inventory/byo/hosts.example index 629956d0e..010dd797f 100644 --- a/inventory/byo/hosts.example +++ b/inventory/byo/hosts.example @@ -38,6 +38,9 @@ deployment_type=enterprise # Allow all auth #openshift_master_identity_providers=[{'name': 'allow_all', 'login': 'true', 'challenge': 'true', 'kind': 'AllowAllPasswordIdentityProvider'}] +# Project Configuration +#openshift_master_project_config=[{'projectConfig': {'defaultNodeSelector':'', 'projectRequestMessage':'','projectRequestTemplate':'','securityAllocator':{'mcsAllocatorRange':'s0:/2', 'mcsLabelsPerProject':5, 'uidAllocatorRange':'1000000000-1999999999/10000'}}}] + # master cluster ha variables using pacemaker or RHEL HA #openshift_master_cluster_password=openshift_cluster #openshift_master_cluster_vip=192.168.133.25 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) diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 151d0662f..5975ae224 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -55,6 +55,8 @@ sdn_host_subnet_length: "{{ osm_host_subnet_length | default(None) }}" default_subdomain: "{{ osm_default_subdomain | default(None) }}" custom_cors_origins: "{{ osm_custom_cors_origins | default(None) }}" + project_config: "{{ openshift_master_project_config | default(None) }}" + # TODO: These values need to be configurable - name: Set dns OpenShift facts diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index c4d319c87..0a8f6c286 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -93,15 +93,7 @@ policyConfig: bootstrapPolicyFile: {{ openshift_master_policy }} openshiftInfrastructureNamespace: openshift-infra openshiftSharedResourcesNamespace: openshift -{# TODO: Allow users to override projectConfig items #} -projectConfig: - defaultNodeSelector: "" - projectRequestMessage: "" - projectRequestTemplate: "" - securityAllocator: - mcsAllocatorRange: s0:/2 - mcsLabelsPerProject: 5 - uidAllocatorRange: 1000000000-1999999999/10000 +{% include 'v1_partials/projectConfig.j2' %} routingConfig: subdomain: "{{ openshift.master.default_subdomain | default("") }}" serviceAccountConfig: diff --git a/roles/openshift_master/templates/v1_partials/projectConfig.j2 b/roles/openshift_master/templates/v1_partials/projectConfig.j2 new file mode 100644 index 000000000..55170e406 --- /dev/null +++ b/roles/openshift_master/templates/v1_partials/projectConfig.j2 @@ -0,0 +1 @@ +{{ openshift.master.project_config[0] | to_nice_yaml }} -- 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 ---------------------- roles/openshift_master/tasks/main.yml | 7 +++++- roles/openshift_master/templates/master.yaml.v1.j2 | 9 ++++++- 3 files changed, 14 insertions(+), 30 deletions(-) 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) diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 5975ae224..019856f19 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -55,7 +55,12 @@ sdn_host_subnet_length: "{{ osm_host_subnet_length | default(None) }}" default_subdomain: "{{ osm_default_subdomain | default(None) }}" custom_cors_origins: "{{ osm_custom_cors_origins | default(None) }}" - project_config: "{{ openshift_master_project_config | default(None) }}" + default_node_selector: "{{ osm_default_node_selector | default(None) }}" + project_request_message: "{{ osm_project_request_message | default(None) }}" + project_request_template: "{{ osm_project_request_template | default(None) }}" + mcs_allocator_range: "{{ osm_mcs_allocator_range | default(None) }}" + mcs_labels_per_project: "{{ osm_mcs_labels_per_project | default(None) }}" + uid_allocator_range: "{{ osm_uid_allocator_range | default(None) }}" # TODO: These values need to be configurable diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index 0a8f6c286..20dfe155a 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -93,7 +93,14 @@ policyConfig: bootstrapPolicyFile: {{ openshift_master_policy }} openshiftInfrastructureNamespace: openshift-infra openshiftSharedResourcesNamespace: openshift -{% include 'v1_partials/projectConfig.j2' %} +projectConfig: + defaultNodeSelector: "{{ openshift.master.default_node_selector | default("") }}" + projectRequestMessage: "{{ openshift.master.project_request_message | default("") }}" + projectRequestTemplate: "{{ openshift.master.project_request_template | default("") }}" + securityAllocator: + mcsAllocatorRange: "{{ openshift.master.project_request_template | default("s0:/2") }}" + mcsLabelsPerProject: "{{ openshift.master.mcs_labels_per_project | default("5") }}" + uidAllocatorRange: "{{ openshift.master.uid_allocator_range | default("1000000000-1999999999/10000") }}" routingConfig: subdomain: "{{ openshift.master.default_subdomain | default("") }}" serviceAccountConfig: -- cgit v1.2.3 From 1d764a0bebbbb12e3c3142c59b10fae34c8b7211 Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Wed, 12 Aug 2015 22:55:14 -0300 Subject: Add missing inventory example --- inventory/byo/hosts.example | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inventory/byo/hosts.example b/inventory/byo/hosts.example index 010dd797f..6a082e518 100644 --- a/inventory/byo/hosts.example +++ b/inventory/byo/hosts.example @@ -39,7 +39,12 @@ deployment_type=enterprise #openshift_master_identity_providers=[{'name': 'allow_all', 'login': 'true', 'challenge': 'true', 'kind': 'AllowAllPasswordIdentityProvider'}] # Project Configuration -#openshift_master_project_config=[{'projectConfig': {'defaultNodeSelector':'', 'projectRequestMessage':'','projectRequestTemplate':'','securityAllocator':{'mcsAllocatorRange':'s0:/2', 'mcsLabelsPerProject':5, 'uidAllocatorRange':'1000000000-1999999999/10000'}}}] +#osm_default_node_selector='' +#osm_project_request_message='' +#osm_project_request_template='' +#osm_mcs_allocator_range='s0:/2' +#osm_mcs_labels_per_project=5 +#osm_uid_allocator_range='1000000000-1999999999/10000' # master cluster ha variables using pacemaker or RHEL HA #openshift_master_cluster_password=openshift_cluster -- cgit v1.2.3 From 7f740ff24b807f9f88209785a027056bfa146e2e Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Mon, 17 Aug 2015 11:59:07 -0300 Subject: Cleanup --- inventory/byo/hosts.example | 1 - roles/openshift_master/templates/v1_partials/projectConfig.j2 | 1 - 2 files changed, 2 deletions(-) delete mode 100644 roles/openshift_master/templates/v1_partials/projectConfig.j2 diff --git a/inventory/byo/hosts.example b/inventory/byo/hosts.example index b7ad231d7..bc1b10768 100644 --- a/inventory/byo/hosts.example +++ b/inventory/byo/hosts.example @@ -39,7 +39,6 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', #openshift_master_identity_providers=[{'name': 'allow_all', 'login': 'true', 'challenge': 'true', 'kind': 'AllowAllPasswordIdentityProvider'}] # Project Configuration -#osm_default_node_selector='' #osm_project_request_message='' #osm_project_request_template='' #osm_mcs_allocator_range='s0:/2' diff --git a/roles/openshift_master/templates/v1_partials/projectConfig.j2 b/roles/openshift_master/templates/v1_partials/projectConfig.j2 deleted file mode 100644 index 55170e406..000000000 --- a/roles/openshift_master/templates/v1_partials/projectConfig.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ openshift.master.project_config[0] | to_nice_yaml }} -- 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 ++++++++++++++++++++++ roles/openshift_master/templates/master.yaml.v1.j2 | 12 +++++----- 2 files changed, 34 insertions(+), 6 deletions(-) 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) diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index b738084c0..7a8ab5c00 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -100,13 +100,13 @@ policyConfig: openshiftInfrastructureNamespace: openshift-infra openshiftSharedResourcesNamespace: openshift projectConfig: - defaultNodeSelector: "{{ openshift.master.default_node_selector | default("") }}" - projectRequestMessage: "{{ openshift.master.project_request_message | default("") }}" - projectRequestTemplate: "{{ openshift.master.project_request_template | default("") }}" + defaultNodeSelector: {{ openshift.master.default_node_selector }} + projectRequestMessage: {{ openshift.master.project_request_message }} + projectRequestTemplate: {{ openshift.master.project_request_template }} securityAllocator: - mcsAllocatorRange: "{{ openshift.master.project_request_template | default("s0:/2") }}" - mcsLabelsPerProject: "{{ openshift.master.mcs_labels_per_project | default("5") }}" - uidAllocatorRange: "{{ openshift.master.uid_allocator_range | default("1000000000-1999999999/10000") }}" + mcsAllocatorRange: {{ openshift.master.mcs_allocator_range }} + mcsLabelsPerProject: {{ openshift.master.mcs_labels_per_project }} + uidAllocatorRange: {{ openshift.master.uid_allocator_range }} routingConfig: subdomain: "{{ openshift.master.default_subdomain | default("") }}" serviceAccountConfig: -- cgit v1.2.3 From 2f55e2d69f8c9e28ccf73065ddc9db62a2aa4ad9 Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Fri, 23 Oct 2015 21:23:55 -0300 Subject: Add missing quotes --- roles/openshift_master/templates/master.yaml.v1.j2 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index d66f9e15d..011b43df6 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -98,13 +98,13 @@ policyConfig: openshiftInfrastructureNamespace: openshift-infra openshiftSharedResourcesNamespace: openshift projectConfig: - defaultNodeSelector: {{ openshift.master.default_node_selector }} - projectRequestMessage: {{ openshift.master.project_request_message }} - projectRequestTemplate: {{ openshift.master.project_request_template }} + defaultNodeSelector: "{{ openshift.master.default_node_selector }}" + projectRequestMessage: "{{ openshift.master.project_request_message }}" + projectRequestTemplate: "{{ openshift.master.project_request_template }}" securityAllocator: - mcsAllocatorRange: {{ openshift.master.mcs_allocator_range }} - mcsLabelsPerProject: {{ openshift.master.mcs_labels_per_project }} - uidAllocatorRange: {{ openshift.master.uid_allocator_range }} + mcsAllocatorRange: "{{ openshift.master.mcs_allocator_range }}" + mcsLabelsPerProject: "{{ openshift.master.mcs_labels_per_project }}" + uidAllocatorRange: "{{ openshift.master.uid_allocator_range }}" routingConfig: subdomain: "{{ openshift.master.default_subdomain | default("") }}" serviceAccountConfig: -- cgit v1.2.3 From e87883d2be647edbcd564cefbf09a40120f1832d Mon Sep 17 00:00:00 2001 From: Diego Castro Date: Mon, 26 Oct 2015 16:19:53 -0300 Subject: Fix quotes --- roles/openshift_master/templates/master.yaml.v1.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index 011b43df6..90234bacc 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -103,7 +103,7 @@ projectConfig: projectRequestTemplate: "{{ openshift.master.project_request_template }}" securityAllocator: mcsAllocatorRange: "{{ openshift.master.mcs_allocator_range }}" - mcsLabelsPerProject: "{{ openshift.master.mcs_labels_per_project }}" + mcsLabelsPerProject: {{ openshift.master.mcs_labels_per_project }} uidAllocatorRange: "{{ openshift.master.uid_allocator_range }}" routingConfig: subdomain: "{{ openshift.master.default_subdomain | default("") }}" -- cgit v1.2.3