When trying to apply control 3.3.4 in the conditional to check whether 'ufw' is present before restarting the service, the condition will never be able to be assessed as the error is in stderr rather than in stdout. It was constantly failing:
- name: 3.3.4 Ensure suspicious packets are logged | restart ufw after changes in /etc/ufw/sysctl.conf
service:
name: ufw
state: restarted
when:
- UFWEnable
- "'not found' not in ufw_check.stdout"
... thus the last line above should be replaced with the following line, after which it happily skips the control and completes without issues:
- "'not found' not in ufw_check.stderr"
... and some more proof:

When trying to apply control 3.3.4 in the conditional to check whether 'ufw' is present before restarting the service, the condition will never be able to be assessed as the error is in stderr rather than in stdout. It was constantly failing:
service:
name: ufw
state: restarted
when:
- UFWEnable
- "'not found' not in ufw_check.stdout"
... thus the last line above should be replaced with the following line, after which it happily skips the control and completes without issues:
- "'not found' not in ufw_check.stderr"
... and some more proof: