Ansible任务在某个Vagrant box(bento)上不能有sudo_user

6
以下任务在Vagrant虚拟机(ubuntu 12.04 chefless)上失败:http://opscode.github.io/bento/
  - name: ensure database is created
    postgresql_db: name={{dbname}}
    sudo_user: postgres

fd

failed: [192.168.78.8] => {"failed": true, "parsed": false}
invalid output was: Sorry, user vagrant is not allowed to execute '/bin/sh -c echo SUDO-SUCCESS-lalargtagydzinzenmftocwaiucrmxuk; /usr/bin/python /tmp/ansible-1392568385.89-150322815243790/postgresql_db' as postgres on cogol-dev.

我需要创建自己的框吗?

=== /etc/sudoers 的内容

Defaults    env_reset
Defaults    exempt_group=sudo
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=NOPASSWD:ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

了解您在vagrant box上的sudo权限将会很有帮助。在您的vagrant box上运行grep vagrant /etc/sudoers,并将输出添加到您的问题中。 - Ben Whaley
我添加了整个/etc/sudoers的内容。 - Max L.
2个回答

6

可能有点晚了,但我今天遇到了同样的错误,并通过以下方式解决了它:

username ALL=(ALL) NOPASSWD: ALL

你的sudo组缺少这个括号中的ALL


虽然有点晚了,但我也给你点赞,因为这对我来说是个解决方案(使用chef/Ubuntu 14和vagrant)。 - msanford

0
相信你也必须在 sudo_user 参数的下方/上方添加 sudo: yes

1
即使我添加了 sudo: yes,使用 sudo_user 仍然会出现相同的错误。 - sworisbreathing

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接