mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2026-10-23 03:22:03 +02:00
fix(roles): fix check mode on clean install (#547)
Signed-off-by: Ian Lewis <ian@ianlewis.org>
This commit is contained in:
1 parent
9cdd1dd47c
commit
35b8377f74
2 files changed
+7
-4
No files matched your search
@@ -100,6 +100,7 @@
|
|||||||
# install script leaves the service stopped (INSTALL_K3S_SKIP_START), so a plain
|
# install script leaves the service stopped (INSTALL_K3S_SKIP_START), so a plain
|
||||||
# restart also covers the first install.
|
# restart also covers the first install.
|
||||||
- name: Enable and start K3s agent
|
- name: Enable and start K3s agent
|
||||||
|
when: not ansible_check_mode
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: k3s-agent
|
name: k3s-agent
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|||||||
@@ -147,7 +147,6 @@
|
|||||||
- name: Init first server node
|
- name: Init first server node
|
||||||
when: inventory_hostname == groups[server_group][0] or ansible_host == groups[server_group][0]
|
when: inventory_hostname == groups[server_group][0] or ansible_host == groups[server_group][0]
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Convert server config to YAML and write to file
|
- name: Convert server config to YAML and write to file
|
||||||
when: not ansible_check_mode
|
when: not ansible_check_mode
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -170,6 +169,7 @@
|
|||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
- name: Enable and start K3s service
|
- name: Enable and start K3s service
|
||||||
|
when: not ansible_check_mode
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: k3s
|
name: k3s
|
||||||
state: restarted
|
state: restarted
|
||||||
@@ -194,6 +194,7 @@
|
|||||||
# If no changes are found, we can skip copying the kubeconfig to the control node.
|
# If no changes are found, we can skip copying the kubeconfig to the control node.
|
||||||
# This is dependent on the speed of the target node for k3s startup time, so retries are used.
|
# This is dependent on the speed of the target node for k3s startup time, so retries are used.
|
||||||
- name: Copy k3s.yaml to second file
|
- name: Copy k3s.yaml to second file
|
||||||
|
when: not ansible_check_mode
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: /etc/rancher/k3s/k3s.yaml
|
src: /etc/rancher/k3s/k3s.yaml
|
||||||
dest: /etc/rancher/k3s/k3s-copy.yaml
|
dest: /etc/rancher/k3s/k3s-copy.yaml
|
||||||
@@ -245,7 +246,9 @@
|
|||||||
- k3s_server_mv_result.rc == 0
|
- k3s_server_mv_result.rc == 0
|
||||||
|
|
||||||
- name: Get the token if randomly generated
|
- name: Get the token if randomly generated
|
||||||
when: token is not defined
|
when:
|
||||||
|
- not ansible_check_mode
|
||||||
|
- token is not defined
|
||||||
block:
|
block:
|
||||||
- name: Wait for token
|
- name: Wait for token
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
@@ -266,7 +269,6 @@
|
|||||||
- (groups[server_group] | length) > 1
|
- (groups[server_group] | length) > 1
|
||||||
- inventory_hostname != groups[server_group][0] and ansible_host != groups[server_group][0]
|
- inventory_hostname != groups[server_group][0] and ansible_host != groups[server_group][0]
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Get token from first server if needed
|
- name: Get token from first server if needed
|
||||||
when: token is not defined and hostvars[groups[server_group][0]].random_token is defined
|
when: token is not defined and hostvars[groups[server_group][0]].random_token is defined
|
||||||
# noqa var-naming[no-role-prefix]
|
# noqa var-naming[no-role-prefix]
|
||||||
@@ -336,7 +338,6 @@
|
|||||||
- name: Setup kubectl for user
|
- name: Setup kubectl for user
|
||||||
when: user_kubectl
|
when: user_kubectl
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Create directory .kube
|
- name: Create directory .kube
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: ~{{ ansible_user }}/.kube
|
path: ~{{ ansible_user }}/.kube
|
||||||
@@ -345,6 +346,7 @@
|
|||||||
mode: "u=rwx,g=rx,o="
|
mode: "u=rwx,g=rx,o="
|
||||||
|
|
||||||
- name: Copy config file to user home directory
|
- name: Copy config file to user home directory
|
||||||
|
when: not ansible_check_mode
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: /etc/rancher/k3s/k3s.yaml
|
src: /etc/rancher/k3s/k3s.yaml
|
||||||
dest: ~{{ ansible_user }}/.kube/config
|
dest: ~{{ ansible_user }}/.kube/config
|
||||||
|
|||||||
Reference in new issue
Block a user