Chef 推荐的命令执行方式

Chef recommended way for executing a command

我正在尝试 运行 使用厨师的命令 mkdir -p /path/on/disk && touch sample-file。我的厨师代码如下。我在 linux.

execute 'create directory' do
    command 'mkdir -p /path/on/disk && touch sample-file'
end

是否有使用 chef 实现此目的的更好方法?

尽管你很懒,这里有一些类似于你想要实现的东西(你的问题很不清楚)。

directory "/path/on/disk" do
  recursive true
end

file "/path/on/disk/sample-file" do
  content ""
  action :create_if_missing
end