title: How to write an Ansible role task that only runs when any of the previous other tasks in the task file have been changed?
body: <p>I am working on a role where I want one task to be run at the end of the tasks file if and only if <strong>any</strong> of the previous tasks in that task file have changed.</p>
  
  <p>For example, I have:</p>
  
  <pre><code>- name: install package
    apt: name=mypackage state=latest
  
  - name: modify a file
    lineinfile: do stuff
  
  - name: modify a second file
    lineinfile: other stuff
  
  - name: restart if anything changed
    service: name=mypackage state=restarted
  </code></pre>
  
  <p>... and I want to only restart the service if an update has been installed or any of the config files have been changed. </p>
  
  <p>How can I do this?</p>