On Nov 18, 7:09 pm, "russell.fulton" <russell.ful...@gmail.com> wrote:
> I am trying to import a hash definition from a separate file but this
> fails whereas including the text verbatim in the original manifest
> works fine:
>
> class monitor ($master, $interface)  {
>
> #  import "masters.pp"
>
>    $sensor_rule_categories = {
[...]
>     }
>
>    $rule_files = $sensor_rule_categories[$master]

[}]

> if I have the definition $sensor_rule_categories in the file ./
> masters.pp then I get the error:

[...]

> I really want to have this stuff in a separate file as it is generated
> elsewhere I want to have a symlink to the file with the defs rather
> than have to hack at init.pp itself.
>
> I guess my real question is what are the constraints on the contents
> of 'imported ' files?

Do not think of the Puppet "import" statement like the C
preprocessor's #include directive.  They are not analogous.  Puppet's
"import" is more like Java's "import": it makes complete manifest
subunits (classes and definitions) available within the importing
manifest.

See http://docs.puppetlabs.com/guides/language_tutorial.html#importing-manifests

(though that doesn't say much more than I already have done).

In addition:

1) You can still put your hash in a separate file by wrapping it in
its own class.  To use it, include the class (after importing its
manifest, if necessary), and reference the variable by its fully-
qualified name.

2) At first I read your comments about init.pp as indicative that
you're putting everything in the master manifest.  Now I'm not so
sure, but if that's indeed what you are doing then I strongly advise
you to structure your manifests into modules instead.

3) If you *are* using modules, and you are following the naming and
structure guidelines, then you should never need to explicitly import
anything.

4) I'm curious why you need to generate your "$sensor_rule_categories"
hash externally.  There's nothing particularly wrong with doing that,
but it seems like it would limit your ability to expand your use of
Puppet.

> Also, should I report (where ?) things that make puppet return ruby
> errors so they can be 'rescued' and have a more meaningful error
> message given?  I'm happy to file bug report if there is an intention
> to fix things like this.

The top page of the Puppetlabs bug tracker is

http://projects.puppetlabs.com/

Puppetlabs is very active fixing bugs and developing new features for
Puppet.  They crave issue reports.  (And also bugfixes!  Puppet is
open source, you know.)  However, I cannot speak to how any particular
report will be prioritized or what kind of resolution it might
receive.


Best,

John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to