FAQ
Hi,

Trying to get some understanding on how code should be structured in
Puppet. I have a class oracle_java defined to deploy the Java virtual
machine on the agents (basically copy of
http://log.scalemotion.com/2013/04/oracle-java-under-linux-with-puppet.html).
It works fine if i copy the body of the class (omitting the class
declaration) within site.pp. But that's no way to do business as you may
presume.

Now, I put the class under /etc/puppet/manifests/jdk.pp and change site.pp
into:

node default{
include jdk
}

Unfortunately, this doesn't work. I keep getting the following error
message from the agent:

Could not retrieve catalog from remote server: Error 400 on SERVER: Could
not find class jdk for
ec2-52-221-193-75.compute-1.amazonaws.com-c1421f15-ac06-c6ab-6b5d-95f238bf27c7.

Is there a way to reference a class in site.pp without creating a module?

Thanks,
Max.

--
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Denmat at Apr 21, 2013 at 10:23 pm
    Hi Max,

    Making the module directory structure is pretty easy and will serve you well as you develop your manifest.

    mkdir -p /etc/puppet/manifests/jdk/manifests

    Then copy your jdk class into init.pp in that new directory.

    Alternatively you can add the import clause into site.pp to find your jdk class.

    import '*.pp'

    That will tell puppet to import any .pp file in the same directory as site.pp.

    Regards,
    Den
    On 21/04/2013, at 23:18, max.bridgewater@gmail.com wrote:

    Hi,

    Trying to get some understanding on how code should be structured in Puppet. I have a class oracle_java defined to deploy the Java virtual machine on the agents (basically copy of http://log.scalemotion.com/2013/04/oracle-java-under-linux-with-puppet.html). It works fine if i copy the body of the class (omitting the class declaration) within site.pp. But that's no way to do business as you may presume.

    Now, I put the class under /etc/puppet/manifests/jdk.pp and change site.pp into:

    node default{
    include jdk
    }

    Unfortunately, this doesn't work. I keep getting the following error message from the agent:

    Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class jdk for ec2-52-221-193-75.compute-1.amazonaws.com-c1421f15-ac06-c6ab-6b5d-95f238bf27c7.

    Is there a way to reference a class in site.pp without creating a module?

    Thanks,
    Max.
    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Joshua Gross at Apr 21, 2013 at 11:36 pm
    You will need to import your jdk class file in site.pp

    Something like this:

    import "jdk.pp"

    At the top of site.pp

    Cheers,
    Josh
    On Sunday, April 21, 2013 9:18:36 AM UTC-4, max.bri...@gmail.com wrote:

    Hi,

    Trying to get some understanding on how code should be structured in
    Puppet. I have a class oracle_java defined to deploy the Java virtual
    machine on the agents (basically copy of
    http://log.scalemotion.com/2013/04/oracle-java-under-linux-with-puppet.html).
    It works fine if i copy the body of the class (omitting the class
    declaration) within site.pp. But that's no way to do business as you may
    presume.

    Now, I put the class under /etc/puppet/manifests/jdk.pp and change site.pp
    into:

    node default{
    include jdk
    }

    Unfortunately, this doesn't work. I keep getting the following error
    message from the agent:

    Could not retrieve catalog from remote server: Error 400 on SERVER: Could
    not find class jdk for
    ec2-52-221-193-75.compute-1.amazonaws.com-c1421f15-ac06-c6ab-6b5d-95f238bf27c7.

    Is there a way to reference a class in site.pp without creating a module?

    Thanks,
    Max.
    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jcbollinger at Apr 22, 2013 at 3:40 pm

    On Sunday, April 21, 2013 8:18:36 AM UTC-5, max.bri...@gmail.com wrote:
    Hi,

    Trying to get some understanding on how code should be structured in
    Puppet. I have a class oracle_java defined to deploy the Java virtual
    machine on the agents (basically copy of
    http://log.scalemotion.com/2013/04/oracle-java-under-linux-with-puppet.html).
    It works fine if i copy the body of the class (omitting the class
    declaration) within site.pp. But that's no way to do business as you may
    presume.
    No, no way to do business at all.


    Now, I put the class under /etc/puppet/manifests/jdk.pp and change site.pp
    into:

    node default{
    include jdk
    }

    Unfortunately, this doesn't work. I keep getting the following error
    message from the agent:

    Could not retrieve catalog from remote server: Error 400 on SERVER: Could
    not find class jdk for
    ec2-52-221-193-75.compute-1.amazonaws.com-c1421f15-ac06-c6ab-6b5d-95f238bf27c7.

    The 'include' function operates on class names, not file names. Unless you
    have renamed the class, you should be writing "include 'oracle_java'".

    In light of that, it should be clear that the issue is largely one of
    instructing Puppet where to find the definition of the class you want to
    declare. There are three ways to do that:

    1. put the whole class definition (not just the body) in site.pp;
    2. 'import' the class's manifest *file* into site.pp; or
    3. correctly put the class into a module so that Puppet can find its
    manifest automatically.


    Is there a way to reference a class in site.pp without creating a module?
    Why don't you want to create a module? It's the right thing to do.

    The other respondents have covered 'import', which is the direct answer to
    your question. But don't do that. Creating a module is very simple --
    it's basically just a matter of creating a couple of directories. Putting
    your class into a module is mostly a matter of putting its file in the
    right place, with the right name. To create a one-class module containing
    your particular class, simply move /etc/puppet/manifests/jdk.pp to
    /etc/puppet/modules/oracle_java/manifests/init.pp. Done.

    There's room for refinement, however. Your class references a file whose
    source it assumes can be found on the master, in /etc/puppet/files/. It
    can continue to do so, but it would be far better to move the source file
    into the module, too, so that the whole is, um, modular. To do that, move
    /etc/puppet/files/jdk-7u17-linux-x64.tar.gz to
    /etc/puppet/module/oracle_java/files/jdk-7u17-linux-x64.tar.gz, and change
    the line 'source => "puppet:///files/${file_name}",' to 'source =>
    "puppet:///modules/oracle_java/${file_name}",'.

    There are further improvements that could be considered, but they go well
    beyond the scope of your question. You may need a bit more experience with
    Puppet before you are prepared look into such things.


    John

    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 21, '13 at 1:18p
activeApr 22, '13 at 3:40p
posts4
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase