我一直在玩Ansible,我可以针对流浪汉虚拟机启动我的剧本,但是当我尝试在EC2实例中执行相同的过程时会出现问题。我不能完成任何任务:
# 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?
有任何线索吗?我可以用ssh sudo:
# 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]
...
答案 0 :(得分:1)
我最终找到了解决方案:
我的库存文件如下:
[dbservers]
ubuntu@mydomain
但是,如果我以另一种方式设置ssh用户运行正常:
[dbservers]
mydomain ansible_ssh_user=ubuntu