diff --git a/tasks/rosetta/configure_nfs_monitoring.yml b/tasks/rosetta/configure_nfs_monitoring.yml index 76c5ef2b6da7e0c0014ef1c9c5d5f87bfa9acfc7..643c25c7d1e1ea3994643fe12244569ff78d50e2 100644 --- a/tasks/rosetta/configure_nfs_monitoring.yml +++ b/tasks/rosetta/configure_nfs_monitoring.yml @@ -20,7 +20,7 @@ loop: - "nfs_timeout_notification.service.sh" - - name: install NFS monitoring services (2/3) - copy service unit + - name: install NFS monitoring services (2/3) - copy service units & timers ansible.builtin.template: src: "usr/local/lib/systemd/system/{{ item }}.j2" dest: "/usr/local/lib/systemd/system/{{ item }}" @@ -29,13 +29,19 @@ group: "root" loop: - "nfs_timeout_notification.service" + - "nfs_timeout_notification_stop.service" + - "nfs_timeout_notification_start.timer" + - "nfs_timeout_notification_stop.timer" notify: daemon-reload - - name: install NFS monitoring services (3/3) - enable service + - name: install NFS monitoring services (3/3) - enable services & timers ansible.builtin.systemd_service: name: "{{ item.name }}" enabled: "{{ item.enabled | default(true) }}" state: "{{ item.state | default('started') }}" daemon_reload: true loop: - - name: "nfs_timeout_notification.service" + - { name: "nfs_timeout_notification.service" } + - { name: "nfs_timeout_notification_stop.service", state: "stopped" } + - { name: "nfs_timeout_notification_start.timer" } + - { name: "nfs_timeout_notification_stop.timer" } \ No newline at end of file diff --git a/templates/usr/local/lib/systemd/system/nfs_timeout_notification_start.timer.j2 b/templates/usr/local/lib/systemd/system/nfs_timeout_notification_start.timer.j2 new file mode 100644 index 0000000000000000000000000000000000000000..48e1a58cc68aab0e23019a7d50999827a75f513d --- /dev/null +++ b/templates/usr/local/lib/systemd/system/nfs_timeout_notification_start.timer.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=timer for nfs_timeout_notification.service + +[Timer] +# run on the 1st Tuesday of each month +# You can validate your calendar expressions using `systemd-analyze calendar EXPR`. +# Of course, the expression we use on our Debian systems won't work on the +# jurassic RHEL versions of systemd 219, because the ".." syntax for timespans +# in calendar events isn't supported yet. Instead, we have to use the older +# syntax that explicitly lists all days separated by commas. +# One more reason for RHEL to fuck ALL THE WAY OFF! +# OnCalendar=Tue *-*-01..07 08:00:00 # NOT THIS on RHEL 7! +OnCalendar=Tue *-*-01,02,03,04,05,06,07 15:00:00 +Unit=nfs_timeout_notification.service + +[Install] +WantedBy=default.target diff --git a/templates/usr/local/lib/systemd/system/nfs_timeout_notification_stop.service.j2 b/templates/usr/local/lib/systemd/system/nfs_timeout_notification_stop.service.j2 new file mode 100644 index 0000000000000000000000000000000000000000..a10d9af8b74bc28c8d23e11532065d82780e9a48 --- /dev/null +++ b/templates/usr/local/lib/systemd/system/nfs_timeout_notification_stop.service.j2 @@ -0,0 +1,36 @@ +[Unit] +Description=stop monitor journal for NFS timeouts and notify staff +After=remote-fs.target +Conflicts=nfs_timeout_notification.service + +[Service] +Type=simple +Restart=no +ExecStart=/usr/bin/true +User={{ vault_nfs_timeout_notification_service.owner }} +Group={{ vault_nfs_timeout_notification_service.group }} + +### Security features +# documented at https://www.freedesktop.org/software/systemd/man/systemd.exec.html +# or at `man (5) systemd.exec` +ProtectSystem=full +ProtectHome=read-only +#ProtectHostname=true +#ProtectClock=true +#ProtectKernelTunables=true +#ProtectKernelModules=true +#ProtectKernelLogs=true +#ProtectControlGroups=true +#LockPersonality=true +#MemoryDenyWriteExecute=true +#RestrictRealtime=true +#RestrictSUIDSGID=true +## RemoveIPC=true +## PrivateMounts=true +## MountFlags= +## SystemCallFilter is a Whitelist!!! +#SystemCallFilter=@debug,@file-system +#SystemCallErrorNumber=1337 + +[Install] +WantedBy=multi-user.target diff --git a/templates/usr/local/lib/systemd/system/nfs_timeout_notification_stop.timer.j2 b/templates/usr/local/lib/systemd/system/nfs_timeout_notification_stop.timer.j2 new file mode 100644 index 0000000000000000000000000000000000000000..6cd58041a27f3e9de1460dc74406ffcba06d6542 --- /dev/null +++ b/templates/usr/local/lib/systemd/system/nfs_timeout_notification_stop.timer.j2 @@ -0,0 +1,17 @@ +[Unit] +Description=timer for nfs_timeout_notification_stop.service + +[Timer] +# run on the 1st Tuesday of each month +# You can validate your calendar expressions using `systemd-analyze calendar EXPR`. +# Of course, the expression we use on our Debian systems won't work on the +# jurassic RHEL versions of systemd 219, because the ".." syntax for timespans +# in calendar events isn't supported yet. Instead, we have to use the older +# syntax that explicitly lists all days separated by commas. +# One more reason for RHEL to fuck ALL THE WAY OFF! +# OnCalendar=Tue *-*-01..07 08:00:00 # NOT THIS on RHEL 7! +OnCalendar=Tue *-*-01,02,03,04,05,06,07 07:55:00 +Unit=nfs_timeout_notification.service + +[Install] +WantedBy=default.target