Logging output of a long running exec

254 views
Skip to first unread message

Dayton Jones

unread,
Dec 11, 2015, 3:45:39 PM12/11/15
to Puppet Users
I have a legacy "provisioning" script that I'm calling with puppet on brand new machines (I'm slowly taking the functionality out of the script and into puppet, but for reasons I can't do a full replacement yet)

I'd like to log the output of the provisioning and have included "logoutput" to the exec in the class (see below) but when I run puppet all I get for the module/class is:
Warning: Waiting for output; will sleep 0.0 seconds
Warning: Waiting for output; will sleep 0.5 seconds
Warning: Could not get output
Notice: /Stage[post]/provision/Exec[provision.sh]/returns: executed successfully
Notice: Finished catalog run in 107.80 seconds


Here is the class and exec... I'm setting a timeout of 1800 and if the catalog run finishes in 107 seconds, I'm unclear on how it's timing out.  Any suggestions?

class provision { 

  notify {'Running provision.sh can take a while - be patient':}

  file { '/root/provision.sh' :
    ensure => file,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
    source => 'puppet:///modules/provision/provision.sh',
    notify => Exec['provision.sh'],
  }

  exec { 'provision.sh' :
    command   => '/root/provision.sh',
    logoutput => true,
    timeout   => 1800,
    cwd       => '/root';
  }
}

Steve Traylen

unread,
Dec 15, 2015, 4:56:14 AM12/15/15
to Puppet Users

Example of long exec running backgrounded in a screen.

exec { 'zrep_initial_sync':
command => "screen -dmS zrep_initial_sync /usr/local/sbin/krb_me.sh /usr/local/sbin/zrep init ${src_vol} ${dst_host} ${dst_vol}", onlyif => "zfs get -H zrep:src-fs -o value ${src_vol} | grep -qv ${src_vol}", path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin'], }

Sent from Nine
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1a15177f-e0f1-4d1b-8c87-5f7b47d7dede%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dayton Jones

unread,
Dec 15, 2015, 7:02:14 AM12/15/15
to Puppet Users
Does that show the output during the puppet run though?  I "need" to have the output of the script show up, hence the "logoutput => true" directive which I don't see in your example.  The script runs just fine, I just don't get any output/status from it when run via puppet.  

Steve Traylen

unread,
Dec 15, 2015, 1:16:04 PM12/15/15
to puppet...@googlegroups.com

In this case the screen session stays forever and you can connect to it later to see the output. That may or may not be useful to you of course

---
Steve Traylen

Dayton Jones

unread,
Dec 15, 2015, 6:07:01 PM12/15/15
to Puppet Users
Ah no...not in this case.  I need to see the output of the script in the puppet log/on screen so immediate action (if any) can be taken care of... 

I'm wondering (though I haven't been able to corroborate) if there is a buffer limit for the exec function and the script is just spewing too much for puppet to capture... 
Reply all
Reply to author
Forward
0 new messages