title: Ansible | Create symlink if directory is empty
body: <p>I have a playbook like this:</p>
  
  <pre><code>---
  - hosts: all
    tasks:
      - name: Create 404 link
        file:
          dest: /var/www/html/{{ item }}/images/index.html
          src: /var/www/html/404.html
          state: link
        with_items:
          - a
          - b
          - c
          - d
          - e
        # when: ???
  ...
  </code></pre>
  
  <p><strong>Now the task should run only if the <code>/var/www/html/{{ item }}/images</code> directory is empty.</strong> How do I get this done? I've tried using the <code>find</code> module and <code>register</code>ing the output but wasn't successful in extracting the items (directories) which had no files in them.</p>