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\" 
\"[email protected]:/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

-- 
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/a5a388ab-73c3-44b0-8919-4208937f69f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to