Ver Fonte

Merge pull request #11598 from mtnbikenc/fix-kubeconfig

Fix openshift_kube_config_path defaults
Scott Dodson há 5 anos atrás
pai
commit
08e4336a22

+ 3 - 53
playbooks/upgrade.yml

@@ -4,7 +4,8 @@
   connection: local
   connection: local
   gather_facts: no
   gather_facts: no
   tasks:
   tasks:
-  - fail:
+  - name: Ensure [workers] group is populated
+    fail:
       msg: >
       msg: >
         Detected no workers in inventory. Please add hosts to the
         Detected no workers in inventory. Please add hosts to the
         workers host group to upgrade nodes
         workers host group to upgrade nodes
@@ -14,57 +15,6 @@
   hosts: workers
   hosts: workers
   serial: 1
   serial: 1
   tasks:
   tasks:
-  - block:
-    - debug:
-        msg: "Running openshift_node_pre_cordon_hook {{ openshift_node_pre_cordon_hook }}"
-    - include_tasks: "{{ openshift_node_pre_cordon_hook }}"
-    when: openshift_node_pre_cordon_hook is defined
-
-  - name: Cordon node prior to upgrade
-    command: >
-      oc adm cordon {{ item | lower }}
-      --config={{ openshift_kubeconfig_path }}
-    delegate_to: localhost
-    with_items: "{{ ansible_play_batch }}"
-
-  - name: Drain node prior to upgrade
-    command: >
-      oc adm drain {{ item | lower }}
-      --config={{ openshift_kubeconfig_path }}
-      --force --delete-local-data --ignore-daemonsets
-    delegate_to: localhost
-    with_items: "{{ ansible_play_batch }}"
-
-  # Run the openshift_node_pre_upgrade_hook if defined
-  - block:
-    - debug:
-        msg: "Running node openshift_node_pre_upgrade_hook {{ openshift_node_pre_upgrade_hook }}"
-    - include_tasks: "{{ openshift_node_pre_upgrade_hook }}"
-    when: openshift_node_pre_upgrade_hook is defined
-
-  # Upgrade Node
   - import_role:
   - import_role:
       name: openshift_node
       name: openshift_node
-    vars:
-      openshift_node_package_state: latest
-
-  # Run the openshift_node_pre_uncordon_hook if defined
-  - block:
-    - debug:
-        msg: "Running openshift_node_pre_uncordon_hook {{ openshift_node_pre_uncordon_hook }}"
-    - include_tasks: "{{ openshift_node_pre_uncordon_hook }}"
-    when: openshift_node_pre_uncordon_hook is defined
-
-  - name: Uncordon node after upgrade
-    command: >
-      oc adm uncordon {{ item | lower }}
-      --config={{ openshift_kubeconfig_path }}
-    delegate_to: localhost
-    with_items: "{{ ansible_play_batch }}"
-
-  # Run the openshift_node_post_upgrade_hook if defined
-  - block:
-    - debug:
-        msg: "Running node openshift_node_post_upgrade_hook {{ openshift_node_post_upgrade_hook }}"
-    - include_tasks: "{{ openshift_node_post_upgrade_hook }}"
-    when: openshift_node_post_upgrade_hook is defined
+      tasks_from: upgrade.yml

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

@@ -1,11 +1,11 @@
 ---
 ---
-openshift_kubeconfig_path: '~/.kube/config'
 openshift_pull_secret_path: '~/pull-secret.txt'
 openshift_pull_secret_path: '~/pull-secret.txt'
 
 
 openshift_node_machineconfigpool: 'worker'
 openshift_node_machineconfigpool: 'worker'
 openshift_node_tls_verify: false
 openshift_node_tls_verify: false
 
 
-openshift_node_kubeconfig: "{{ lookup('file', openshift_kubeconfig_path) | from_yaml }}"
+openshift_node_kubeconfig_path: "{{ openshift_kubeconfig_path | default('~/.kube/config') | expanduser | realpath }}"
+openshift_node_kubeconfig: "{{ lookup('file', openshift_node_kubeconfig_path) | from_yaml }}"
 openshift_node_bootstrap_port: 22623
 openshift_node_bootstrap_port: 22623
 openshift_node_bootstrap_server: "{{ openshift_node_kubeconfig.clusters.0.cluster.server.split(':')[0:-1] | join(':') }}:{{ openshift_node_bootstrap_port }}"
 openshift_node_bootstrap_server: "{{ openshift_node_kubeconfig.clusters.0.cluster.server.split(':')[0:-1] | join(':') }}:{{ openshift_node_bootstrap_port }}"
 openshift_node_bootstrap_endpoint: "{{ openshift_node_bootstrap_server }}/config/{{ openshift_node_machineconfigpool }}"
 openshift_node_bootstrap_endpoint: "{{ openshift_node_bootstrap_server }}/config/{{ openshift_node_machineconfigpool }}"

+ 1 - 1
roles/openshift_node/tasks/config.yml

@@ -51,7 +51,7 @@
 - name: Get release image
 - name: Get release image
   command: >
   command: >
     oc get clusterversion
     oc get clusterversion
-    --config={{ openshift_kubeconfig_path }}
+    --config={{ openshift_node_kubeconfig_path }}
     --output=jsonpath='{.items[0].status.desired.image}'
     --output=jsonpath='{.items[0].status.desired.image}'
   delegate_to: localhost
   delegate_to: localhost
   register: oc_get
   register: oc_get

+ 55 - 0
roles/openshift_node/tasks/upgrade.yml

@@ -0,0 +1,55 @@
+---
+- block:
+  - debug:
+      msg: "Running openshift_node_pre_cordon_hook {{ openshift_node_pre_cordon_hook }}"
+  - include_tasks: "{{ openshift_node_pre_cordon_hook }}"
+  when: openshift_node_pre_cordon_hook is defined
+
+- name: Cordon node prior to upgrade
+  command: >
+    oc adm cordon {{ item | lower }}
+    --config={{ openshift_node_kubeconfig_path }}
+  delegate_to: localhost
+  with_items: "{{ ansible_play_batch }}"
+
+- name: Drain node prior to upgrade
+  command: >
+    oc adm drain {{ item | lower }}
+    --config={{ openshift_node_kubeconfig_path }}
+    --force --delete-local-data --ignore-daemonsets
+  delegate_to: localhost
+  with_items: "{{ ansible_play_batch }}"
+
+# Run the openshift_node_pre_upgrade_hook if defined
+- block:
+  - debug:
+      msg: "Running node openshift_node_pre_upgrade_hook {{ openshift_node_pre_upgrade_hook }}"
+  - include_tasks: "{{ openshift_node_pre_upgrade_hook }}"
+  when: openshift_node_pre_upgrade_hook is defined
+
+# Upgrade Node
+- import_role:
+    name: openshift_node
+  vars:
+    openshift_node_package_state: latest
+
+# Run the openshift_node_pre_uncordon_hook if defined
+- block:
+  - debug:
+      msg: "Running openshift_node_pre_uncordon_hook {{ openshift_node_pre_uncordon_hook }}"
+  - include_tasks: "{{ openshift_node_pre_uncordon_hook }}"
+  when: openshift_node_pre_uncordon_hook is defined
+
+- name: Uncordon node after upgrade
+  command: >
+    oc adm uncordon {{ item | lower }}
+    --config={{ openshift_node_kubeconfig_path }}
+  delegate_to: localhost
+  with_items: "{{ ansible_play_batch }}"
+
+# Run the openshift_node_post_upgrade_hook if defined
+- block:
+  - debug:
+      msg: "Running node openshift_node_post_upgrade_hook {{ openshift_node_post_upgrade_hook }}"
+  - include_tasks: "{{ openshift_node_post_upgrade_hook }}"
+  when: openshift_node_post_upgrade_hook is defined