Преглед изворни кода

Ensure installed crio version matches cluster API

Russell Teague пре 5 година
родитељ
комит
ca6b56dd43
2 измењених фајлова са 26 додато и 9 уклоњено
  1. 3 3
      roles/openshift_node/defaults/main.yml
  2. 23 6
      roles/openshift_node/tasks/install.yml

+ 3 - 3
roles/openshift_node/defaults/main.yml

@@ -10,9 +10,9 @@ openshift_node_bootstrap_server: "{{ openshift_node_kubeconfig.clusters.0.cluste
 openshift_node_bootstrap_endpoint: "{{ openshift_node_bootstrap_server }}/config/{{ openshift_node_machineconfigpool }}"
 
 openshift_node_packages:
-  - cri-o
-  - openshift-clients{{ l_cluster_version }}
-  - openshift-hyperkube{{ l_cluster_version }}
+  - cri-o-{{ kubernetes_major_version }}.{{ kubernetes_minor_version }}.*
+  - openshift-clients-{{ l_cluster_version }}.*
+  - openshift-hyperkube-{{ l_cluster_version }}.*
 
 openshift_node_support_packages: "{{ openshift_node_support_packages_base + openshift_node_support_packages_by_arch[ansible_architecture] }}"
 

+ 23 - 6
roles/openshift_node/tasks/install.yml

@@ -32,17 +32,34 @@
   until:
   - oc_get.stdout is defined
   - oc_get.stdout != ''
-  retries: 36
-  delay: 5
 
 - name: Set fact l_cluster_version
   set_fact:
-    l_cluster_version: "-{{ oc_get.stdout | regex_search('^\\d+\\.\\d+') }}*"
+    l_cluster_version: "{{ oc_get.stdout | regex_search('^\\d+\\.\\d+') }}"
 
-- name: Override version when running CI
+- name: Override cluster version when running CI
   set_fact:
-    l_cluster_version: ""
-  when: ci_version_override | default(False) | bool == True
+    l_cluster_version: "*"
+  when: ci_version_override | default(false) | bool == true
+
+- name: Get kubernetes server version
+  command: >
+    oc version
+    --config={{ openshift_node_kubeconfig_path }}
+    --output=json
+  delegate_to: localhost
+  register: oc_get
+  until:
+  - oc_get.stdout is defined
+  - oc_get.stdout != ''
+
+- name: Set fact kubernetes_major_version
+  set_fact:
+    kubernetes_major_version: "{{ (oc_get.stdout | from_json).serverVersion.major }}"
+
+- name: Set fact kubernetes_minor_version
+  set_fact:
+    kubernetes_minor_version: "{{ (oc_get.stdout | from_json).serverVersion.minor | regex_search('^\\d+') }}"
 
 - block:
   - name: Install openshift packages