I am trying to use the synchronize module to copy file from Ansible node to remote node. I want these files to exist as UserB on the remote nodes but I do not have access to UserB directly. Instead UserA has sudo privileges to switch to UserB. So im logging in as UserA.
My environment file says:
ansible_ssh_user=UserA
ansible_ssh_pass=<PassUserA>
ansible_become_method=sudo
ansible_become_user=UserB
ansible_become_pass=<PassUserA>
My task is :
- name: Copy and unarchive webapps node.
synchronize: src=/home/ansible/templates/app/Sprint6/webapps dest=/opt/msdp/ca/app checksum=yes
become: yes
But when I run the playbook, I get an ERROR:
fatal: [5.232.57.247]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --checksum --archive --rsh 'ssh -S none -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=60s' --rsync-path=\"sudo rsync\" --out-format='<<CHANGED>>%i %n%L' \"/home/ansible/templates/app/Sprint6/webapps\" \"UserA@5.232.57.247:/opt/msdp/ca/app\"", "failed": true, "msg": "sudo: sorry, you must have a tty to run sudo\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]\n", "rc": 12}
On the remote node, only UserB can write under : /opt/msdp/ca/app
Is there a config that I am missing ?
On the remote node I set Defaults !requiretty
But then I get
sudo: no tty present and no askpass program specified