Conditional when any of several tasks has been done

28 views
Skip to first unread message

John Oliver

unread,
Dec 12, 2016, 2:06:18 PM12/12/16
to Ansible Project
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?

Spike Robinson

unread,
Dec 12, 2016, 2:15:37 PM12/12/16
to Ansible Project
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. 

John Oliver

unread,
Dec 12, 2016, 2:50:45 PM12/12/16
to Ansible Project
Thanks, Spike.  That's what I'll do.  That, or a hash.

Kai Stian Olstad

unread,
Dec 12, 2016, 3:02:36 PM12/12/16
to ansible...@googlegroups.com

John Oliver

unread,
Dec 12, 2016, 4:12:48 PM12/12/16
to Ansible Project, ansible-pr...@olstad.com
Darn it, I forgot all about handlers!
Reply all
Reply to author
Forward
0 new messages