title: How to replace a directory with a symlink using ansible?
body: <p>I would like to replace <code>/etc/nginx/sites-enabled</code> with a symlink to my repo. I'm trying to do this using <code>file</code> module, but that doesn't work as the file module doesn't remove a directory with force option.</p>
  
  <pre><code>- name: setup nginx sites-available symlink
    file: path=/etc/nginx/sites-available src=/repo/etc/nginx/sites-available state=link force=yes
    notify: restart nginx
  </code></pre>
  
  <p>I could fall back to using shell.</p>
  
  <pre><code>- name: setup nginx sites-available symlink
    shell: test -d /etc/nginx/sites-available &amp;&amp; rm -r /etc/nginx/sites-available &amp;&amp; ln -sT /repo/etc/nginx/sites-available /etc/nginx/sites-available
    notify: restart nginx  
  </code></pre>
  
  <p>Is there any better way to achieve this instead of falling back to shell?</p>