Skip to content

Commit

Permalink
test: restore journald /dev/log after imuxsock test
Browse files Browse the repository at this point in the history
The test makes rsyslog listen to /dev/log.  We have to
restore /dev/log for journald on the systems where
journald listens for /dev/log, by restarting the journald
units.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Feb 23, 2024
1 parent 3f7e418 commit 37cb35d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/tests_imuxsock_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,42 @@

- name: Check ports managed by firewall and selinux
include_tasks: tasks/check_firewall_selinux.yml

- name: Check if /dev/log is present
stat:
path: /dev/log
register: __dev_log

- name: Restore /dev/log by restarting journald units
when: not __dev_log.stat.exists
vars:
__journald_units:
- systemd-journald.service
- systemd-journald.socket
- systemd-journald-dev-log.socket
block:
- name: Stop journald units
service:
name: "{{ item }}"
state: stopped
loop: "{{ __journald_units }}"

- name: Start journald units
service:
name: "{{ item }}"
state: started
loop: "{{ __journald_units }}"

- name: Ensure /dev/log is present
stat:
path: /dev/log
register: __dev_log
failed_when: __dev_log.stat.lnk_target != "/run/systemd/journal/dev-log"
rescue:
- name: Check journal for errors
command: journalctl -ex
changed_when: false

- name: Fail
fail:
msg: "{{ ansible_failed_result }}"

0 comments on commit 37cb35d

Please sign in to comment.