Amos Shapira
2013-Nov-19 03:34 UTC
[Puppet Users] Weird situation - exec fails but Puppet 2.7 exits 2
Hello, We are a long time Puppet 2.7 shop (installing latest Puppet 2.7 gems on deployments. In this particular build it picked up Puppet 2.7.23) and just discovered the following: Executing a psql command like: build 12-Nov-2013 04:30:16 debug: /Stage[main]/Buildeng_postgres::Service/Service[postgresql]: The container Class[Buildeng_postgres::Service] will propagate my refresh event build 12-Nov-2013 04:30:16 debug: Class[Buildeng_postgres::Service]: The container Stage[main] will propagate my refresh event build 12-Nov-2013 04:30:16 debug: Exec[create postgres user](provider=posix): Executing ''psql -U postgres -c "ALTER USER postgres WITH PASSWORD ''password'';"'' build 12-Nov-2013 04:30:16 debug: Executing ''psql -U postgres -c "ALTER USER postgres WITH PASSWORD ''password'';"'' build 12-Nov-2013 04:30:16 notice: /Stage[main]/Buildeng_postgres::Post_service/Buildeng_postgres::Create_user[postgres]/Exec[create postgres user]/returns: psql: FATAL: the database system is starting up build 12-Nov-2013 04:30:16 err: /Stage[main]/Buildeng_postgres::Post_service/Buildeng_postgres::Create_user[postgres]/Exec[create postgres user]: Failed to call refresh: psql -U postgres -c "ALTER USER postgres WITH PASSWORD ''password'';" returned 2 instead of one of [0] at /home/ubuntu/puppet-cfg/buildeng-modules/buildeng_postgres/manifests/create_user.pp:10 The resource which creates this log is: define buildeng_postgres::create_user ($password=undef) { require buildeng_postgres::service exec { ''create postgres user'': subscribe => Service[''postgresql''], user => $buildeng_postgres::params::user, command => "psql -U ${buildeng_postgres::params::postgres_user} -c \"ALTER USER ${buildeng_postgres::params::postgres_user} WITH PASSWORD ''${buildeng_postgres::params::postgres_password}'';\"", refreshonly => true, } } Puppet registers the failure as an error ("2" is not an expected exit code of this Exec resource) but still exits with exit status "2" (with --detailed-exitcode). I know why psql failed but that''s besides the point - Puppet should have failed but it didn''t. Any idea why? Thanks. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3968d231-7a42-45cc-88e0-61bf55e96b4f%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Felix Frank
2013-Nov-19 14:31 UTC
Re: [Puppet Users] Weird situation - exec fails but Puppet 2.7 exits 2
Hi, if memory serves, --detailed-exitcode (one of the more annyoing implications of --test) will return the number of resources that changed. So are there any other things that puppet did during its run? Generally, if you want to use the exit code of `puppet agent` (or apply) to determine whether there were problems, you should avoid --detailed-exitcode and --test. HTH, Felix On 11/19/2013 04:34 AM, Amos Shapira wrote:> > Puppet registers the failure as an error ("2" is not an expected exit > code of this Exec resource) but still exits with exit status "2" (with > --detailed-exitcode). > I know why psql failed but that''s besides the point - Puppet should have > failed but it didn''t.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/528B765F.3000803%40alumni.tu-berlin.de. For more options, visit https://groups.google.com/groups/opt_out.