Puppet: System Administration Automated

Support

Ticket #972 (new enhancement)

Opened 1 year ago

Last modified 7 months ago

More useful information (error handling) from Exec via system()

Reported by: astinus Assigned to: luke
Priority: normal Milestone:
Component: exec Version:
Severity: normal Keywords:
Cc: Triage Stage: Needs design decision
Attached Patches: None Complexity: Easy

Description

I've been managing my /home directories using Puppet lately, and pushing around a "skeleton" containing all the useful files like .ssh/config you want on *all* hosts -- gives the whole network a consistent look and feel because prompts are the same, aliases are the same, really makes for a nicer system administration experience.

I ran into an error just recently, with:

        exec { "update-home":
            command     => "tar -xvf $homedir/.skeleton/$name.tar -C $homedir",
            user        => "$name",
            path        => ["/usr/bin", "/usr/sbin"],
            subscribe   => File["$homedir/.skeleton/$name.tar"],
            logoutput   => true,
            refreshonly => true
        }

The file is copied over correctly. Directory permissions and file permissions are correct. Altering the tarball such that the MD5 changes will make Puppet go "Hey! That changed" and copy the new one before trying to execute update-home; in every case it fails with:

err: //default/accounts/account[ahowells]/Exec[update-home]: Failed to call refresh on Exec[update-home]: tar -xvf /home/ahowells/.skeleton/ahowells.tar returned 1 instead of 0 at /etc/puppet/manifests/modules/user-management/definitions/account:158

I am doing a one-time invocation of Puppet on the client node with puppetd --test --debug --verbose and expecting useful output to help me debug ;) That output wasn't useful enough.

19:43 < lak> that kind of thing is really difficult to detect, actually
19:43 < lak> i call system(), it pukes, i try to give an exception that helps, but...
19:43 < lak> it's all up to whether system() pukes usefully, and it doesn't
19:43 < astinus> yah, not blaming you really :)  It was user error on my part.  Just coulda fixed it in ~10s rather than 
                 ~10 minutes if system() puked more usefully
19:44 < lak> yeah, i know
19:45 < lak> good error handling is clearly critical
19:45 < lak> feel free to file it as an enhancement request; i don't know that i've specifically attacked that one, so 
             maybe it's not that hard

The problem was actually that Ubuntu "Gutsy Gibbon" has that package kicking about in /bin/tar and I'd expected /usr/bin/tar ;) Thus the fix is:

        exec { "update-home":
            command     => "tar -xvf $homedir/.skeleton/$name.tar -C $homedir",
            user        => "$name",
            path        => ["/bin", "/usr/bin", "/usr/sbin"],
            subscribe   => File["$homedir/.skeleton/$name.tar"],
            logoutput   => true,
            refreshonly => true
        }

I'm filing this as an enhancement request because I think it should have taken 10 seconds to fix with better error handling, not 10 minutes to play the system administration equivalent of Whack-a-Mole.

Change History

12/28/07 03:58:07 changed by jamtur01

  • owner changed from community to luke.
  • complexity changed from Unknown to Easy.
  • stage changed from Unreviewed to Needs design decision.

04/24/08 08:00:25 changed by luke

  • component changed from client to exec.