We've got this code also in puppetrun.rb and a bit of it in puppet_ssh.rb so they would need updating too.  Maybe just move the sudo section into runner.rb and use it in all three.