19 lines
562 B
YAML
19 lines
562 B
YAML
---
|
|
- name: Ensure sshd config options set correctly
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/ssh/sshd_config
|
|
regexp: "^#?{{ item.key }} .*$"
|
|
line: "{{ item.key }} {{ item.value }}"
|
|
state: present
|
|
validate: '/usr/sbin/sshd -t -f %s'
|
|
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
|