Search code examples
puppet

how to run npm install on nodejs-application using puppet after cloning it from git repo


please find the code i used to clone my git repo:

package { 'git':
    ensure => 'latest',
  }

  vcsrepo { "/nodejs-helloworld":
    ensure   => latest,
    provider => git,
    require  => [ Package["git"] ],
    source   => "[email protected]:hello-world/nodejs-helloworld.git",
    revision => 'master',

  }

After cloning my git repository using puppet i want run my nodejs application(cloned repository) using puppet

To run my nodejs app normally please find the below steps:

cd nodejs_helloworld/
npm install 
npm start

Can anyone help me or suggest any links to run nodejs app using puppet.


Solution

  • Crude exec that will do the trick:

    exec { '/usr/bin/npm install; /usr/bin/npm start':
      cwd         => '/nodejs-helloworld',
      subscribe   => Vcsrepo['/nodejs-helloworld'],
      refreshonly => true,
    }