report changed properly for "deactivate short moduli" task
All checks were successful
/ Ansible Lint (pull_request) Successful in 1m34s
/ Ansible Lint (push) Successful in 1m32s

This fixes the ansible-lint no-changed-when complaint and also allows to
notify the reboot handler.
This commit is contained in:
June 2024-12-01 22:20:15 +01:00
parent e3a29c422a
commit e6d6d9eed0
Signed by: june
SSH key fingerprint: SHA256:o9EAq4Y9N9K0pBQeBTqhSDrND5E7oB+60ZNx0U1yPe0

View file

@ -17,4 +17,20 @@
- name: deactivate short moduli
ansible.builtin.shell:
cmd: awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.tmp && mv /etc/ssh/moduli.tmp /etc/ssh/moduli
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:
# Reboot instead of just restarting the ssh service, since I don't know how Ansible reacts, when it restarts the service it probably needs for the connection.
- reboot the system