I have a requirement to update /etc/sysct.conf, but then I need to run systemctl -p --system if that is changed.
How can I achieve that in my playbook?
You could do this either by using a handler or registering the task and execute the reload task conditionally. The below snippet shows how to do this by registering file change
- copy:
src: sysctl.conf
dest: /etc/sysctl.conf
owner: root
group: root
register: result
- shell: sysctl -p --system
become: yes
when: result.changed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With