chef-shell 权限不足

chef-shell insufficient permissions

我尝试使用这个简单的代码块在 chef 中创建一个目录

...
directory "/opt/myfolder" do
  owner "abc"
  group "abc"
  mode "0755"
  action :create
end
...

当我使用 "chef-client" 执行它时,它起作用了。但是当我在 chef-shell(运行ning 在客户端模式下)执行这个时,我得到这个错误

================================================================================
Error executing action `create` on resource 'directory[/opt/myfolder/]'
================================================================================

Chef::Exceptions::InsufficientPermissions
-----------------------------------------
Cannot create directory[/opt/myfolder/] at /opt/myfolder/ due to insufficient permissions

我正在使用 chef-shell 来调试我的食谱

在 chef-shell 我正在使用 node.run_chef 来 运行 启动客户端 运行

您 运行ning chef-shell 是 sudo 还是 root?如果没有,你需要。

想知道 chef-shell 中 运行 时

`whoami`
的输出会很有趣。那会告诉你它认为它是 运行ning 的用户。您可以将其添加到配方中,然后查看 运行ning 为 chef-client 时的输出。我猜 chef-client 是 运行 root 用户。