不能 运行 Chef 作为 root
Can't run Chef as root
在中断 2 年之后,我最近回到了 Linux。我试着
learn Chef 以便自动执行某些应用程序部署。在 Chef 教程中,它声明 sudo
是 运行 安装软件包的命令所必需的,这是有道理的。
webserver.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, along with an 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)
我认为他的意思是您不应该 运行 Chef 100% 的时间都是 root。我无法 运行 Chef 作为 root,这似乎与 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>'
如果教程说您可以 运行 Chef 作为 root,并且需要 root 来执行某些食谱,那么我认为 Chef 在某些情况下应该 运行 作为 root。
我最大的问题是如何修复此错误并 运行 Chef 作为 root?它 运行 与任何其他用户一样正常,但当我尝试 sudo
时失败了。
好吧 rvm reset
毕竟成功了。
所以我之前嘲笑的"solution" post其实就是我要找的解决方案。因果报应。
不要通过 GEM. 安装 CHEF(很多充分的理由太长无法解释,但相信我,使用综合包)
这里发生的事情是您的 rvm 覆盖了路径搜索顺序和 ruby 调用,因此 chef 启动器在 rvm 路径中搜索,而不是在嵌入式 ruby chef 路径中搜索。调用 rvm reset
通过删除 override/path 添加来解决问题。
对于 'to be or not to be root' 部分,我对您链接的问题的回答有错别字。 not 改写后忘记了,(我希望句子的其余部分需要明确的词根)。无论如何,谢谢你的提醒。
Chef 的意思是 运行 作为 root
,但强烈建议不要远程连接到机器作为 root
。
因此,您应该在 100% 的情况下使用 sudo
以 root
权限启动 chef-client
。如果 运行 作为普通用户,Chef 将无法执行某些操作,因为它旨在管理整个系统。
注意:我说的是 'should' 而不是 'must',因为有人可能会找到一个边缘案例,建议在有限的环境中 运行 厨师,但我真的认为这是一个在这种情况下,边缘情况和 chef 可能不是正确的工具。
在中断 2 年之后,我最近回到了 Linux。我试着
learn Chef 以便自动执行某些应用程序部署。在 Chef 教程中,它声明 sudo
是 运行 安装软件包的命令所必需的,这是有道理的。
webserver.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 omitsudo
from the command.
我用谷歌搜索了我遇到的问题并找到了 "solution" that didn't work, along with an 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)
我认为他的意思是您不应该 运行 Chef 100% 的时间都是 root。我无法 运行 Chef 作为 root,这似乎与 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>'
如果教程说您可以 运行 Chef 作为 root,并且需要 root 来执行某些食谱,那么我认为 Chef 在某些情况下应该 运行 作为 root。
我最大的问题是如何修复此错误并 运行 Chef 作为 root?它 运行 与任何其他用户一样正常,但当我尝试 sudo
时失败了。
好吧 rvm reset
毕竟成功了。
所以我之前嘲笑的"solution" post其实就是我要找的解决方案。因果报应。
不要通过 GEM. 安装 CHEF(很多充分的理由太长无法解释,但相信我,使用综合包)
这里发生的事情是您的 rvm 覆盖了路径搜索顺序和 ruby 调用,因此 chef 启动器在 rvm 路径中搜索,而不是在嵌入式 ruby chef 路径中搜索。调用 rvm reset
通过删除 override/path 添加来解决问题。
对于 'to be or not to be root' 部分,我对您链接的问题的回答有错别字。 not 改写后忘记了,(我希望句子的其余部分需要明确的词根)。无论如何,谢谢你的提醒。
Chef 的意思是 运行 作为 root
,但强烈建议不要远程连接到机器作为 root
。
因此,您应该在 100% 的情况下使用 sudo
以 root
权限启动 chef-client
。如果 运行 作为普通用户,Chef 将无法执行某些操作,因为它旨在管理整个系统。
注意:我说的是 'should' 而不是 'must',因为有人可能会找到一个边缘案例,建议在有限的环境中 运行 厨师,但我真的认为这是一个在这种情况下,边缘情况和 chef 可能不是正确的工具。