# ansible-playbook fails, even though I can ssh into the machine

**URL:** <https://forum.ansible.com/t/ansible-playbook-fails-even-though-i-can-ssh-into-the-machine/16965>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [December 4, 2014, 11:36pm UTC](https://forum.ansible.com/t/ansible-playbook-fails-even-though-i-can-ssh-into-the-machine/16965 "2014-12-04T23:36:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanner\_Semerad](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@Tanner\_Semerad](https://forum.ansible.com/u/Tanner_Semerad)\
**Post date:** [December 4, 2014, 11:36pm UTC](https://forum.ansible.com/t/ansible-playbook-fails-even-though-i-can-ssh-into-the-machine/16965/1 "2014-12-04T23:36:48Z")

</div>

I have an AWS machine that I want to run an Ansible playbook against. The playbook has been running great against my local Vagrant vm, but now I’m having trouble’s running it against the AWS machine. I am able to ssh into the machine fine. Ex:

ssh myserver

I have a hosts file that looks like this:

[production]  
myserver

When I try to use ansible-playbook to run it, it fails:  
ansible-playbook -i hosts myplaybook.yml

I tried specifying the --private-key to be the same one I used to ssh, but still doesn’t work:  
ansible-playbook -i hosts --private-key=~/.ssh/id\_rsa myplaybook.yml

I also tried specifically setting the sudo user and setting --ask-sudo-pass but still had no luck.

Is there something specific I should be looking for? I looked through the output of -vvvv, but nothing is standing out to me. I have 4 different private keys and it tried each of them, even when I specify which one to use. I’m running ansible 1.7.2 on a Macbook Pro.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [December 5, 2014, 2:12am UTC](https://forum.ansible.com/t/ansible-playbook-fails-even-though-i-can-ssh-into-the-machine/16965/2 "2014-12-05T02:12:36Z")

</div>

For AWS, the private key should be the PEM you download I believe. Beyond that, you may also want to use the ec2 dynamic inventory script, rather than hard-coding your hosts into a file. This will allow you to use things like ec2 tags as groups and is generally a better way to reference your AWS hosts.
