Chef推荐的执行命令的方法

时间:2016-09-16 17:11:11

标签: linux chef chef-recipe

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

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

使用厨师是否有更好的方法来实现这一目标?

1 个答案:

答案 0 :(得分:2)

尽管你的懒惰,这里有类似于你想要达到的东西(你的问题很不清楚)。

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

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