Browse Source

Merge pull request #8325 from mgugino-upstream-stage/fix-undef-networks

Fix undefined variable for existing network config
Michael Gugino 7 years ago
parent
commit
429405b353
1 changed files with 18 additions and 10 deletions
  1. 18 10
      playbooks/init/basic_facts.yml

+ 18 - 10
playbooks/init/basic_facts.yml

@@ -81,18 +81,26 @@
       name: openshift_control_plane
       tasks_from: check_existing_config.yml
 
-  - set_fact:
-      osm_cluster_network_cidr: "{{ l_existing_clusternet_cidr }}"
-      osm_host_subnet_length: "{{ l_existing_clusternet_len }}"
-      openshift_portal_net: "{{ l_existing_config_master_config.networkConfig.serviceNetworkCIDR }}"
-    vars:
-      # networkConfig.clusterNetworks may not be present in upgraded clusters
-      l_clusternet_list: "{{ l_existing_config_master_config.networkConfig.clusterNetworks is defined | bool }}"
-      l_existing_clusternet_cidr: "{{ l_clusternet_list | ternary((l_existing_config_master_config.networkConfig.clusterNetworks[0].cidr | default('')), l_existing_config_master_config.networkConfig.clusterNetworkCIDR) }}"
-      l_existing_clusternet_len: "{{ l_clusternet_list | ternary((l_existing_config_master_config.networkConfig.clusterNetworks[0].hostSubnetLength | default('')), l_existing_config_master_config.networkConfig.hostSubnetLength) }}"
-    when:
+  - when:
     - l_existing_config_master_config is defined
     - l_existing_config_master_config.networkConfig is defined
+    block:
+    - set_fact:
+        openshift_portal_net: "{{ l_existing_config_master_config.networkConfig.serviceNetworkCIDR }}"
+
+    - set_fact:
+        osm_cluster_network_cidr: "{{ l_existing_config_master_config.networkConfig.clusterNetworks[0].cidr }}"
+        osm_host_subnet_length: "{{ l_existing_config_master_config.networkConfig.clusterNetworks[0].hostSubnetLength }}"
+      when:
+      - l_existing_config_master_config.networkConfig.clusterNetworks is defined
+
+    # Use deprecated config variables if newer ones not found above.
+    - set_fact:
+        osm_cluster_network_cidr: "{{ l_existing_config_master_config.networkConfig.clusterNetworkCIDR }}"
+        osm_host_subnet_length: "{{ l_existing_config_master_config.networkConfig.hostSubnetLength }}"
+      when:
+      - l_existing_config_master_config.networkConfig.clusterNetworks is not defined
+      # End block
 
 - name: Initialize special first-master variables
   hosts: oo_first_master