【问题标题】:Does Vagrant create the /etc/sudoers.d/vagrant file, or does it need to be added manually to use ansible sudo_user?Vagrant 是创建 /etc/sudoers.d/vagrant 文件,还是需要手动添加才能使用 ansible sudo_user?
【发布时间】:2014-03-14 20:30:06
【问题描述】:

一些 ubuntu 云图像,例如这个: http://cloud-images.ubuntu.com/vagrant/precise/20140120/precise-server-cloudimg-amd64-vagrant-disk1.box

拥有文件 /etc/sudoers.d/vagrant,其内容为 vagrant ALL=(ALL) NOPASSWD:ALL

其他盒子比如这个https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-13.10_chef-provisionerless.box

没有,因此带有 sudo_user 的 ansible 命令不起作用。

我可以添加文件:

- name: ensure Vagrant is a sudoer
  copy: content="vagrant ALL=(ALL) NOPASSWD:ALL" dest=/etc/sudoers.d/vagrant owner=root group=root
  sudo: yes

我想知道 Vagrant 是否应该做些什么,因为这个任务 在真实(非流浪)机器上运行 ansible playbook 时将不适用。

【问题讨论】:

    标签: vagrant ansible


    【解决方案1】:

    Vagrant 需要使用config.ssh.username = "root" 或更常见的sudo 对VM 进行特权访问。 Bento Ubuntu 盒子目前 configure 它直接到 /etc/sudoers。

    我不知道 ansible 的 sudo_user 做什么或意味着什么,但我猜你的配置覆盖了 /etc/sudoers.在这种情况下,您确实需要确保您不会失去 Vagrant 对 VM 的 sudo 访问权限。或者构建您自己的使用 sudoers.d 的基础框。

    附带说明,如果您创建 /etc/sudoers.d/ 文件,您还应该将其模式设置为 0440 或至少一些旧 sudo 版本拒绝应用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 2017-07-06
      • 1970-01-01
      • 2013-01-17
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      相关资源
      最近更新 更多