Fix handlers
This commit is contained in:
@@ -1,7 +1,18 @@
|
|||||||
---
|
---
|
||||||
- name: "Restart sshd"
|
- name: "Restart the ssh service"
|
||||||
|
listen: "Restart ssh"
|
||||||
|
when: ansible_os_family == 'Debian'
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: ssh
|
name: ssh
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: true
|
enabled: true
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: "Restart the sshd service"
|
||||||
|
listen: "Restart ssh"
|
||||||
|
when: ansible_os_family == 'RedHat'
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: sshd
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: true
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# NOTE: order of preference for openssh-server ed25519 -> rsa
|
# NOTE: order of preference for openssh-server ed25519 -> rsa
|
||||||
- name: "Algorithms | enable ed25519 authentication algorithm"
|
- name: "Algorithms | enable ed25519 authentication algorithm"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^HostKey /etc/ssh/ssh_host_ed25519_key'
|
regexp: '^HostKey /etc/ssh/ssh_host_ed25519_key'
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
validate: sshd -f %s -t
|
validate: sshd -f %s -t
|
||||||
|
|
||||||
- name: "Algorithms | enable the RSA authentication algorithm"
|
- name: "Algorithms | enable the RSA authentication algorithm"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^HostKey /etc/ssh/ssh_host_rsa_key'
|
regexp: '^HostKey /etc/ssh/ssh_host_rsa_key'
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
validate: sshd -f %s -t
|
validate: sshd -f %s -t
|
||||||
|
|
||||||
- name: "Algorithms | disable the ECDSA algorithm (deemed to be less safe)"
|
- name: "Algorithms | disable the ECDSA algorithm (deemed to be less safe)"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^HostKey /etc/ssh/ssh_host_ecdsa_key'
|
regexp: '^HostKey /etc/ssh/ssh_host_ecdsa_key'
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
validate: sshd -f %s -t
|
validate: sshd -f %s -t
|
||||||
|
|
||||||
- name: "Algorithms | disable the DSA algorithm (considered to be defunct)"
|
- name: "Algorithms | disable the DSA algorithm (considered to be defunct)"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^HostKey /etc/ssh/ssh_host_dsa_key'
|
regexp: '^HostKey /etc/ssh/ssh_host_dsa_key'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: "Authentication | Configure SSH authentication settings"
|
- name: "Authentication | Configure SSH authentication settings"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
loop:
|
loop:
|
||||||
- { regexp: '^#?\s*PubkeyAuthentication\s+', line: 'PubkeyAuthentication yes' }
|
- { regexp: '^#?\s*PubkeyAuthentication\s+', line: 'PubkeyAuthentication yes' }
|
||||||
- { regexp: '^#?\s*PasswordAuthentication\s+', line: 'PasswordAuthentication {{ sshd_password_auth | ternary("yes", "no") }}' }
|
- { regexp: '^#?\s*PasswordAuthentication\s+', line: 'PasswordAuthentication {{ sshd_password_auth | ternary("yes", "no") }}' }
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
- name: "Authentication | override password authentication by cloud-init to '{{ sshd_password_auth | ternary('yes', 'no') }}'"
|
- name: "Authentication | override password authentication by cloud-init to '{{ sshd_password_auth | ternary('yes', 'no') }}'"
|
||||||
when: sshd_cloud_init.stat.exists
|
when: sshd_cloud_init.stat.exists
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
path: "/etc/ssh/sshd_config.d/50-cloud-init.conf"
|
||||||
regexp: '^#?PasswordAuthentication'
|
regexp: '^#?PasswordAuthentication'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
- /etc/ssh/ssh_host_ecdsa_key.pub
|
- /etc/ssh/ssh_host_ecdsa_key.pub
|
||||||
- /etc/ssh/ssh_host_dsa_key
|
- /etc/ssh/ssh_host_dsa_key
|
||||||
- /etc/ssh/ssh_host_dsa_key.pub
|
- /etc/ssh/ssh_host_dsa_key.pub
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
ansible.builtin.include_tasks: "whitelists.yml"
|
ansible.builtin.include_tasks: "whitelists.yml"
|
||||||
|
|
||||||
- name: "Log at VERBOSE level"
|
- name: "Log at VERBOSE level"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?LogLevel'
|
regexp: '^#?LogLevel'
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
validate: /usr/sbin/sshd -t -f %s
|
validate: /usr/sbin/sshd -t -f %s
|
||||||
|
|
||||||
- name: "Restrictions | toggle PAM"
|
- name: "Restrictions | toggle PAM"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?UsePAM'
|
regexp: '^#?UsePAM'
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
validate: sshd -f %s -t
|
validate: sshd -f %s -t
|
||||||
|
|
||||||
- name: "Restrictions | ensure the SSHD config is restricted to the root user"
|
- name: "Restrictions | ensure the SSHD config is restricted to the root user"
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
owner: root
|
owner: root
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: "Configure AllowUsers"
|
- name: "Configure AllowUsers"
|
||||||
when: sshd_allow_users is defined
|
when: sshd_allow_users is defined
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?\s*AllowUsers\s+'
|
regexp: '^#?\s*AllowUsers\s+'
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
- name: "Configure AllowGroups"
|
- name: "Configure AllowGroups"
|
||||||
when: sshd_allow_groups is defined
|
when: sshd_allow_groups is defined
|
||||||
notify: Restart sshd
|
notify: "Restart ssh"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?\s*AllowGroups\s+'
|
regexp: '^#?\s*AllowGroups\s+'
|
||||||
|
|||||||
Reference in New Issue
Block a user