Reputation: 13321
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?
Upvotes: 4
Views: 3595
Reputation: 1820
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
Upvotes: 7