ssh: Ensure ssh enabled, use ssh.service unit on debian
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- name: Restart sshd
|
||||
- name: Restart ssh service
|
||||
ansible.builtin.systemd_service:
|
||||
name: sshd.service
|
||||
name: "{{ _ssh_service_name }}"
|
||||
state: restarted
|
||||
|
||||
@@ -6,8 +6,13 @@
|
||||
line: "{{ item.key }} {{ item.value }}"
|
||||
state: present
|
||||
validate: '/usr/sbin/sshd -t -f %s'
|
||||
notify: Restart sshd
|
||||
notify: Restart ssh service
|
||||
with_dict:
|
||||
PermitRootLogin: "prohibit-password"
|
||||
PasswordAuthentication: "{{ 'yes' if ssh_password_auth else 'no' }}"
|
||||
X11Forwarding: "no"
|
||||
|
||||
- name: Ensure ssh service is enabled
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ _ssh_service_name }}"
|
||||
enabled: true
|
||||
|
||||
2
roles/ssh/vars/main.yaml
Normal file
2
roles/ssh/vars/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
_ssh_service_name: "{{ 'ssh.service' if ansible_facts.os_family == 'Debian' else 'sshd.service' }}"
|
||||
Reference in New Issue
Block a user