Browse Source

Ensure existing network facts are set

This commit ensures existing values set for various
network settings remain in place for scaleup
operations by slurping values from the master
config files.
Michael Gugino 7 years ago
parent
commit
615ae4746f

+ 15 - 0
playbooks/init/basic_facts.yml

@@ -74,11 +74,26 @@
   hosts: oo_masters_to_config
   gather_facts: no
   any_errors_fatal: true
+  roles:
+  - openshift_facts
   tasks:
   - import_role:
       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:
+    - l_existing_config_master_config is defined
+    - l_existing_config_master_config.networkConfig is defined
+
 - name: Initialize special first-master variables
   hosts: oo_first_master
   roles:

+ 12 - 1
playbooks/init/cluster_facts.yml

@@ -13,6 +13,17 @@
     get_current_openshift_version:
       deployment_type: "{{ openshift_deployment_type }}"
 
+  # oo_first_master group might not be present due to provisioning plays
+  # for existing clusters, openshift_portal_net will be force-set by
+  # basic_facts.yml from value in existing master configs.
+  - name: set_fact openshift_portal_net if present on masters
+    set_fact:
+      openshift_portal_net: "{{ hostvars[groups.oo_first_master.0].openshift_portal_net }}"
+    when:
+    - "'oo_first_master' in groups"
+    - "groups.oo_first_master | length > 0"
+    - "'openshift_portal_net' in hostvars[groups.oo_first_master.0]"
+
   - name: Gather Cluster facts
     openshift_facts:
       role: common
@@ -21,7 +32,7 @@
         ip: "{{ openshift_ip | default(None) }}"
         public_hostname: "{{ openshift_public_hostname | default(None) }}"
         public_ip: "{{ openshift_public_ip | default(None) }}"
-        portal_net: "{{ openshift_portal_net | default(openshift_master_portal_net) | default(None) }}"
+        portal_net: "{{ openshift_portal_net }}"
         http_proxy: "{{ openshift_http_proxy | default(None) }}"
         https_proxy: "{{ openshift_https_proxy | default(None) }}"
         no_proxy: "{{ openshift_no_proxy | default(None) }}"

+ 0 - 2
playbooks/openshift-master/private/scaleup.yml

@@ -34,8 +34,6 @@
     delay: 1
     changed_when: false
 
-- import_playbook: set_network_facts.yml
-
 - import_playbook: ../../openshift-node/private/bootstrap.yml
 
 - import_playbook: ../../openshift-etcd/private/master_etcd_certificates.yml

+ 0 - 28
playbooks/openshift-master/private/set_network_facts.yml

@@ -1,28 +0,0 @@
----
-- name: Read first master\'s config
-  hosts: oo_first_master
-  gather_facts: no
-  tasks:
-  - stat:
-      path: "{{ openshift.common.config_base }}/master/master-config.yaml"
-    register: g_master_config_stat
-  - slurp:
-      src: "{{ openshift.common.config_base }}/master/master-config.yaml"
-    register: g_master_config_slurp
-
-- name: Set network facts for masters
-  hosts: oo_masters_to_config
-  gather_facts: no
-  roles:
-  - role: openshift_facts
-  post_tasks:
-  - block:
-    - set_fact:
-        openshift_portal_net: "{{ (hostvars[groups.oo_first_master.0].g_master_config_slurp.content|b64decode|from_yaml).networkConfig.serviceNetworkCIDR }}"
-      when: openshift_portal_net is not defined
-    - openshift_facts:
-        role: common
-        local_facts:
-          portal_net: "{{ openshift_portal_net | default(openshift_master_portal_net) | default(None) }}"
-    when:
-    - hostvars[groups.oo_first_master.0].g_master_config_stat.stat.exists | bool

+ 1 - 0
roles/openshift_facts/defaults/main.yml

@@ -14,6 +14,7 @@ openshift_cli_image: "{{ osm_image | default(openshift_cli_image_dict[openshift_
 osm_default_subdomain: "router.default.svc.cluster.local"
 openshift_master_default_subdomain: "{{ osm_default_subdomain }}"
 
+openshift_portal_net: "{{ openshift_master_portal_net | default(None) }}"
 openshift_cluster_network_cidr: "{{ osm_cluster_network_cidr | default('10.128.0.0/14') }}"
 openshift_host_subnet_length: " {{ osm_host_subnet_length | default('9') }}"