weird control flow, had to remove an end statement
straggling Puppet.err calls replaced with fail