# Cant Copy Files

**URL:** <https://forum.ansible.com/t/cant-copy-files/19032>\
**Category:** Ansible Project\
**Created:** [August 16, 2015, 11:34pm UTC](https://forum.ansible.com/t/cant-copy-files/19032 "2015-08-16T23:34:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [August 16, 2015, 11:34pm UTC](https://forum.ansible.com/t/cant-copy-files/19032/1 "2015-08-16T23:34:15Z")

</div>

I must be missing something really obvious but cant seem to manage copying a repo file in place. The playbook is so simple I am not sure where to start. Here is the output of some -vvvv action:

> > > [root@localhost ansible]# ansible-playbook -vvvv -i hosts-test.ini playbook-sensu.yml
> > 
> > > 
> > 
> > > PLAY [sensu-server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> > 
> > > 
> > 
> > > GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> > 
> > > \<192.168.110.64\> ESTABLISH CONNECTION FOR USER: centos
> > 
> > > \<192.168.110.64\> REMOTE\_MODULE setup
> > 
> > > \<192.168.110.64\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o StrictHostKeyChecking=no -o IdentityFile=“/root/.ssh/machine.pem” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127 && echo $HOME/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127’
> > 
> > > \<192.168.110.64\> PUT /tmp/tmpvRMQe1 TO /home/centos/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127/setup
> > 
> > > \<192.168.110.64\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o StrictHostKeyChecking=no -o IdentityFile=“/root/.ssh/machine.pem” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=jynbxwsfdeohvvupaxefxoirnkumswgr] password: " -u root /bin/sh -c '”’“‘echo BECOME-SUCCESS-jynbxwsfdeohvvupaxefxoirnkumswgr; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/centos/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127/setup; rm -rf /home/centos/.ansible/tmp/ansible-tmp-1439752997.23-250870364991127/ \>/dev/null 2\>&1’”‘"’’
> > 
> > > ok: [192.168.110.64]
> > 
> > > 
> > 
> > > TASK: [sensu | Copy Sensu Repo configuration file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> > 
> > > \<192.168.110.64\> ESTABLISH CONNECTION FOR USER: centos
> > 
> > > \<192.168.110.64\> REMOTE\_MODULE file src=sensu.repo dest=/etc/yum.repos.d/sensu.repo owner=root group=root
> > 
> > > \<192.168.110.64\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o StrictHostKeyChecking=no -o IdentityFile=“/root/.ssh/machine.pem” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734 && echo $HOME/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734’
> > 
> > > \<192.168.110.64\> PUT /tmp/tmpqYdiro TO /home/centos/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734/file
> > 
> > > \<192.168.110.64\> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=“/root/.ansible/cp/ansible-ssh-%h-%p-%r” -o StrictHostKeyChecking=no -o IdentityFile=“/root/.ssh/machine.pem” -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 192.168.110.64 /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=zttsegrxwbsozarymjbqavsmkvrbbbkn] password: " -u root /bin/sh -c '”’“‘echo BECOME-SUCCESS-zttsegrxwbsozarymjbqavsmkvrbbbkn; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /home/centos/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734/file; rm -rf /home/centos/.ansible/tmp/ansible-tmp-1439752998.61-257891007893734/ \>/dev/null 2\>&1’”‘"’’
> > 
> > > failed: [192.168.110.64] =\> {“failed”: true, “path”: “/etc/yum.repos.d/sensu.repo”, “state”: “absent”}
> > 
> > > msg: file (/etc/yum.repos.d/sensu.repo) is absent, cannot continue
> > 
> > > 
> > 
> > > FATAL: all hosts have already failed – aborting
> > 
> > > 
> > 
> > > PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> > 
> > > to retry, use: --limit @/root/playbook-sensu.retry
> > 
> > > 
> > 
> > > 192.168.110.64 : ok=1 changed=0 unreachable=0 failed=1

Relevant ansible.cfg file:

> [root@localhost ansible]# cat ansible.cfg

> [defaults]

> host\_key\_checking = False

> remote\_user = centos

> sudo = true

> private\_key\_file=~/.ssh/machine.pem

> 

This is a CentOS 7.1 machine if it makes any difference. Any ideas?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 16, 2015, 11:46pm UTC](https://forum.ansible.com/t/cant-copy-files/19032/2 "2015-08-16T23:46:44Z")

</div>

it would help if you showed the play, as it stands it seems copy  
cannot find the file.

Brian Coca

---

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [August 17, 2015, 4:31am UTC](https://forum.ansible.com/t/cant-copy-files/19032/3 "2015-08-17T04:31:20Z")

</div>

sure thing. I have a standard dir structure laid out:

```auto
hosts-test.ini
playbook-sensu.yml

```

```auto
roles/
    sensu/
        tasks/
            main.yml
        templates/
        files/
            sensu.repo

```

```auto
I call as:

```

```auto
ansible-playbook -vvvv -i hosts-test.ini playbook-sensu.yml

```

```auto

> ---

> 

> - name: Copy Sensu Repo configuration file

> file: src=sensu.repo dest=/etc/yum.repos.d/sensu.repo owner=root group=root

> 

> - name: Install Sensu and Dependencies

> yum: name={{ item }} state=latest

> with_items:

> - erlang

> - redis

> - sensu

> 

> - name: Install rabbitmq

> yum: name=[https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.4/rabbitmq-server-3.5.4-1.noarch.rpm](https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.4/rabbitmq-server-3.5.4-1.noarch.rpm) state=present

> 

> - name: Ensure RabbitMQ running and starts during boot

> service: name=rabbitmq-server enabled=yes state=restarted

> 

> - name: create rabbitmq vhost by hand

> rabbitmq_vhost: name=/sensu state=present 

> 

> - name: create rabbitmq stuff by hand

> rabbitmq_user: user=sensu password=sensu vhost=/sensu configure_priv=.* read_priv=.* write_priv=.*

> 

> - name: ensure redis is up and starts on boot

> service: name=redis enabled=yes state=started

> 

> - name: Copy Sensu config.json

> file: src=sensu-server-config.json dest=/etc/sensu/config.json

> 

> - name: Copy memcheck

> file: src=check_memory.json dest=/etc/sensu/conf.d/check_memory.json

> 

> - name: Copy default_handler

> file: src=default_handler.json dest=/etc/sensu/conf.d/default_handler.json

> 

> - name: Ensure sensu owns files

> file: path=/etc/sensu owner=sensu group=sensu recurse=yes

> 

> - name: Start sensu services

> service: name={{ item }} enabled=yes state=started

> with_items:

> - sensu

> - sensu-api

If I comment out the repo copy it continues on until the other copies fail. Those files are there, just didnt type them out above. Thanks for the help

```

```auto

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 17, 2015, 4:33am UTC](https://forum.ansible.com/t/cant-copy-files/19032/4 "2015-08-17T04:33:01Z")

</div>

you are using the file module, when you mean to use the copy module,  
change the task to this:

- name: Copy Sensu Repo configuration file  
&nbsp;&nbsp;copy: src=sensu.repo dest=/etc/yum.repos.d/sensu.repo owner=root group=root

---

<div class="post-metadata">

**Author:** ![John\_Favorite](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@John\_Favorite](https://forum.ansible.com/u/John_Favorite)\
**Post date:** [August 17, 2015, 4:49am UTC](https://forum.ansible.com/t/cant-copy-files/19032/5 "2015-08-17T04:49:38Z")

</div>

awesome. that was it. thanks much!
