Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ansible tasks to stop zypper #188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions ansible/playbooks/fully-patch-system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,46 @@
use_reboottimeout: 600

tasks:
- name: Check if Zypper lock file exists
stat:
path: /var/run/zypp.pid
register: lockfile_check
become: yes

- name: Get PID from Zypper lock file
slurp:
src: /var/run/zypp.pid
register: pid_content
become: yes
when: lockfile_check.stat.exists and lockfile_check.stat.size > 0

- name: Set PID variable
set_fact:
zypper_pid: "{{ (pid_content['content'] | b64decode).strip() }}"
when: lockfile_check.stat.exists and lockfile_check.stat.size > 0

- name: Kill process with the PID
command: kill -9 {{ zypper_pid }}
become: yes
ignore_errors: yes
when: zypper_pid is defined

- name: Wait to confirm the process is dead
command: ps -p {{ zypper_pid }} -o comm=
register: process_check
retries: 5
delay: 2
until: process_check.rc != 0
failed_when: false
when: zypper_pid is defined

- name: Remove stale Zypper lock file
file:
path: /var/run/zypp.pid
state: absent
become: yes
when: lockfile_check.stat.exists and (lockfile_check.stat.size == 0 or zypper_pid is defined)

# Fully patch system
- name: Apply all available patches
community.general.zypper:
Expand Down