Let’s say I have a playbook that looks for and changes lines in sshd_config if necessary. Then I want the sshd service to be restarted only if at least one of those actions has taken place. Is there a way to evaluate for that without registering a variable for the completion of each and every play?
In the specific case of modifying one file only, multiple times, you could get away with one register for the original modification timestamp, and then compare that timestamp with the current timestamp as your last operation.
In the general case, I think you need to use a register with a boolean for each operation that can trigger your final action.
Thanks, Spike. That’s what I’ll do. That, or a hash.
Check out handlers and notify.
https://docs.ansible.com/ansible/playbooks_intro.html#handlers-running-operations-on-change
Darn it, I forgot all about handlers!