Take a look at using Mixlib::ShellOut (previously Chef::ShellOut).
https://github.com/opscode/mixlib-shellout
Here's an outdated example (needs to be updated to Mixlib from Chef).
https://github.com/opscode/cookbooks/blob/master/drbd/recipes/pair.rb#L49
Archive powered by MHonArc 2.6.16.