我试图运行puppet来配置虚拟机。它失败的命令是Exec。
exec { 'configure openssl-arm':
logoutput => on_failure,
loglevel => verbose,
command => '/opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild',
cwd => '/opt/openssl-1.0.1g',
user => root,
environment => 'CC=arm-axis-linux-gnueabi-gcc'
}
我非常有信心这更像是一个傀儡问题。
我尝试运行的命令是通过 exec 。如果我流入ssh,我可以手动运行命令。
木偶: 错误:/ Stage [main] // Exec [configure openssl-arm] / returns:从notrun更改为0失败:/opt/openssl-1.0.1g/Configure dist --prefix = / opt / openssl-1.0.1g / armbuild在/tmp/vagrant-puppet-6/manifests/default.pp:36中返回1而不是[0]中的一个
手册:
local> vagrant ssh
vagrant@precise32 > sudu su
root@precise32 > export CC=arm-axis-linux-gnuabi-gcc
root@precise32 > /opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild
....
.... lots of output
....
root@precise32 > echo $?
0
sudo puppet apply
debug: /Schedule[hourly]: Skipping device resources because running on a host
debug: Exec[configure openssl-arm](provider=posix): Executing '/opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild'
debug: Executing '/opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild'
err: /Stage[main]//Exec[configure openssl-arm]/returns: change from notrun to 0 failed: /opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild returned 1 instead of one of [0] at /tmp/build.pp:1
debug: /Schedule[never]: Skipping device resources because running on a host
debug: /Schedule[weekly]: Skipping device resources because running on a host
debug: /Schedule[puppet]: Skipping device resources because running on a host
debug: Finishing transaction -613771238
流浪汉 https://drive.google.com/file/d/0B7B7RIseycQkTGxXczRqVGdDVGs/edit?usp=sharing
答案 0 :(得分:1)
听起来像运行你的脚本需要更多环境变量,这些变量在puppet运行期间不存在;我曾经遇到过与Maven构建脚本相同的问题。编辑Exec命令以在构建命令之前获取配置文件,因此最终的“脚本”运行如下:
#!/bin/bash
source $HOME/.bash_profile
export CC=arm-axis-linux-gnuabi-gcc
/opt/openssl-1.0.1g/Configure dist .......
所以,在木偶术语中:
exec { 'configure openssl-arm':
command => 'source $HOME/.bash_profile; /opt/openssl-1.0.1g/Configure dist --prefix=/opt/openssl-1.0.1g/armbuild',
cwd => '/opt/openssl-1.0.1g',
user => root,
environment => 'CC=arm-axis-linux-gnueabi-gcc'
}
另外,不要忘记检查脚本返回的实际值。也许它正在优雅地运行,但由于一些神秘的原因而返回非零。这不是我第一次使用Puppet部署一个包,并且由于“status”命令被严重执行,服务init脚本需要一些后期调整。