# Problems with copy module

**URL:** <https://forum.ansible.com/t/problems-with-copy-module/13848>\
**Category:** Ansible Project\
**Created:** [November 5, 2013, 11:01am UTC](https://forum.ansible.com/t/problems-with-copy-module/13848 "2013-11-05T11:01:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![igor.masen](https://avatars.discourse-cdn.com/v4/letter/i/e36b37/32.png) [@igor.masen](https://forum.ansible.com/u/igor.masen)\
**Post date:** [November 5, 2013, 11:01am UTC](https://forum.ansible.com/t/problems-with-copy-module/13848/1 "2013-11-05T11:01:16Z")

</div>

I have a problem with the ansible copy module.

We have a ansible-repository which I checked out on machine “A” and I have a second machine where I want to install jenkins, “B”. So I start ansible-playbook like this on machine “A”:

ansible-playbook -i integration jenkinsservers.yml --ask-pass -s

In my jenkins role I defined a task which should copy an private and a public key from machine “A” into the .ssh directory of the application-user on machine “B”:

- name: create ssh directory for user ${app\_name}  
file: path=/home/${app\_name}/.ssh owner=${app\_name} group=${app\_name} state=directory

- name: copy ${app\_name} private key into place  
file: src=id\_rsa dest=/home/${app\_name}/.ssh/id\_rsa owner=${app\_name} group=${app\_name} mode=600

- name: copy ${app\_name} public key into place  
file: src=id\_rsa.pub dest=/home/${app\_name}/.ssh/id\_rsa.pub owner=${app\_name} group=${app\_name} mode=640

But when I run this, I get the following error:

TASK: [copy jenkins public key into place] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [v00684.sbb.ch] =\> {“failed”: true, “item”: “”, “path”: “/home/jenkins/.ssh/id\_rsa.pub”, “state”: “absent”}  
msg: file (/home/jenkins/.ssh/id\_rsa.pub) does not exist, use copy or template module to create

FATAL: all hosts have already failed – aborting

On the machine “B” I can see the directory, but no content.

PS: Ansible Version 1.3.3.

What I am doing wrong?

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [November 5, 2013, 2:46pm UTC](https://forum.ansible.com/t/problems-with-copy-module/13848/2 "2013-11-05T14:46:40Z")

</div>

I would advise adding a shell command in your playbook to verify the host and content …

- shell: hostname ; whoami; pwd ; ls -al /home/jenkins

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [November 6, 2013, 1:03am UTC](https://forum.ansible.com/t/problems-with-copy-module/13848/3 "2013-11-06T01:03:20Z")

</div>

first i would use the authorized\_key module to do all in 1 step.

I think you misunderstand what is happening in these 2 tasks:

> - name: copy ${app\_name} private key into place

> file: src=id\_rsa dest=/home/${app\_name}/.ssh/id\_rsa owner=${app\_name} \>group=${app\_name} mode=600
> 
> - name: copy ${app\_name} public key into place  
> file: src=id\_rsa.pub dest=/home/${app\_name}/.ssh/id\_rsa.pub owner=${app\_name} \>group=${app\_name} mode=640

they are NOT copying the file, you need to use the copy module for this.

---

<div class="post-metadata">

**Author:** ![igor.masen](https://avatars.discourse-cdn.com/v4/letter/i/e36b37/32.png) [@igor.masen](https://forum.ansible.com/u/igor.masen)\
**Post date:** [November 6, 2013, 1:08pm UTC](https://forum.ansible.com/t/problems-with-copy-module/13848/4 "2013-11-06T13:08:34Z")

</div>

Hello Brian

Thank’s for the tip with the module, I will use it.

Your second tip helped me with the copy operation. I was confused of the word copy in the “name:”-line, so I didn’t noticed the mistake.
