我正在编写一个木偶模块来在我们的测试服务器上安装一个应用程序。测试环境要求我们安装一个名为execSync (https://github.com/mgutz/execSync)的节点包。因为execSync是一个本机包,所以在安装时会编译它。当我尝试在服务器上手动安装它时,它就会被安装。然而,当我使用木偶做同样的事情时,编译步骤就失败了。
我尝试过使用puppetlabs模块(https://github.com/puppetlabs/puppetlabs-nodejs)安装https://github.com/puppetlabs/puppetlabs-nodejs,并使用exec定义的类型和命令npm install execSync来安装,但似乎没有什么效果。我还检查过是否使用了nodejs和npm的正确版本。
我很想让这个过程完全自动化,但是似乎什么都没有用,我已经没有选择了。可能的原因是什么?
编辑:
下面是我使用的清单:
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,
}我使用puppet apply运行这个程序。
这就是我在控制台输出中看到的:
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当我手动运行命令时,同样的操作也很好。编译成功。
发布于 2015-03-06 10:33:52
弄明白了。我一直在试着了解这两者的不同之处。环境似乎是不同的。编译步骤要求设置HOME env变量。如果未设置编译步骤,则编译步骤将在没有任何有用错误消息的情况下失败。
最后,使用以下清单:
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'],
}发布于 2015-03-05 14:21:50
在执行执行时,一定要使用完全限定的路径,如下所示:
exec {'install-execSync':
command => '/usr/local/bin/npm install execSync',
}为了完全自动化这个过程,我们需要更多的信息。
https://stackoverflow.com/questions/28878023
复制相似问题