Browse Source

Custom Project Config

Diego Castro 9 years ago
parent
commit
ec293f3710

+ 3 - 0
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

+ 28 - 0
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)

+ 2 - 0
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

+ 1 - 9
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:

+ 1 - 0
roles/openshift_master/templates/v1_partials/projectConfig.j2

@@ -0,0 +1 @@
+{{ openshift.master.project_config[0] | to_nice_yaml }}