Own the k3s config.yaml in the kubernetes role template, write it only on a semantic change and run the installer only when the pinned k3s version differs
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
- name: Install K3s agent
|
||||
command: /root/k3s_install.sh {{ type }}
|
||||
environment:
|
||||
INSTALL_K3S_VERSION: "{{ kubernetes.version }}"
|
||||
when: k3s_installed.rc != 0 or (kubernetes.version != '' and ('k3s version ' ~ kubernetes.version ~ ' ') not in k3s_installed.stdout)
|
||||
register: command
|
||||
changed_when: "'No change detected' not in command.stdout"
|
||||
until: "command is not failed"
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
- name: Install K3s-server for 1st-node
|
||||
command: /root/k3s_install.sh {{ type }}
|
||||
when: "inventory_hostname == groups['kubernetes'][0]"
|
||||
environment:
|
||||
INSTALL_K3S_VERSION: "{{ kubernetes.version }}"
|
||||
when:
|
||||
- "inventory_hostname == groups['kubernetes'][0]"
|
||||
- k3s_installed.rc != 0 or (kubernetes.version != '' and ('k3s version ' ~ kubernetes.version ~ ' ') not in k3s_installed.stdout)
|
||||
register: command
|
||||
changed_when: "'No change detected' not in command.stdout"
|
||||
|
||||
@@ -19,7 +23,11 @@
|
||||
|
||||
- name: Install K3s-server for other nodes
|
||||
command: /root/k3s_install.sh {{ type }}
|
||||
when: "inventory_hostname != groups['kubernetes'][0]"
|
||||
environment:
|
||||
INSTALL_K3S_VERSION: "{{ kubernetes.version }}"
|
||||
when:
|
||||
- "inventory_hostname != groups['kubernetes'][0]"
|
||||
- k3s_installed.rc != 0 or (kubernetes.version != '' and ('k3s version ' ~ kubernetes.version ~ ' ') not in k3s_installed.stdout)
|
||||
register: command
|
||||
changed_when: "'No change detected' not in command.stdout"
|
||||
until: "command is not failed"
|
||||
|
||||
Reference in New Issue
Block a user