简体   繁体   中英

puppet exec returned 1 instead of [0]

I'm trying to run puppet to provision a virtual machine. The command it fails on is an 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 . If I vagrant ssh in, I can run the command manually.

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

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

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. Edit your Exec command to source your profile before the build command, so the final "script" run looks like:

#!/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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