From ed22f6311cca3addef29012b42ddd07f4a5924f9 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 3 Jul 2024 10:30:20 -0500 Subject: [PATCH] r/samba-dc: Auto restart samba Although it's rare, sometimes Samba crashes or fails to start. When this happens, restarting it is almost always enough to get it working again. Since all sorts of authentication problems can occur if one of the domain controllers is down, it's probably best to just have systemd automatically restart _samba.service_ if it ever stops for any reason. --- roles/samba-dc/files/auto-restart.conf | 6 ++++++ roles/samba-dc/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 roles/samba-dc/files/auto-restart.conf diff --git a/roles/samba-dc/files/auto-restart.conf b/roles/samba-dc/files/auto-restart.conf new file mode 100644 index 0000000..3a7ace8 --- /dev/null +++ b/roles/samba-dc/files/auto-restart.conf @@ -0,0 +1,6 @@ +[Unit] +StartLimitIntervalSec=60 +StartLimitBurst=10 + +[Service] +RestartSec=10s diff --git a/roles/samba-dc/tasks/main.yml b/roles/samba-dc/tasks/main.yml index 43ac2d5..01412ce 100644 --- a/roles/samba-dc/tasks/main.yml +++ b/roles/samba-dc/tasks/main.yml @@ -77,6 +77,20 @@ path=/etc/systemd/system/samba.service.d mode=0755 state=directory + tags: + - systemd +- name: ensure samba service auto restart is configurd + copy: + src: auto-restart.conf + dest: /etc/systemd/system/samba.service.d + owner: root + group: root + mode: u=rw,go=r + notify: + - reload systemd + - restart samba + tags: + - systemd - name: ensure samba starts at boot service: