From 3548c1f4d6763b2a2f53201603a9d1917a7951a8 Mon Sep 17 00:00:00 2001
From: June <june@jsts.xyz>
Date: Fri, 25 Apr 2025 02:01:29 +0200
Subject: [PATCH] restart ssh service instead of rebooting as this should be
 fine

Active connections should survive a restart of the service and testing
also didn't show any issues.
---
 inventories/chaosknoten/hosts.yaml                | 3 +++
 roles/deploy_ssh_server_config/handlers/main.yaml | 6 ++++--
 roles/deploy_ssh_server_config/tasks/main.yaml    | 6 ++----
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/inventories/chaosknoten/hosts.yaml b/inventories/chaosknoten/hosts.yaml
index 1f5b31b..92185ed 100644
--- a/inventories/chaosknoten/hosts.yaml
+++ b/inventories/chaosknoten/hosts.yaml
@@ -174,3 +174,6 @@ netbox_hosts:
 proxmox_vm_template_hosts:
   hosts:
     chaosknoten:
+ansible_pull_hosts:
+  hosts:
+    netbox:
diff --git a/roles/deploy_ssh_server_config/handlers/main.yaml b/roles/deploy_ssh_server_config/handlers/main.yaml
index 001bbe4..721a348 100644
--- a/roles/deploy_ssh_server_config/handlers/main.yaml
+++ b/roles/deploy_ssh_server_config/handlers/main.yaml
@@ -1,3 +1,5 @@
-- name: reboot the system
+- name: restart the ssh service
+  ansible.builtin.systemd:
+    name: ssh.service
+    state: restarted
   become: true
-  ansible.builtin.reboot:
diff --git a/roles/deploy_ssh_server_config/tasks/main.yaml b/roles/deploy_ssh_server_config/tasks/main.yaml
index f5d00f5..4350790 100644
--- a/roles/deploy_ssh_server_config/tasks/main.yaml
+++ b/roles/deploy_ssh_server_config/tasks/main.yaml
@@ -12,8 +12,7 @@
         group: root
         src: sshd_config.j2
       notify:
-        # Reboot instead of just restarting the ssh service, since I don't know how Ansible reacts, when it restarts the service it probably needs for the connection.
-        - reboot the system
+        - restart the ssh service
 
     - name: deactivate short moduli
       ansible.builtin.shell:
@@ -32,5 +31,4 @@
       changed_when:
         - '"ansible-changed" in result.stdout'
       notify:
-        # Reboot instead of just restarting the ssh service, since I don't know how Ansible reacts, when it restarts the service it probably needs for the connection.
-        - reboot the system
+        - restart the ssh service