title: How to copy file to local directory using Ansible?
body: <p>I'm trying to set up a playbook that will configure my development system.  I'd like to copy the <code>/etc/hosts</code> file from my playbooks "files" directory to the <code>/etc</code> directory on my system.  Currently I'm doing the following:</p>
  
  <pre><code># main.yml
  - hosts: all
  - tasks:
      - copy: src=files/hosts
              dest=/etc/hosts
              owner=root
              group=wheel
              mode=0644
              backup=true
        become: true
  </code></pre>
  
  
  
  <pre><code># inventory
  localhost   ansible_connection=local
  </code></pre>
  
  <p>When I run the playbook I'm getting this error:</p>
  
  <pre><code>fatal: [localhost]: FAILED! =&gt; {... "msg": Failed to get information on remote file (/etc/hosts): MODULE FAILURE"}
  </code></pre>
  
  <p>I believe this is because copy is supposed to be used to copy a file to a remote file system.  So how do you copy a file to your local management system?  I did a Google Search and everything talks about doing the former.  I didn't see this addressed in the Ansible docs.</p>