Re: Error 400 on Server

160 views
Skip to first unread message

jcbollinger

unread,
Dec 21, 2012, 9:12:04 AM12/21/12
to puppet...@googlegroups.com


On Thursday, December 20, 2012 5:34:25 PM UTC-6, Kevin Kitchen wrote:
[...] When I run puppet agent --test on the agent side it comes back with: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class java for puppet-node1 on node puppet-node1
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run

What is different here?


Your "java" class is not located where the parser's autoloader expects to find it.  Puppet will interpret a top-scope name such as "java" as a module name, and therefore look for the class definition in the module's init.pp.  That would be <module-path>/java/manifests/init.pp in this case, which would contain

class 'java' {
    # ...
}

Other classes in the same module would have names of the form java::foo, and the autoloader would look for them in (in this case) <module-path>/java/manifests/foo.pp.

There's more, but the above will cover the vast majority of your needs.


John

Kevin Kitchen

unread,
Dec 21, 2012, 12:08:59 PM12/21/12
to puppet...@googlegroups.com
Thank you for getting back to me on this. This is my init.pp file:
class java {

        require java::params

        file {"$java::params::java_base":
                ensure => "directory",
                owner => "root",
                group => "root",
                alias => "java-base"
        }

        file { "${java::params::java_base}/jdk${java::params::java_version}.tar.gz":
                mode => 0644,
                owner => root,
                group => root,
                source => "puppet:///modules/java/jdk${java::params::java_version}.tar.gz",
                alias => "java-source-tgz",
                before => Exec["untar-java"],
                require => File["java-base"]
        }

        exec { "untar jdk${java::params::java_version}.tar.gz":
                command => "tar -zxf jdk${java::params::java_version}.tar.gz",
                cwd => "${java::params::java_base}",
                creates => "${java::params::java_base}/jdk${java::params::java_version}",
                alias => "untar-java",
                refreshonly => true,
                subscribe => File["java-source-tgz"],
                before => File["java-app-dir"]
        }

        file { "${java::params::java_base}/jdk${java::params::java_version}":
                ensure => "directory",
                mode => 0644,
                owner => root,
                group => root,
                alias => "java-app-dir"
        }
}

Based on what I understand you saying, class java is interpreted as the module name and the class would be called java_base. Unfortunately, this didn't work either. Do I have this wrong?

On Thursday, December 20, 2012 3:34:25 PM UTC-8, Kevin Kitchen wrote:
I've just installed PE 2.7 and went through the quickstart. I was able to install the motd module without an issue. I decided to try a Java install module to test what I've (not) learned. I've looked at the init.pp file, the name of the class is "java". It shows as installed correctly on the agent using the puppet install command. I've added it in the console and added it on the agent in the console. When I run puppet agent --test on the agent side it comes back with: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class java for puppet-node1 on node puppet-node1

jcbollinger

unread,
Jan 2, 2013, 10:05:51 AM1/2/13
to puppet...@googlegroups.com


Yes, you misunderstood me.  Your original init.pp looks mostly fine on first reading.  The name "java" is in this case both the module name and the name of a class in that module.  Based on the error message, the problem is the location of that init.pp file.  I explained the expected location in my previous post.

You may encounter a problem with that class in that some of the resources refer to others that are declared later in the class body.  I don't think Puppet is going to accept that, but the fix would be simply to re-order the resource declarations.

Also, if class 'java::params' is a pure parameters class (declaring no resources, directly or indirectly), then it would be better form to use the 'include' function rather than the 'require' function to include it.  The 'require' function is not harmful in that case, but it is a bit misleading because it has no more effect than a plain 'include'.


John

Reply all
Reply to author
Forward
0 new messages