zhong (钟鹏群) 1 lună în urmă
părinte
comite
a07e33eae3

+ 9 - 4
terraform/ansible-files/install-k3s-master.yml

@@ -21,10 +21,15 @@
       when: k3s_service_exists.stat.exists
       ignore_errors: yes
 
-    - name: Kill any running k3s processes
-      shell: pkill -f k3s || true
-      when: k3s_service_exists.stat.exists
-      ignore_errors: yes
+    - name: Check for running k3s processes
+      shell: pgrep -f k3s
+      register: k3s_processes
+      failed_when: false
+      changed_when: false
+
+    - name: Kill running k3s processes if any exist
+      shell: pkill -f k3s
+      when: k3s_processes.rc == 0  # Only run if processes were found
 
     - name: Remove k3s service file
       file:

+ 9 - 4
terraform/ansible-files/install-k3s-workers.yml

@@ -46,10 +46,15 @@
       when: k3s_agent_service_exists.stat.exists
       ignore_errors: yes
 
-    - name: Kill any running k3s processes
-      shell: pkill -f k3s || true
-      when: k3s_agent_service_exists.stat.exists
-      ignore_errors: yes
+    - name: Check for running k3s processes
+      shell: pgrep -f k3s
+      register: k3s_processes
+      failed_when: false
+      changed_when: false
+
+    - name: Kill running k3s processes if any exist
+      shell: pkill -f k3s
+      when: k3s_processes.rc == 0  # Only run if processes were found
 
     - name: Remove k3s-agent service file
       file: