title: ansible - delete unmanaged files from directory?
body: <p>I want to recursively copy over a directory <strong>and</strong> render all <em>.j2</em> files in there as templates. For this I am currently using the following lines:</p>
  <pre class="lang-yaml prettyprint-override"><code>- template: &gt;
              src=/src/conf.d/{{ item }}
              dest=/dest/conf.d/{{ item|replace('.j2','') }}
    with_lines: find /src/conf.d/ -type f -printf &quot;%P\n&quot;
  </code></pre>
  <p>Now I'm looking for a way to remove unmanaged files from this directory. For example if I remove a file/template from <code>/src/conf.d/</code> I want Ansible to remove it from <code>/dest/conf.d/</code> as well.</p>
  <p>Is there some way to do this? I tried fiddling around with <code>rsync --delete</code>, but there I got a problem with the templates which get their suffix <code>.j2</code> removed.</p>