Glassfish custom provider and 'file does not exist'

248 views
Skip to first unread message

Gavin Williams

unread,
Sep 26, 2012, 12:01:47 PM9/26/12
to puppet...@googlegroups.com
Hi there,

I'm trying to setup Glassfish config management using puppet.
I've found larstobi's module here which I've cloned and am starting to tweak, as it would appear that the mentioned module is based on Solaris, therefore I'm starting to add support for EL. My code tree is here.

The challenge I'm hitting currently is that upon executing, it's failing with
err: Could not find a suitable provider for domain

When running at debug level, I can see the following:
debug: Puppet::Type::Domain::ProviderAsadmin: file asadmin does not exist
debug: Class[Glassfish::Domain]: The container Stage[main] will propagate my refresh event
err: Could not find a suitable provider for domain

I've verified that the asadmin file exists, as follows:
notice: /Stage[main]/Glassfish::Domain/Notify[gfdomain]/message: defined 'message' as 'Creating Glassfish domain cms using portbase 9000.
 Asadmin file is: /usr/local/glassfish-3.1.2/bin/asadmin.'


# file /usr/local/glassfish-3.1.2/bin/asadmin
/usr/local/glassfish-3.1.2/bin/asadmin: POSIX shell script text executable


So the file definitely exists, and is a valid 'asadmin' file.

Any ideas?

Cheers
Gavin

Dick Davies

unread,
Sep 27, 2012, 7:53:18 AM9/27/12
to puppet...@googlegroups.com
At a guess the asadmin command isn't in puppetd's $PATH.
Maybe try a full path to the executable to confirm?
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/A_85G-eU3TwJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

fatmcgav

unread,
Sep 27, 2012, 7:57:01 AM9/27/12
to puppet...@googlegroups.com

Hi there

I thought that initially as well, so I modified the provider to use a full path rather than assume it was on the path.

The log files below are prints of the variables which are being passed around...

Cheers
Gav

Stefan Schulte

unread,
Sep 28, 2012, 1:14:03 AM9/28/12
to puppet...@googlegroups.com
On Thu, Sep 27, 2012 at 12:57:01PM +0100, fatmcgav wrote:
> Hi there
>
> I thought that initially as well, so I modified the provider to use a full
> path rather than assume it was on the path.
>
> The log files below are prints of the variables which are being passed
> around...
>
> Cheers
> Gav
> On Sep 27, 2012 12:53 PM, "Dick Davies" <rasp...@hellooperator.net> wrote:
>
[...]
> > >> notice: /Stage[main]/Glassfish::Domain/Notify[gfdomain]/message: defined
> > >> 'message' as 'Creating Glassfish domain cms using portbase 9000.
> > >> Asadmin file is: /usr/local/glassfish-3.1.2/bin/asadmin.'
> > >> # file /usr/local/glassfish-3.1.2/bin/asadmin
> > >> /usr/local/glassfish-3.1.2/bin/asadmin: POSIX shell script text
> > executable
[...]

Has the file the executable bit set for the user that is running the
script (probably root)?

-Stefan

fatmcgav

unread,
Sep 28, 2012, 3:58:32 AM9/28/12
to puppet...@googlegroups.com
Stefan

Was running puppet agent using 'sudo'...

However just tried using root and no difference...

Asadmin definitely exists and has got the right permissions, as shown below:

# file /usr/local/glassfish-3.1.2/bin/asadmin
/usr/local/glassfish-3.1.2/bin/asadmin: POSIX shell script text executable
# ls -l /usr/local/glassfish-3.1.2/bin/asadmin
-rwxr-xr-x. 1 nobody glassfish 2262 Sep 18 16:23 /usr/local/glassfish-3.1.2/bin/asadmin


Thoughts?

Cheers
Gavin

fatmcgav

unread,
Sep 28, 2012, 5:39:11 AM9/28/12
to puppet...@googlegroups.com
Ok, so I thought I'd take another look, and try and get some debug logging out of the provider to make sure it's constructing things correctly...

I've applied the following patch to asadmin.rb, however I'm not seeing anything on the client trace...

diff --git a/lib/puppet/provider/asadmin.rb b/lib/puppet/provider/asadmin.rb
index f95d6ab..c8bd4a7 100644
--- a/lib/puppet/provider/asadmin.rb
+++ b/lib/puppet/provider/asadmin.rb
@@ -8,6 +8,7 @@
     passed_args.each { |arg| args << arg }
     exec_args = args.join " "
     command = "#{@resource[:asadminpath]} #{exec_args}"
+    Puppet.debug("Command = #{command}")
     command = "su - #{@resource[:user]} -c \"#{command}\"" if @resource[:user] and
       not command.match /create-service/
     self.debug command

Any ideas how I can get the provider logging???

Cheers
Gavin

Stefan Schulte

unread,
Sep 28, 2012, 8:31:18 PM9/28/12
to puppet...@googlegroups.com
On Fri, Sep 28, 2012 at 10:39:11AM +0100, fatmcgav wrote:
> Ok, so I thought I'd take another look, and try and get some debug logging
> out of the provider to make sure it's constructing things correctly...
>
> I've applied the following patch to asadmin.rb, however I'm not seeing
> anything on the client trace...
>
> diff --git a/lib/puppet/provider/asadmin.rb b/lib/puppet/provider/asadmin.rb
> > index f95d6ab..c8bd4a7 100644
> > --- a/lib/puppet/provider/asadmin.rb
> > +++ b/lib/puppet/provider/asadmin.rb
> > @@ -8,6 +8,7 @@
> > passed_args.each { |arg| args << arg }
> > exec_args = args.join " "
> > command = "#{@resource[:asadminpath]} #{exec_args}"
> > + Puppet.debug("Command = #{command}")
> > command = "su - #{@resource[:user]} -c \"#{command}\"" if
> > @resource[:user] and
> > not command.match /create-service/
> > self.debug command
> >
>
> Any ideas how I can get the provider logging???
>
> Cheers
> Gavin
>

do you have the code somewhere? If you dropped the debug call in the
create method or something it will never be executed if puppet thinks
the provider is not valid at all.

So having the actual provider code may make is more obvious why it is
failing for you.

-Stefan

fatmcgav

unread,
Sep 29, 2012, 3:21:20 AM9/29/12
to puppet...@googlegroups.com

Stefan

Yes, the code is all in github. https://github.com/fatmcgav/puppet-glassfish

Cheers
Gav

fatmcgav

unread,
Oct 15, 2012, 6:40:05 AM10/15/12
to puppet...@googlegroups.com
Just got back from holiday, and need to get this one going...

Any ideas on how I can proceed?

Cheers
Gavin

Gavin Williams

unread,
Oct 19, 2012, 12:35:54 PM10/19/12
to puppet...@googlegroups.com
Ok, I've found what was causing the provider to fail...

Changed as follows:
diff --git a/lib/puppet/provider/domain/asadmin.rb b/lib/puppet/provider/domain/asadmin.rb
index 940c051..384f6ab 100644
--- a/lib/puppet/provider/domain/asadmin.rb
+++ b/lib/puppet/provider/domain/asadmin.rb
@@ -2,7 +2,7 @@
 Puppet::Type.type(:domain).provide(:asadmin,
                                    :parent => Puppet::Provider::Asadmin) do
   desc "Glassfish support."
-  commands :asadmin => "asadmin"
+  commands :asadmin => "/usr/local/glassfish-3.1.2/bin/asadmin"
 
   def create
     args = []

Any ideas how I can make commands use a variable?

Cheers
Gavin

On Monday, 15 October 2012 11:40:16 UTC+1, Gavin Williams wrote:
Just got back from holiday, and need to get this one going...

Any ideas on how I can proceed?

Cheers
Gavin

On 29 September 2012 08:21, fatmcgav <fatm...@gmail.com> wrote:

Stefan

Yes, the code is all in github. https://github.com/fatmcgav/puppet-glassfish

Cheers
Gav

To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.

Josh Cooper

unread,
Oct 19, 2012, 1:03:37 PM10/19/12
to puppet...@googlegroups.com
Hi Gavin,
>>>> puppet-users...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/puppet-users?hl=en.
>>>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/hGGzpUwCUxsJ.
>
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

Puppet uses its `path` setting to resolve unqualified executables in
commands[1]. You can specify this on a per-agent basis, or you can
provide an environment or I've recently filed a ticket to add a
per-resource path metaparameter[2]. If you're writing your own
provider, you can also specify an environment that puppet will use to
execute the child process.

Josh

[1] http://docs.puppetlabs.com/references/latest/configuration.html#path
[2] http://projects.puppetlabs.com/issues/16997
--
Josh Cooper
Developer, Puppet Labs

fatmcgav

unread,
Oct 21, 2012, 10:39:05 AM10/21/12
to puppet...@googlegroups.com

Josh

Cheers for the info.
Are there any references on how to set the path when executing child processes?

Cheers
Gavin

Gavin Williams

unread,
Oct 24, 2012, 6:38:20 AM10/24/12
to puppet...@googlegroups.com
Ok, I've gone about it a slightly different way now, and have stripped the 'commands' argument from the domain function provider, and am trying to validate the presence of asadmin at the main asadmin.rb level.

I've created an 'exists?' definition, but it doesn't appear to be getting called. Any ideas how I can force it to be called prior to attempting to execute asadmin?

Latest code commit has been pushed to github, available here: https://github.com/fatmcgav/puppet-glassfish/commit/429f9e8e1d08e99c69d8ffdcb3043648af5fa18a

Any comments welcome.

Regards
Gavin

Stefan Schulte

unread,
Oct 24, 2012, 1:18:35 PM10/24/12
to puppet...@googlegroups.com
On Wed, Oct 24, 2012 at 03:38:20AM -0700, Gavin Williams wrote:
> Ok, I've gone about it a slightly different way now, and have stripped the
> 'commands' argument from the domain function provider, and am trying to
> validate the presence of asadmin at the main asadmin.rb level.
>
> I've created an 'exists?' definition, but it doesn't appear to be getting
> called. Any ideas how I can force it to be called prior to attempting to
> execute asadmin?
>
> Latest code commit has been pushed to github, available here:
> https://github.com/fatmcgav/puppet-glassfish/commit/429f9e8e1d08e99c69d8ffdcb3043648af5fa18a
>
> Any comments welcome.
>
> Regards
> Gavin

Your exists? method in puppet/provider/domain/el.rb overwrites the
exists? method in puppet/provider/asadmin.rb. I don't know if you get
problems when you have an el.rb file but you define an asadmin provider
here. This may create classname clashes with the asadmin provider defined in
provider/asadmin.rb

The exists? method in asadmin.rb is not going to work because `commands`
is a class method while `exists` is an instance method. It does make no
sense to call `commands` inside an instance method.

What exactly are you trying to archive anyhow? If the excutable is not in
PATH how should your provider work? The best approach in my opinion
is to always specify the full path to the executable. If you want your
provider considered suitable even if commands are missing, you can use

optional_commands :asadmin => 'binary_that_may_be_absent'

If you want the user to supply the path to the binary via a resource
parameter then you cannot realize this at a class level but at an
instance level. That beeing said, you cannot define your executables
with use the `commands` method.

To execute something you can use the execute method. You then have to
do something like.

output = execute([resource[:asadmin_binary], "arg1", "arg2"])

-Stefan

>
> On Wednesday, 26 September 2012 17:01:47 UTC+1, Gavin Williams wrote:
> >
> > Hi there,
> >
> > I'm trying to setup Glassfish config management using puppet.
> > I've found larstobi's module here
> > <https://github.com/larstobi/puppet-glassfish/>which I've cloned and am
> > starting to tweak, as it would appear that the mentioned module is based on
> > Solaris, therefore I'm starting to add support for EL. My code tree is
> > here <https://github.com/fatmcgav/puppet-glassfish>.
> >
> > The challenge I'm hitting currently is that upon executing, it's failing
> > with
> >
> >> *err: Could not find a suitable provider for domain*
> >>
> >
> > When running at debug level, I can see the following:
> >
> >> *debug: Puppet::Type::Domain::ProviderAsadmin: file asadmin does not
> >> exist
> >> debug: Class[Glassfish::Domain]: The container Stage[main] will propagate
> >> my refresh event
> >> err: Could not find a suitable provider for domain
> >> *
> >
> >
> > I've verified that the asadmin file exists, as follows:
> >
> >> *notice: /Stage[main]/Glassfish::Domain/Notify[gfdomain]/message:
> >> defined 'message' as 'Creating Glassfish domain cms using portbase 9000.
> >> Asadmin file is: /usr/local/glassfish-3.1.2/bin/asadmin.'*
> >>
> >
> > *# file /usr/local/glassfish-3.1.2/bin/asadmin
> >> /usr/local/glassfish-3.1.2/bin/asadmin: POSIX shell script text executable
> >> *
> >>
> >
> > So the file definitely exists, and is a valid 'asadmin' file.
> >
> > Any ideas?
> >
> > Cheers
> > Gavin
> >
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/_pJvxmzaEmUJ.

fatmcgav

unread,
Oct 24, 2012, 4:36:26 PM10/24/12
to puppet...@googlegroups.com

Stefan

Cheers for the feedback.

Understood on the exists element.

Yes, what I'm trying to achieve is a working provider without asadmin being in the path. That's what I've worked towards by using a full path to the relevant asadmin file, as it's possible a given node could have one or more versions of glassfish installed.

Currently, the asadmin path gets calculated using several parameter values, which allows a user calling the class to override any given parameter.

The actual command execution appears to work as expected currently, though will take another look at the execute command.

Cheers
Gavin

Message has been deleted

Sans

unread,
Oct 6, 2014, 4:18:42 PM10/6/14
to puppet...@googlegroups.com
Hi Gavin,

I know it's almost a 2 yrs. old thread but I'm still getting the very same "Could not find a suitable provider for domain" error. Did you able to solve the this prob at all in the end?

Best!
Reply all
Reply to author
Forward
0 new messages