I wish to copy all files
from
localhost IP(10.8.33.44) folder location: /app/tmpfiles/
to multiple destination IPs with user id user2 at location
/app/IBM/profiles/backup/54166/
I run the playbook from localhost IP(10.8.33.44) with user id user1.
I'm using synchronize module to do this. I use delegate_to: localhost so
that the files from copied from local src only.
Below is my playbook:
- name: "Play 3"
hosts: dest_nodes
any_errors_fatal: True
user: user2
- name: "Backup of files on Destination Server {{ inventory_hostname }}."
synchronize:
src: "{{ playbook_dir }}/tmpfiles/"
dest: "{{ vars[inventory_hostname] }}/{{ Relative_Path }}/backup/{{
Number }}/"
mode: push
delegate_to: localhost
The issue occurs in copy when the host and destination are the same i.e
localhost IP(10.8.33.44)
The playbook run fails due to permission issue because rsync command
constructed by ansible is incorrect and is trying to copy files as user1 on
destination server instead of user2.
Below is the error log:
TASK [Backup of files on Destination Server 10.8.33.44.] ***
> fatal: [10.8.33.44 -> localhost]: FAILED! => {"changed": false, "cmd":
> "/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh
> -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
> --out-format=<<CHANGED>>%i %n%L /app/tmpfiles/
> [email protected]:/was/IBM/profiles/backup/54166/", "msg": "Warning:
> Permanently added '10.8.33.44' (ECDSA) to the list of known
> hosts.\r\nrsync: ERROR: cannot stat destination
> \"/was/IBM/profiles/backup/54166/\": Permission denied (13)\nrsync error:
> errors selecting input/output files, dirs (code 3) at main.c(635)
> [Receiver=3.1.2]\n", "rc": 3}
Can you please help me with a solution to this ?
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/80fb20ac-e3b8-4f4e-a0b2-e8d84784f8f2%40googlegroups.com.