zhong (钟鹏群) 1 月之前
父節點
當前提交
a07e33eae3
共有 2 個文件被更改,包括 18 次插入8 次删除
  1. 9 4
      terraform/ansible-files/install-k3s-master.yml
  2. 9 4
      terraform/ansible-files/install-k3s-workers.yml

+ 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: