Skip to content

Commit 1a3d0b2

Browse files
Add packagekit stop tasks
1 parent 7b0a83c commit 1a3d0b2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

ansible/playbooks/fully-patch-system.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,46 @@
77
use_reboottimeout: 600
88

99
tasks:
10+
- name: Check if Zypper lock file exists
11+
stat:
12+
path: /var/run/zypp.pid
13+
register: lockfile_check
14+
become: yes
15+
16+
- name: Get PID from Zypper lock file
17+
slurp:
18+
src: /var/run/zypp.pid
19+
register: pid_content
20+
become: yes
21+
when: lockfile_check.stat.exists and lockfile_check.stat.size > 0
22+
23+
- name: Set PID variable
24+
set_fact:
25+
zypper_pid: "{{ (pid_content['content'] | b64decode).strip() }}"
26+
when: lockfile_check.stat.exists and lockfile_check.stat.size > 0
27+
28+
- name: Kill process with the PID
29+
command: kill -9 {{ zypper_pid }}
30+
become: yes
31+
ignore_errors: yes
32+
when: zypper_pid is defined
33+
34+
- name: Wait to confirm the process is dead
35+
command: ps -p {{ zypper_pid }} -o comm=
36+
register: process_check
37+
retries: 5
38+
delay: 2
39+
until: process_check.rc != 0
40+
failed_when: false
41+
when: zypper_pid is defined
42+
43+
- name: Remove stale Zypper lock file
44+
file:
45+
path: /var/run/zypp.pid
46+
state: absent
47+
become: yes
48+
when: lockfile_check.stat.exists and (lockfile_check.stat.size == 0 or zypper_pid is defined)
49+
1050
# Fully patch system
1151
- name: Apply all available patches
1252
community.general.zypper:

0 commit comments

Comments
 (0)