FAQ
Hi John,

thanks for your answer, first of all I must say I just wanted to experiment
and learn, it's not like I'm going to put such "awful hacks" :-) in
production....mostly because I guess it's easy they can be changed over the
time as they are not part of puppet DSL and so, it can be harder to
maintain and for other colleagues to understand.

OK, now to the point...I forgot to include the node definition, sorry about
that, it looks like:

node hostname {
   class {'test1': }
   test1::print {'test11':
     message => 'test11',
   }
   test1::print {'test12':
     message => 'test13',
   }
   test1::print {'test13':
     message => 'test13',
   }

So I understand that when you say I haven't defined any resource it's
because I forgot to mention that part, right? If so, why the define types
are not showing up in the file? Also, as you can see in the content of the
file I included in my previous message, Class[test1] was declared and
showed in the content of the file, but the File resource itself was not
there when the template was built.

I have the feeling the template is evaluated before all this resources are
present in the catalog...am I wrong? Is that expected behavior?


Thanks.
Sergio.
On Tuesday, September 10, 2013 3:23:47 PM UTC+2, jcbollinger wrote:


On Monday, September 9, 2013 6:13:46 PM UTC-5, sjr wrote:

Hi,

I've been doing some tests with some internal methods just to mess a
little and learn a bit about puppet internals but found myself in a
situation which I don't really understand and I was hoping someone around
could help me to get it.

I have a test module with the following init.pp:

class test1
{

file
{'/tmp/test1':

content =>
template('test1/test1.erb'),


}



Test1::Print <| |> ->
File['/tmp/test1']

}

The define test1::print looks like:

define test1::print
(


$message

)
{

notify{$message:
}

}

So nothing really special, then in the template I try to catch all the
resources in the catalog with "scope.catalog.resources" method, nothing I
came up with by myself I saw it in a module and thought it was a neat trick
and wanted to try it and learn what else I could do with this kind of stuff.

The problem I'm having is that the template seems to be "compiled" before
all the resources are in the catalog as the file only contains the
following list of resources:

Stage[main]
Class[Settings]
Class[main]
Node[default]
Class[Test1]

In puppet's output, the relationships seem to be well defined but feels
like puppet is somehow applying (catching?) the template even before
creating the actual file.

The template has the following content:

<% @test = scope.catalog.resources.select { |r| r.type } -%>
<% @test.each do |t| -%>
<%= t %>
<% end %>

Am I missing anything? I expected to see in the file the defined type
test1::print...
You are missing several things, including at least

1. Puppet relationships, such as are declared via the arrow operators
or 'require' and 'before' metaparameters, influence only the order in which
resources are applied by the agent. They have no bearing on the order of
events during catalog compilation.
2. Defined types are *types*, not resources. They are thoroughly
analogous to native resource types such as File. You could see *
instances* of defined types among your catalog resources if you
declared any (you didn't), but you will not see the defined types
themselves.
3. scope.catalog.resources is an awful hack, not a "neat trick",
because it is sensitive to when during the compilation process the template
is evaluated. To build robust and reliable classes and modules you must
avoid depending on mechanisms that are sensitive to evaluation order
(sometimes inaccurately called "parse order", including by me).


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.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 5 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 9, '13 at 11:13p
activeSep 11, '13 at 1:37p
posts5
users2
websitepuppetlabs.com

2 users in discussion

Jcbollinger: 3 posts Sjr: 2 posts

People

Translate

site design / logo © 2022 Grokbase