3
votes

My install file is like this:

...
cd /home/work/package/dea_ng
...
bundle install
export PATH=$PATH:/usr/local/go/bin
bundle exec rake dir_server:install

I'm pretty sure that the last command can run successfully on my client machine, but puppet keep reporting " returned 1 instead of one of [0]" error.

So, here is the install manifest:

class dea_ng::install {
  exec { "/bin/bash /home/work/install/dea_ng_install.sh":
    path=>'/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin',
    cwd =>'/home/work/install',
    logoutput => false,
    require =>Class["dea_ng::dea_ngfile"],
    before => Class["dea_ng::service"],
  }
} 

The problem also happens to my start command which also use bundle exec: after puppet finished dea_ng::install and run dea_ng::service, the command below did not work unless I execute it manually on the client machine.

bundle exec rake dir_server:run[config/dea.yml] &

I'm really confused about this, it seems like puppet can not handle bundle exec well in my case. Did I missed some env configuration here?

The output of --debug seems no help:

Debug: Executing '/bin/bash /home/work/install/dea_ng_install.sh'
Error: /bin/bash /home/work/install/dea_ng_install.sh returned 1 instead of one of [0]
Error: /Stage[main]/Dea_ng::Install/Exec[/bin/bash /home/work/install/dea_ng_install.sh]/returns: change from notrun to 0 failed: /bin/bash /home/work/install/dea_ng_install.sh returned 1 instead of one of [0]

And if I remove the bundle exec line, the shell will success.

1
can you run puppet with --debug mode and post the few bits prior to the returned 1 error. - iamauser
Can you add print statements or something to your script to see what's different in each of the execution environments? - Nate W.
@Shakedown Could you give me some tips about what may be different between puppet world and real world in this case? I don't know where to start my debug actually. - harryz
I'm just shooting from the hip really, but...maybe the current environment (env) would shed light on something? - Nate W.
Exciting, I got the error by adding output => true: "couldn't find HOME environment -- expanding `~' ". How to fix that in puppet? - harryz

1 Answers

4
votes

The real error is found by adding output => true:

couldn't find HOME environment -- expanding `~'

And this is a know issue in Puppet3, see

https://groups.google.com/forum/#!topic/puppet-users/5sk9mJqe4Z0

So add HOME env solves the problem:

environment => "HOME=/root"