1

I found this SO post about copying files between nodes with ansible. Here's the ansible task:

- name: Copy Pipeline files
  synchronize: mode=pull src=/home/ec2-user/nlp/nlp_test/all_data/test/ dest=/opt/nlp-ml/rate/Pipeline dirs=yes
  delegate_to: "{{ ml_ip }}"

I tried it out with my playbook but it failed with the message:

msg: Warning: Identity file /Users/me/me.pem not accessible: No such file or directory.
Permission denied (publickey).

This makes sense as my identity file is stored locally and not on a remote machine. However, the source node's public key has been distributed to the target node. How can I get around this?

Edit: I tried adding the destination node's public key to the source node. I then added use_ssh_args=yes to the synchronize task. After that I added ssh_args = -i /home/ec2-user/.ssh/id_rsa (the location of the private key on both the source and destination nodes) to ansible.cfg. Same issue.

Community
  • 1
  • 1
cscan
  • 3,684
  • 9
  • 45
  • 83
  • @vvchik I've just updated the answer to show the ansible task - I originally didn't included it because it was so close to the other SO post. – cscan Apr 19 '16 at 20:07
  • 1
    is `ml_ip` source server or destination? try to remove `mode=pull` in your task – vvchik Apr 19 '16 at 20:22

1 Answers1

1

So in order to do this it requires a combination of the things that I tried. @vvchik suggested that I try removing mode=pull, which didn't work initially. However, when combined with use_ssh_args, I was able to get it working. For any who would like the full solution, here it is:

Generate a ssh key on the source node (in the default location and without a password) and install it on the destination nodes. Add this task:

- name: Copy files from source to destination
  synchronize: src=source dest=destination dirs=yes use_ssh_args=yes
  delegate_to: "{{ source_ip }}"

Finally, in ansible.cfg add ssh_args = -i /home/user/.ssh/id_rsa. ansible.cfg should be in the current directory.

cscan
  • 3,684
  • 9
  • 45
  • 83