I’m having trouble with paramiko/sftp, and using the -c ssh option gets me one step further but still results in an error. I’ve been running on OSX but created a fresh LinuxMint VM in VirtualBox with all the latest and greatest stuff, and duplicated the issues I saw in OSX. The -c ssh looks slightly different though. For reference, I’m running python 2.7 on both Linux and OSX, and I’m trying to access an EC2 instance.
I’ve tried executing a simple shell command (-m shell -a 'echo “HELLO”) and a ping (-m ping). I have also tried a simple playbook and gotten the same errors.
LinuxMint (VM), Pyth
Paramiko
$ansible prod --user=ec2-user --private-key=key.pem -m shell -a ‘echo “Hello”’
www.myserver.com | FAILED => failed to open a SFTP connection
SSH
$ansible prod --user=ec2-user --private-key=key.pem -m shell -a ‘echo “Hello”’ -c ssh
prod1.v2.pixieplug.com | FAILED => failed to transfer file to /home/ec2-user/.ansible/tmp/ansible-1353110320.71-241956472283584/command:
Couldn’t read packet: Connection reset by peer
OSX
Paramiko
$ansible prod --user=ec2-user --private-key=key.pem -m shell -a ‘echo “Hello”’
prod1.v2.pixieplug.com | FAILED => failed to open a SFTP connection
SSH
$ansible prod --user=ec2-user --private-key=key.pem -m shell -a ‘echo “Hello”’ -c ssh
www.myserver.com | FAILED => failed to transfer file to /home/ec2-user/.ansible/tmp/ansible-1353110453.09-107376501006560/command:
Connecting to www.myserver.com…
// motd that I expect from my server, so it got in //
subsystem request failed on channel 0
Connection closed
OSX, Playbooks
Paramiko
$ansible-playbook test.yml --user=ec2-user --private-key=key.pem
PLAY [prod] *********************
GATHERING FACTS *********************
fatal: [www.myserver.com] => failed to open a SFTP connection
TASK: [print hello world] *********************
FATAL: no hosts matched or all hosts have already failed – abortingPLAY RECAP *********************
www.myserver.com : ok=0 changed=0 unreachable=1 failed=0
SSH