error2007s error2007s - 11 months ago 51
Linux Question

Chef recommended way for executing a command

I was trying to run a command

mkdir -p /path/on/disk && touch sample-file
using chef. My chef code is as below. I am on linux.

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

Is there a more beter way to achieve this using chef?

Answer Source

Despite your laziness, here's something similar to the thing you want to achieve (your question is very unclear).

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

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