Hi,
I am new to Ansible, and I use Ansible 2.0.1.0 on CentOS 6.x.
I need to copy a file from ServerA to Serverb (both are remote systems). I
used following code block.
Ansible host, ServerA, ServerB has same private key /root/.ssh/mykey.pem.
each /root/myfile.txt file has just one line.
- name: Write to myfile.txt in host
synchronize: mode=pull src=/root/myfile.txt dest=/root/myfile.txt
delegate_to: serverb
register: file_copied
In my inventory file I have following entries as well.
[servera]
*<ServerA_IP>* ansible_ssh_private_key_file=/root/.ssh/mykey.pem
[serverb]
*<ServerB_IP>* ansible_ssh_private_key_file=/root/.ssh/mykey.pem
When I run the playbook I get following error.
fatal: [*<ServerA_IP>* -> *<ServerB_IP>*]: FAILED! => {"changed": false,
"cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh
'/usr/bin/ssh -i /root/.ssh/ap-southeast-1-20130927.pem -S none -o
StrictHostKeyChecking=no' --out-format='<<CHANGED>>%i %n%L'
\"*<ServerA_IP>*:/root/read.txt\"
\"/root/read.txt\"", "failed": true, "invocation": {"module_args":
{"_local_rsync_path": "rsync", "_substitute_controller": false, "archive":
true, "checksum": false, "compress": true, "copy_links": null, "delete":
false, "dest": "/root/read.txt", "dest_port": 22, "dirs": false,
"existing_only": false, "group": null, "links": null, "mode": "pull",
"owner": null, "partial": false, "perms": null, "private_key":
"/root/.ssh/mykey.pem", "recursive": null, "rsync_opts": null,
"rsync_path": null, "rsync_timeout": 0, "set_remote_user": true, "src": "
*<ServerA_IP>*:/root/read.txt", "ssh_args": null, "times": null,
"verify_host": false}}, "msg": "Warning: Identity file /root/.ssh/mykey.pem
not accessible: No such file or directory.\nPermission denied
(publickey,gssapi-keyex,gssapi-with-mic).\r\nrsync: connection unexpectedly
closed (0 bytes received so far) [receiver]\nrsync error: error in rsync
protocol data stream (code 12) at io.c(600) [receiver=3.0.6]\n", "rc": 12}
01. How can I send a file from ServerA to ServerB?
02. How to append content of /root/myfile.txt file in ServerA to
/root/myfile.txt file of Server B
Thanks,
Danishka
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/10d9f50c-9e97-4f07-9868-39a7a1c89e55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.