the lines.each could be rewritten to just Chef::ShellOut.new(cmd).run_command.stdout.split("\n").each

not sure if that makes things better though. I don't like single use variables that much.