ansible-infra/roles/deploy_ssh_server_config/tasks/main.yaml
June 3548c1f4d6
All checks were successful
/ Ansible Lint (push) Successful in 2m9s
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.
2025-04-25 02:01:29 +02:00

34 lines
971 B
YAML

# Role and config created after: https://infosec.mozilla.org/guidelines/openssh
- name: deploy SSH server config
become: true
block:
- name: deploy `sshd_config`
ansible.builtin.template:
force: true
dest: /etc/ssh/sshd_config
mode: "0644"
owner: root
group: root
src: sshd_config.j2
notify:
- restart the ssh service
- name: deactivate short moduli
ansible.builtin.shell:
executable: /bin/bash
cmd: |
set -eo pipefail
awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.tmp
if diff /etc/ssh/moduli /etc/ssh/moduli.tmp; then
rm /etc/ssh/moduli.tmp
else
mv /etc/ssh/moduli.tmp /etc/ssh/moduli
echo "ansible-changed: changed /etc/ssh/moduli"
fi
register: result
changed_when:
- '"ansible-changed" in result.stdout'
notify:
- restart the ssh service