linux - 无法以 root 身份运行 Chef

标签 linux chef-infra

在中断 2 年之后,我最近又回到了 Linux。我试图 learn Chef为了自动化一些应用程序部署。在 Chef 教程中,它声明 sudo 是运行安装包的命令所必需的,这是有道理的。

网络服务器.rb

package 'httpd'

shell 命令

sudo chef-apply webserver.rb

教程摘录:

sudo is required because this command installs a package and therefore must be run with root privileges. If you're running as root on your own machine, you can omit sudo from the command.

我用谷歌搜索了我遇到的问题并找到了 "solution" that didn't work , 以及 SO question that stated you shouldn't run Chef as root .我不确定我是否购买它。

First of all, chef is not intended to be run as root. A lot of resources assume they're run as root, and need it. They will fail if not running as root.

他还声明你应该使用 sudo,这与他之前的声明相冲突。

use sudo to run chef client with a test user (need an entry in sudoers file)

我认为他的意思是您不应该 100% 地以根用户身份运行 Chef。我无法以 root 身份运行 Chef,这似乎与 OP 试图解决的问题相反。

我遇到的错误

/opt/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'chef' (>= 0) among 13 total gem(s) (Gem::LoadError)
        from /opt/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
        from /opt/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
        from /opt/rvm/gems/ruby-2.1.5/bin/chef-apply:22:in `<main>'
        from /opt/rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
        from /opt/rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'

如果教程说您可以以 root 身份运行 Chef,并且需要 root 身份才能执行某些 Recipe ,那么我认为在某些情况下 Chef 应该以 root 身份运行。

我最大的问题是如何修复此错误并以 root 身份运行 Chef?它像任何其他用户一样运行良好,但当我尝试 sudo 时失败。

最佳答案

好吧 rvm reset 终于成功了。

所以我之前 mock 的“解决方案”帖子实际上是我正在寻找的解决方案。业力。

关于linux - 无法以 root 身份运行 Chef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33347785/

相关文章:

linux - 在 LAMP Droplet 上安装 Vesta 面板( digital ocean )

docker - Knife 箱工作流程说明

linux - 使用 Chef 在 LDAP 中具有相同 ID 的多个组

chef-infra - Chef 存储库的目的是什么?

linux - 在 bash 脚本要求时通过命令行提供密码

linux - Autotools 和一个带有普通 Makefile 的嵌套项目工程

linux - 我们如何生成 MCE(机器检查错误)

linux - 我怎样才能看到这个 RUN_CMD 定义

linux - 在实时挂载系统上调整根分区大小的解决方案

chef-infra - 如何声明内容依赖于 Recipe 文件的 Chef 文件资源?