I am attempting to comment out below line using Ansible. I am running into an issue where a comment keeps getting added every time the playbook is run.
How can I change my regexp to ignore the line if already commented out?
- replace:
path: /etc/rsyslog.conf
regexp: '(.*@hostname.*)'
replace: '#\1'
notify:
- Restart rsyslog