zhong (钟鹏群) 1 kuukausi sitten
vanhempi
commit
dbfd13dd1b
1 muutettua tiedostoa jossa 6 lisäystä ja 5 poistoa
  1. 6 5
      cluster-setup/ansible-files/install-k3s-workers.yml

+ 6 - 5
cluster-setup/ansible-files/install-k3s-workers.yml

@@ -47,14 +47,15 @@
       ignore_errors: yes
 
     - name: Check for running k3s processes
-      shell: pgrep -f k3s
-      register: k3s_processes
-      failed_when: false
+      shell: ps aux | grep '[k]3s' | awk '{print $2}' || true
+      register: k3s_pids
       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
+      shell: "kill {{ item }}"
+      loop: "{{ k3s_pids.stdout_lines }}"
+      when: k3s_pids.stdout != ""
+      ignore_errors: yes
 
     - name: Remove k3s-agent service file
       file: