title: Find and Copy a file where the location is not fixed in Ansible
body: <p>I am trying to find and copy files with pattern <code>*-chrony-configuration.yaml</code> from the <code>machineconfig</code> directory to <code>manifests</code> directory.</p>
  <p>The location of the <code>machineconfig</code> varies depending on the user</p>
  <ul>
  <li>if the user is <em>root</em>, the folder is <em>/root/machineconfig</em></li>
  <li>if the user is <em>non-root</em>, the folder is <em>/home/machineconfig</em></li>
  </ul>
  <pre class="lang-yaml prettyprint-override"><code>- name: Find machineconfig files generated from helpernode
    find:
      paths: &quot;machineconfig/&quot;
      patterns: &quot;*-chrony-configuration.yaml&quot;
    register: machine_file
  
  - name: Copy machineconfig files generated from helpernode
    copy:
      src: &quot;{{ item.path }}&quot;
      dest: &quot;{{ workdir }}/manifests&quot;
      remote_src: yes
    with_items:
      - &quot;{{ machine_file.files }}&quot;
  </code></pre>
  <p>The above code errors out giving</p>
  <blockquote>
  <p>&quot;msg&quot;: &quot;machineconfig/ was skipped as it does not seem to be a valid directory or it cannot be accessed\n&quot;</p>
  </blockquote>
  <p>Is there a way in ansible where it finds the path of the file and uses that to produce its copy?</p>