title: Path to stat module via dict variable
body: <p>I want to register status of a file with the <a href="https://docs.ansible.com/ansible/latest/modules/stat_module.html" rel="nofollow noreferrer">stat</a> module so that I can set permissions if it exists.</p>
  
  <p>In the following tasks, I send variables to the cron and file modules. What is a good way to make those same variables available to the <code>stat</code> module, or what is an alternate method of checking for the existence of a file based on <code>dict</code> variables?</p>
  
  <pre><code>- name: Task One
    cron:
      name: "{{ item.key }} nightly S3 backup"
      minute: "0"
      hour: "12"
      user: "{{ web_user }}"
      job: "cd {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/scripts &amp;&amp; ./backup-to-s3.sh &gt; /dev/null 2&gt;&amp;1"
      cron_file: "backup-nightly-{{ item.key | replace('.', '_') }}"
    with_dict: "{{ my_dictionary }}"
  
  - name: Task Two
    stat:
      path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/scripts/backup-to-s3.sh"
      register: stat_result
  
  - name: Task Three
    file:
      path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/scripts/backup-to-s3.sh"
      owner: "{{ web_user }}"
      group: "{{ web_group }}"
      mode: 0755
    when: stat_result.stat.exists == True
    with_dict: "{{ my_dictionary }}"
  
  my_dictionary:
    example.com:
      site_hosts:
        - canonical: example.com
      local_path: ../example.com
      env:
        db_prefix: my_
  </code></pre>
  
  <p>I am thinking maybe <code>with_items</code> will be at at least part of the solution.</p>