Is it possible execute a command on the master node, everytime an agent node is powered up?

asked 2016-08-05 10:41:41 -0500

jyepesr1 gravatar image

I have a Cluster in which I require that every "x" seconds after a node is powered up, the Master executes a specific command. Until now I have this:

exec { 'My command':
   path => ['/usr/bin', '/usr/sbin/', '/bin'],
   command => 'some command',
   onlyif => "test ${uptime_seconds} -lt 60",

That works only for the compute nodes, but I need running this command only on the master node.

Thank you in advance.

edit retag flag offensive close merge delete


why don't you define a node block for your master containing exec resource in site.pp?

rajeevsharma gravatar imagerajeevsharma ( 2016-08-06 13:20:24 -0500 )edit

But, How the puppet master realizes when a node is powered up?, to execute the command on itself with a node block definition Thank You.

jyepesr1 gravatar imagejyepesr1 ( 2016-08-07 14:32:14 -0500 )edit

No. BTW, it depends. If you have installed puppet with packages, they should have included an init script to trigger puppet agent run as soon as your machine is up. If not, you have to deploy an init script for this. As soon as your node is powered up, agent will trigger to run the node definition.

rajeevsharma gravatar imagerajeevsharma ( 2016-08-08 06:01:19 -0500 )edit