Ask Your Question

puppet agent hangs when trying to run node PM2

asked 2015-09-09 04:22:12 -0600

mustafa gravatar image

Following is my puppet code.

 file {
     ensure => 'file',
      source => 'puppet:///modules/node_and_git/',
      require => Class['order_management'],
      path => '/home/admin/',
      owner => 'root',
      group => 'root',
      mode  => '0744', # Use 0700 if it is sensitive
      notify => Exec['run_my_script'],
  exec {
     path =>['/usr/bin','/usr/sbin','/bin','/sbin','/usr/local/bin', '/usr/local/sbin'],
     command => '/home/admin/',
     refreshonly => true,
     timeout => 1800,

In file I have

yum -y install gcc-c++
cd /home/admin/package/node-v0.12.7
sudo make install
/usr/local/bin/npm install pm2 -g
cd /home/admin/package/Order-Management
pm2 start processes.json

Everything is working fine until the last line. When the puppet client try to execute the last line it hangs. The script run perfectly locally on the client machine. Any help ?? Thanks in advance.

edit retag flag offensive close merge delete


Does the pm2 process show up in the process list at that point? Have you tried running puppet with the --debug switch to see if there are any interesting messages emitted? Does pm2 depend on any environment variables that need to be set in the exec resource?

GregLarkin gravatar imageGregLarkin ( 2015-09-09 17:40:40 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-09-10 11:31:32 -0600

mustafa gravatar image


Thanks for your reply. Yes I had to add a environment variable in the exec resource. I was setting the path but looks like it is not enough.

Br, Mustafa

edit flag offensive delete link more

answered 2015-09-11 08:47:52 -0600

slk gravatar image

Try running 'pm2' on the background.

pm2 start processes.json & ( notice the & at the end )

edit flag offensive delete link more

answered 2016-02-25 10:13:19 -0600

For those that stumble upon this, the answer is to add the HOME environment variable.

see for details.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-09-09 03:54:07 -0600

Seen: 285 times

Last updated: Sep 11 '15