10784

Installing execSync using Puppet

Question:

I am writing a Puppet module to setup an application on our test servers. The testing environment requires us to install a node package called execSync (<a href="https://github.com/mgutz/execSync" rel="nofollow">https://github.com/mgutz/execSync</a>). Since execSync is a native package, it gets compiled on installation. When I try to manually install it on the server, it gets installed. However, when I do the same thing using Puppet, compilation step fails.

I have tried installing execSync using the puppetlabs-nodejs module (<a href="https://github.com/puppetlabs/puppetlabs-nodejs" rel="nofollow">https://github.com/puppetlabs/puppetlabs-nodejs</a>) and using exec defined type with command npm install execSync as well, and nothing seems to work. I have also checked that the right versions of nodejs and npm are used.

I would love to automate this process completely but nothing seems to work and I have run out of options. What could be the possible reasons?

<strong>Edited:</strong>

Here is the manifest I am using:

exec { 'npm-install': command => 'npm install execSync', cwd => '/var/www/appv3', path => '/usr/local/node/node-default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', logoutput => true, }

I run this using puppet apply.

This is what I see in the console output:

Notice: Compiled catalog for test.app.com in environment production in 0.54 seconds Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http GET https://registry.npmjs.org/execSync Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http 304 https://registry.npmjs.org/execSync Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http GET https://registry.npmjs.org/temp Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http 304 https://registry.npmjs.org/temp Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http GET https://registry.npmjs.org/rimraf Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http 304 https://registry.npmjs.org/rimraf Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http GET https://registry.npmjs.org/graceful-fs Notice: /Stage[main]/Main/Exec[npm-install]/returns: npm http 304 https://registry.npmjs.org/graceful-fs Notice: /Stage[main]/Main/Exec[npm-install]/returns: Notice: /Stage[main]/Main/Exec[npm-install]/returns: > execSync@1.0.2 install /var/www/appv3frontend_testapp.vwo.com/node_modules/execSync Notice: /Stage[main]/Main/Exec[npm-install]/returns: > node install.js Notice: /Stage[main]/Main/Exec[npm-install]/returns: Notice: /Stage[main]/Main/Exec[npm-install]/returns: [execsync v1.0.2] Attempting to compile native extensions. Notice: /Stage[main]/Main/Exec[npm-install]/returns: [execSync v1.0.2] Notice: /Stage[main]/Main/Exec[npm-install]/returns: Native code compile failed!! Notice: /Stage[main]/Main/Exec[npm-install]/returns: execSync@1.0.2 node_modules/execSync Notice: /Stage[main]/Main/Exec[npm-install]/returns: └── temp@0.5.1 (rimraf@2.1.4) Notice: /Stage[main]/Main/Exec[npm-install]/returns: executed successfully

The same thing works just fine when I run the command manually. The compilation happens successfully.

Answer1:

Figured it out. I had been trying to understand what was different in the two. It seems that the environment was different. The compilation step requires the HOME env variable to be set. When it is not set, the compilation step fails without any helpful error messages.

Finally, ended up using the following manifest:

exec { 'npm-install': command => 'npm install execSync', cwd => '/var/www/appv3', path => '/usr/local/node/node-default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', environment => ['HOME=/root'], }

Answer2:

Make sure to use fully qualified paths when doing an exec, something like:

exec {'install-execSync': command => '/usr/local/bin/npm install execSync', }

For automating the process completely with the puppetlabs module (which you want to do) we need more info.

Recommend

  • loop generate plots for variables in a data frame
  • Run an exe in client machine from a website
  • How to test chat web app
  • Playing an array as sound and recording its output in parallel
  • Java catching exceptions and subclases
  • Do stored procedures have the ability to delete a file from the OS?
  • send data back from jsp iterator to struts action class
  • Chrome breakpoint on radio doesn't fire
  • Allocating a 2D contiguous array within a function
  • How to replace TouchesBegan with UIGestureRecognizer
  • What's the name of this finding square root algorithm?
  • Tools for understanding HTML layout
  • Available space left on drive - WinAPI - Windows CE
  • Examples of how to a STS in .Net 4.5 using WCF
  • Can my PDF ping my server when it is opened?
  • Access user's phone number on iOS 7
  • Cast between interfaces whose interface signatures are same
  • GAE: Way to get reference to an HttpSession from its ID?
  • How can I sort a a table with VBA with given text condition?
  • QLineEdit password safety
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Deleting and Updating values from a cusrsor adapter
  • How do I fake an specific browser client when using Java's Net library?
  • Modifying destination and filename of gulp-svg-sprite
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • How can I estimate amount of memory left with calling System.gc()?
  • Apache 2.4 - remove | delete | uninstall
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Understanding cpu registers
  • How do I configure my settings file to work with unit tests?
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Binding checkboxes to object values in AngularJs
  • How do I use LINQ to get all the Items that have a particular SubItem?