Reputation: 9704
I've been playing around with Ansible a little bit and I'm able to launch my playbook against a vagrant virtual machine, but the problems arise when I try to do the same process in an EC2 instance. I just can't sudo any task:
# ansible -i inventory/staging dbservers --sudo -a "apt-get update"
ubuntu@staging-ansible | FAILED | rc=100 >>
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Any clue? I can sudo with ssh:
# ssh ubuntu@staging-ansible "sudo apt-get update"
sudo: unable to resolve host ip-10-0-0-61
Get:1 http://eu-west-1.ec2.archive.ubuntu.com precise Release.gpg [198 B]
Get:2 http://eu-west-1.ec2.archive.ubuntu.com precise-updates Release.gpg [198 B]
Get:3 http://security.ubuntu.com precise-security Release.gpg [198 B]
...
Upvotes: 3
Views: 2003
Reputation: 9704
I eventually found the solution:
My inventory file was like:
[dbservers]
ubuntu@mydomain
But if I set the ssh user in this other way runs ok:
[dbservers]
mydomain ansible_ssh_user=ubuntu
Upvotes: 3