Make sshd restart handler multi-distro #4

Merged
hmx merged 1 commit from sjat/make_users:multi-distro-sshd-service into main 2026-07-16 14:01:45 +02:00
Collaborator

The restart handler hardcoded the service name ssh, which only exists on Debian-family distros — on RedHat/Suse/Arch the unit is sshd, so any sshd config change would fail the play there, despite the README describing the role as multi-distribution.

Changes:

  • handlers/main.yaml: restart {{ users_sshd_service_name }} instead of hardcoded ssh.
  • defaults/main.yaml: new users_sshd_service_name default — ssh on Debian family, sshd elsewhere, overridable for exotic distros.
  • tasks/main.yaml: gather minimal facts inside the role when os_family is missing (the play runs with gather_facts: false), tagged always so it also runs under --tags sshd.
  • README.md: one line documenting the auto-detection and override variable.

Verified with ansible-playbook --syntax-check, a test play rendering the name for Debian/RedHat/Suse/Archlinux fact values, and ansible-lint (no findings in touched files).

🤖 Generated with Claude Code

The restart handler hardcoded the service name `ssh`, which only exists on Debian-family distros — on RedHat/Suse/Arch the unit is `sshd`, so any sshd config change would fail the play there, despite the README describing the role as multi-distribution. Changes: - `handlers/main.yaml`: restart `{{ users_sshd_service_name }}` instead of hardcoded `ssh`. - `defaults/main.yaml`: new `users_sshd_service_name` default — `ssh` on Debian family, `sshd` elsewhere, overridable for exotic distros. - `tasks/main.yaml`: gather minimal facts inside the role when `os_family` is missing (the play runs with `gather_facts: false`), tagged `always` so it also runs under `--tags sshd`. - `README.md`: one line documenting the auto-detection and override variable. Verified with `ansible-playbook --syntax-check`, a test play rendering the name for Debian/RedHat/Suse/Archlinux fact values, and `ansible-lint` (no findings in touched files). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sjat added 1 commit 2026-07-16 13:55:16 +02:00
The handler restarted the hardcoded service "ssh", which only exists on
Debian-family distros; on RedHat, Suse, Arch etc. the unit is "sshd",
so any sshd config change would fail there.

Pick the name via a new users_sshd_service_name default keyed off
ansible_facts['os_family'] (overridable for exotic distros). Since
site.yaml runs with gather_facts: false, the role now gathers minimal
facts itself when os_family is missing, tagged always so it also runs
under --tags sshd.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
hmx approved these changes 2026-07-16 14:01:34 +02:00
hmx merged commit 758aebee4b into main 2026-07-16 14:01:45 +02:00
Sign in to join this conversation.
No reviewers
hmx
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hmx/make_users#4
No description provided.