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

test: restore journald /dev/log after imuxsock test #380

Merged
merged 1 commit into from
Feb 26, 2024
Merged
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
47 changes: 47 additions & 0 deletions tests/tests_imuxsock_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,50 @@

- 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
block:
# This is really hacky - but I could not find a reliable way to do this
# that works on older rhel8, newer rhel9, and fedora - each platform has
# odd idiosyncrasies
- name: Restart journald units
shell: |
for service in {{ __journald_units | join(" ") }}; do
if systemctl is-active "$service"; then
systemctl stop "$service" || :
sleep 1
fi
done
for service in {{ __journald_units | join(" ") }}; do
if ! systemctl is-active "$service"; then
systemctl start "$service"
sleep 1
fi
done
changed_when: true
vars:
__journald_units:
- systemd-journald.service
- systemd-journald-dev-log.socket
- systemd-journald.socket

- 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 }}"
Loading