Browse Source

Fix node label customisation (#679)

* node labels: add checks for custom labels

- README: add more info about customising labels
- pre_tasks: add checks for label values, set to empty dict if undefined
- group_vars: move labels customisation from OSEv3 to all

* pre_tasks: tried a new approach to updating variables

* pre_tasks: variable update fixed

* pre_tasks: rollback upscaling changes (to be added in upscaling PR)

* pre_tasks: blank line removed

* pre_tasks: add check for undefined variable (should not happen though)

* pre_tasks: be sure to have regions defined
Tlacenka 7 years ago
parent
commit
2a0afda094

+ 9 - 1
playbooks/provisioning/openstack/README.md

@@ -130,7 +130,15 @@ The `openstack_num_masters`, `openstack_num_infra` and
 App nodes to create.
 
 The `openshift_cluster_node_labels` defines custom labels for your openshift
-cluster node groups, like app or infra nodes. For example: `{'region': 'infra'}`.
+cluster node groups. It currently supports app and infra node groups.
+The default value of this variable sets `region: primary` to app nodes and
+`region: infra` to infra nodes.
+An example of setting a customised label:
+```
+openshift_cluster_node_labels:
+  app:
+    mylabel: myvalue
+```
 
 The `openstack_nodes_to_remove` allows you to specify the numerical indexes
 of App nodes that should be removed; for example, ['0', '2'],

+ 16 - 0
playbooks/provisioning/openstack/pre_tasks.yml

@@ -31,3 +31,19 @@
   delegate_to: localhost
   when:
   - openshift_master_default_subdomain is undefined
+
+# Check that openshift_cluster_node_labels has regions defined for all groups
+# NOTE(kpilatov): if node labels are to be enabled for more groups,
+#                 this check needs to be modified as well
+- name: Set openshift_cluster_node_labels if undefined (should not happen)
+  set_fact:
+    openshift_cluster_node_labels: {'app': {'region': 'primary'}, 'infra': {'region': 'infra'}}
+  when: openshift_cluster_node_labels is not defined
+
+- name: Set openshift_cluster_node_labels for the infra group
+  set_fact:
+    openshift_cluster_node_labels: "{{ openshift_cluster_node_labels | combine({'infra': {'region': 'infra'}}, recursive=True) }}"
+
+- name: Set openshift_cluster_node_labels for the app group
+  set_fact:
+    openshift_cluster_node_labels: "{{ openshift_cluster_node_labels | combine({'app': {'region': 'primary'}}, recursive=True) }}"

+ 0 - 6
playbooks/provisioning/openstack/sample-inventory/group_vars/OSEv3.yml

@@ -8,12 +8,6 @@ openshift_master_cluster_method: native
 openshift_master_cluster_hostname: "{{ groups.lb.0|default(groups.masters.0) }}"
 openshift_master_cluster_public_hostname: "{{ groups.lb.0|default(groups.masters.0) }}"
 
-#openshift_cluster_node_labels:
-#  app:
-#    region: primary
-#  infra:
-#    region: infra
-
 osm_default_node_selector: 'region=primary'
 
 # NOTE(shadower): the hostname check seems to always fail because the

+ 9 - 0
playbooks/provisioning/openstack/sample-inventory/group_vars/all.yml

@@ -122,3 +122,12 @@ ansible_user: openshift
 # If you want to use the VM storage instead of Cinder volumes, set this to `true`.
 # NOTE: this is for testing only! Your data will be gone once the VM disappears!
 # ephemeral_volumes: false
+
+# # OpenShift node labels
+# # - in order to customise node labels for app and/or infra group, set the
+# #   openshift_cluster_node_labels variable
+#openshift_cluster_node_labels:
+#  app:
+#    region: primary
+#  infra:
+#    region: infra