Question Exec resource

58 views
Skip to first unread message

Christian Charpentier

unread,
Jul 27, 2016, 12:43:17 PM7/27/16
to Puppet Users
Hi,

I'm trying to install openam with puppet. To do this i'm using an exec resource:

exec { 'openam_install':
  command  
=> "source /etc/profile && /opt/openam/bin/openam_install.sh install ${::env} > /opt/openam/install.log",
  provider => shell,
  creates  => '/var/lib/tomcat/webapps/sso',
}

The script openam_install.sh exit with an error code:

Debug: /Stage[main]/Openam::Config/Exec[openam_install]/returns:    ERROR: command execution failed at line 247 !

Error: source /etc/profile && /opt/openam/bin/openam_install.sh install cm returned 1 instead of one of [0]

Error: /Stage[main]/Openam::Config/Exec[openam_install]/returns: change from notrun to 0 failed: source /etc/profile && /opt/openam/bin/openam_install.sh install cm returned 1 instead of one of [0]


Line 247 i have this:


java -jar /opt/openam/configurator/openam-configurator-tool-${openAMversion}.jar -f /opt/openam/configurator/openam.conf

echo "Restarting OpenAM"
service tomcat restart


The java -jar command fail but i can't figure out why because if i try to launch this command directly in a shell it works.


Any help would be appreciated.


Thanks.


Chris

Martin Alfke

unread,
Jul 28, 2016, 3:06:15 AM7/28/16
to puppet...@googlegroups.com
An exec resource will always start with an empty environment.
I assume that it can not find the java binary.
You can try specifying the
path => ‘…'
attribute.
And: log_output => true

Besides this:
please take care on being idempotent (only run in case that it is required) and on error handling (how to proceed/revert in case of error).

Best,
Martin
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c0c81a61-b7cc-46e8-b9cf-63020f7598fd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Christian Charpentier

unread,
Jul 28, 2016, 12:47:59 PM7/28/16
to Puppet Users
Thnaks for your answer Martin.

Here is the beginning of the stack:

 [0;36mDebug: Executing '/bin/sh -c source /etc/profile && /opt/openam/bin/openam_install.sh install cm > /opt/openam/install.log' [0m
 [0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: Certificate was added to keystore [0m
[0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: Certificate stored in file </tmp/openam-openam1.der> [0m
[0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: Certificate was added to keystore [0m
[0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: java.net.ConnectException: Connection refused [0m
[0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns:         at java.net.PlainSocketImpl.socketConnect(Native Method) [0m


Could it be an SSL connection issue instead of a path issue with the java -jar command?

About the idenpotency, by using the creates attribute normally ensure the exec command will be executed only if the file/directory doesn't exist. So i should not have any problem with that.

Martin Alfke

unread,
Jul 29, 2016, 2:53:19 AM7/29/16
to puppet...@googlegroups.com
Hi Christian,


> On 28 Jul 2016, at 18:47, Christian Charpentier <cha...@gmail.com> wrote:
>
> Thnaks for your answer Martin.
>
> Here is the beginning of the stack:
>
> [0;36mDebug: Executing '/bin/sh -c source /etc/profile && /opt/openam/bin/openam_install.sh install cm > /opt/openam/install.log' [0m
> [0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: Certificate was added to keystore [0m
> [0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: Certificate stored in file </tmp/openam-openam1.der> [0m
> [0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: Certificate was added to keystore [0m
> [0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: java.net.ConnectException: Connection refused [0m
> [0;36mDebug: /Stage[main]/Openam::Config/Exec[openam_install]/returns: at java.net.PlainSocketImpl.socketConnect(Native Method) [0m

This looks like a connection error from within the java process.
This is unrelated to Puppet.
Does the command work when running it from a root shell?
If this is the case: check for further environments setting which might be needed by the installer and use the environment parameter of the exec resource type.

Best,
Martin

>
>
> Could it be an SSL connection issue instead of a path issue with the java -jar command?
>
> About the idenpotency, by using the creates attribute normally ensure the exec command will be executed only if the file/directory doesn't exist. So i should not have any problem with that.
>
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/cf796f0d-7ddb-4ff5-bbfb-5ce67aeae565%40googlegroups.com.

Christian Charpentier

unread,
Aug 1, 2016, 3:10:17 AM8/1/16
to Puppet Users
Yes the command exit with succes from a root shell. 
I'm gonna try to use exec environment parameter.

Thx
Reply all
Reply to author
Forward
0 new messages