Skip to content

Commit

Permalink
test: disable service start limit to avoid errors during testing
Browse files Browse the repository at this point in the history
In some cases running the test gives errors like this:

```
Unable to restart service systemd-journal-flush.service:
Job for systemd-journal-flush.service failed because
start of the service was attempted too often
```

Set `StartLimitIntervalSec=0` to avoid this problem.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Oct 29, 2024
1 parent 67603e4 commit 31a0927
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/tests_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,45 @@
journald_forward_to_syslog: true
journald_rate_limit_burst: 2000
journald_rate_limit_interval_sec: 2
__service_files:
- systemd-journald.service
- systemd-journal-flush.service

tasks:
- name: Run test
block:
- name: Make a copy of the service files
copy:
src: /usr/lib/systemd/system/{{ item }}
dest: /etc/systemd/system/{{ item }}
remote_src: true
mode: preserve
loop: "{{ __service_files }}"

- name: Change the startlimit to avoid errors with excessive journald restarts
lineinfile:
path: /etc/systemd/system/{{ item }}
insertafter: ^\[Unit\]
line: StartLimitIntervalSec=0
loop: "{{ __service_files }}"

- name: Make a copy of the systemd-journald.service
copy:
src: /usr/lib/systemd/system/systemd-journald.service
dest: /etc/systemd/system/systemd-journald.service
remote_src: true
mode: preserve

- name: Change the startlimit to avoid errors with excessive journald restarts
lineinfile:
path: /etc/systemd/system/systemd-journald.service
insertafter: ^\[Unit\]
line: StartLimitIntervalSec=0

- name: Reload systemd to ensure startlimit changes take effect upon restart
systemd:
daemon_reload: true

- name: Run the role
include_role:
name: linux-system-roles.journald
Expand Down Expand Up @@ -109,6 +144,12 @@
path: "{{ __journald_dropin_dir }}/{{ __journald_dropin_conf }}"
state: absent

- name: Remove copy of the service files
file:
path: /etc/systemd/system/{{ item }}
state: absent
loop: "{{ __service_files }}"

- name: Restart journald services
service:
name: "{{ item }}"
Expand Down

0 comments on commit 31a0927

Please sign in to comment.