-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_info.yaml
104 lines (94 loc) · 3.5 KB
/
check_info.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
- name: Check Kubernetes Version
hosts: controlplanes:workers
tags: kubernetes
roles:
- variables
tasks:
- name: Get Kubelet Minor Version
shell: "if [ ! -z $(which kubelet) ]; then kubelet --version | awk '{ print $2 }' | grep -oP '([0-9].[0-9]+)'; fi"
become: yes
args:
executable: "/bin/bash"
register: kubelet_minor_version
changed_when: false
- name: Get Kubelet Revision
shell: "if [ ! -z $(which kubelet) ]; then kubelet --version | awk '{ print $2 }' | grep -oP '(?!\\.)([0-9]+)$'; fi"
become: yes
args:
executable: "/bin/bash"
register: kubelet_revision
changed_when: false
- debug:
msg:
- "Current Kubelet Version: {{ kubelet_minor_version.stdout }}.{{ kubelet_revision.stdout }}"
- "Would install Kubelet Version: {{ kubernetes_minor_version }}.{{ kubernetes_revision }}"
when:
- kubelet_minor_version.stdout != ""
- kubelet_revision.stdout != ""
- name: Check CNI Version (Calico for now)
hosts: controlplanes
tags: cni
roles:
- variables
tasks:
- name: Check for existing Calico DaemonSet
shell: "kubectl --kubeconfig {{ kube_user_config }} get daemonset -A | grep -ic calico-node"
become: no
failed_when: "calico_ds_count == 2"
register: calico_ds_count
changed_when: false
run_once: true
- name: Check for Calico version
shell: "kubectl --kubeconfig {{ kube_user_config }} get ds -n calico-system calico-node -o yaml | grep -m 1 'image:' | sed -nr 's/.+v([0-9.]+)/\\1/p'"
become: no
register: calico_version_found
changed_when: false
when: "( calico_ds_count.stdout|int > 0 )"
run_once: true
- debug:
msg:
- "Calico Version Found {{ calico_version_found.stdout }}"
- "Calico Version to be installed {{ calico_version }}"
when: "( calico_ds_count.stdout|int > 0 )"
run_once: true
- name: Check MetalLB Version
hosts: controlplanes
tags: metallb
roles:
- variables
tasks:
- name: Check for existing Metallb Controller
shell: "kubectl --kubeconfig {{ kube_user_config }} get pods -A | grep metallb | grep -c controller"
become: no
failed_when: "metallb_controller_count == 2"
register: metallb_controller_count
changed_when: false
- name: Check for existing version
shell: "kubectl --kubeconfig {{ kube_user_config }} get deployment -n metallb-system controller -o jsonpath=\"{.spec.template.spec.containers[0].image}\" | awk -F ':v' '{print $2}'"
become: no
register: metallb_current_version
when: "( metallb_controller_count.stdout|int > 0 )"
- name: Current Version of Metallb Deployment on host
debug:
msg:
- "current version {{ metallb_current_version.stdout }}"
- "version to be applied {{ metallb_version }}"
when: "( metallb_controller_count.stdout|int > 0 )"
- name: Check Longhorn Version
hosts: controlplanes
tags: longhorn
roles:
- variables
tasks:
- name: Check for existing version
shell: "kubectl --kubeconfig {{ kube_user_config }} get daemonset -n longhorn-system longhorn-manager -o jsonpath=\"{.spec.template.spec.containers[0].image}\" | awk -F ':v' '{print $2}'"
become: no
register: longhorn_current_version
changed_when: false
- name: Current Version of Longhorn Deployment on host
debug:
msg:
- "current version {{ longhorn_current_version.stdout }}"
- "version to be applied {{ longhorn_version }}"
when: longhorn_current_version.stdout != ""