简体   繁体   English

人偶执行程序返回1而不是[0]

[英]puppet exec returned 1 instead of [0]

I'm trying to run puppet to provision a virtual machine. 我正在尝试运行puppet来配置虚拟机。 The command it fails on is an Exec. 执行失败的命令是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' 
      }

I'm pretty confident this is more of a puppet issue. 我非常有信心这是一个木偶戏。

The command I'm trying to run is through exec . 我试图运行的命令是通过exec If I vagrant ssh in, I can run the command manually. 如果我不熟悉ssh,可以手动运行该命令。

puppet: 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/vagrant-puppet-6/manifests/default.pp:36 木偶: err:/ 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]之一。

manual : 手册

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

vagrant box https://drive.google.com/file/d/0B7B7RIseycQkTGxXczRqVGdDVGs/edit?usp=sharing 无业游民的盒子 https://drive.google.com/file/d/0B7B7RIseycQkTGxXczRqVGdDVGs/edit?usp=sharing

Sounds like more environment variables are required to run your script that are not present during puppet runs; 听起来需要更多环境变量来运行您的脚本,而这些脚本在木偶运行期间不存在; I suffered once the same issue with a Maven build script. 我曾经在Maven构建脚本中遇到过同样的问题。 Edit your Exec command to source your profile before the build command, so the final "script" run looks like: 编辑您的Exec命令以在build命令之前获取您的概要文件,因此最终的“脚本”运行如下所示:

#!/bin/bash
source $HOME/.bash_profile
export CC=arm-axis-linux-gnuabi-gcc
/opt/openssl-1.0.1g/Configure dist .......

So, in puppet terminology: 因此,用人偶术语来说:

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' 
  }

Also, don't forget to check the actual value returned by your script. 另外,不要忘记检查脚本返回的实际值。 Maybe it's running gracefully but returning non zero because of some mysterious reason. 也许它运行正常,但由于某些神秘的原因而返回非零值。 It's not the first time I deploy a package with Puppet and the service init script needs some post-tuning due to "status" commands badly implemented. 这不是我第一次使用Puppet部署软件包,并且由于错误地实现了“状态”命令,服务初始化脚本需要进行一些后期调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM