2
votes

ubuntu 14.04.3 LTS ansible version: 2.1.0, the sshport on remote server is 44022

Im using adhoc way to run synchronize module as a sudo user[nopasswd is not enabled] to synchronize local and remote directories (push)

Below is host file /etc/ansible/hosts

[webdb]
10.153.99.132
10.153.99.52
[webdb:vars]
ansible_ssh_user=ctuser
ansible_ssh_private_key_file=/root/.ssh/id_rsa
ansible_port=44022

Below are the command used:

ansible webdb -s -K  -m synchronize -a "src=/tmp/muhan 
dest=/store" -u ctuser

and (dest_port used)

ansible webdb -s -K  -m synchronize -a "dest_port=44022 
src=/tmp/muhan dest=/store" -u ctuser 

Both commands outputs below error:-

10.153.99.52 | FAILED! => {
    "changed": false, 
    "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh 'ssh -i /root/.ssh/id_rsa -S none -o StrictHostKeyChecking=no -o Port=44022' --rsync-path=\"sudo rsync\" --out-format='<<CHANGED>>%i %n%L' \"/tmp/muhan\" \"[email protected]:/store\"", 
    "failed": true, 
    "msg": "sudo: unable to resolve host c2.example.com\nsudo: no tty present and no askpass program specified\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.0]\n", 
    "rc": 12
}
10.153.99.132 | FAILED! => {
    "changed": false, 
    "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh 'ssh -i /root/.ssh/id_rsa -S none -o StrictHostKeyChecking=no -o Port=44022' --rsync-path=\"sudo rsync\" --out-format='<<CHANGED>>%i %n%L' \"/tmp/muhan\" \"[email protected]:/store\"", 
    "failed": true, 
    "msg": "sudo: unable to resolve host c1.example.com\nsudo: no tty present and no askpass program specified\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.0]\n", 
    "rc": 12
}
1
-s and -K are both deprecated. What do you get if you use -b and --ask-become-pass? - MillerGeek
Also, if you are using key-based authentication it may be ideal to enable passwordless sudo. - MillerGeek
did you figure out a solution? - ali haider
No solution .Currently im using with password less sudo - sherpaurgen

1 Answers

0
votes

You can tackle this from multiple angles:

The exact switches you need:

ssh_args = -tt