Am Freitag, 16. Februar 2018 04:09:34 UTC+1 schrieb Jeremiah Powell:
>
> You can also use stages to define strong barriers to order large parts of 
> a task.  The canonical example is configuring a database before the 
> application that needs it.
>

But stages are not transitive either so the stage has to be given for every 
subclass like with the contain function.
 

>
> Using contain on a defined type is not a syntax error.  But you won't 
> provide any of the parameters on the defined type when you use contain.  
> This includes parameter like a unique name.  So the semantic meaning is 
> rather curious. It adds a tag to the define type with the name of the class 
> then adds a dependency between instances of the defined type and the 
> class.  All of the defined type instances. That won't help you, though, for 
> two reasons.  First, depending on the version of Puppet the resources in 
> the defined type won't get the relationship.
>

So the bottom-line is that for defined types the new contain function is 
useless and we need to stick to the anchor pattern. Sounds like an 
incomplete feature to me.
 

>
> Look at the graph for your node.
>
> You should see the resources in your sub-classes 'floating' off the 
> graph.  They should have no relationship to anything else.   
>
> Secondly, this will still have the same sub-class issue. You can see this 
> here:
>
>
> https://ask.puppet.com/question/18868/containment-with-role-and-profile-pattern/
>
>
thx for the link, good read. The light-weight version of the anchor pattern 
shown by Piennar should cover most cases and looks better than the anchors 
everywhere.
 

> Sub-sub-classes in Puppet are not tagged with their ancestor (parent and 
> parent's parent, etc) tags.  
>

Though i guess it would be possible to implement a transitive version of 
the contain function. This would make it easier for module writers and also 
for the users since it is clearly visible in the main class that everything 
happens in there and no resources are floating around.
 

>
> Setting containment manually adds all the tags for the current class 
> explicitly.  It also adds the relationship in the catalog between those 
> tags.
>
> In the link above: role class -> profile class -> utility class -> 
> resource.  The resource is tagged with the utility class's name but not the 
> profile or role name.  So you could not create relationships at the 
> meta-level of roles or profiles.
>
> Requires is another way to do this.
>
> https://puppet.com/docs/puppet/5.4/lang_classes.html#using-include
>
> The function create_resources() was a great way to trigger this behavior 
> for a long time. Resources generated by this function did not have tags 
> from the class in which create_resources was run.  Using create_resources 
> to get  'fake looping' means explicit resource dependencies were required.  
>
> This is one reason to replace create_resources with using the hash (* =>) 
> attribute and lambdas.
>
>
> https://puppet.com/docs/puppet/4.9/lang_resources_advanced.html#implementing-the-createresources-function
>
> I still order things explicitly at the resource level.   Abstractions like 
> classes and defines are nice programmer candy.  The Puppet agent only cares 
> about the resources in the catalog. If  I'm having to add contains 
> everywhere that tells me my fancy class structure is not adding value.  It 
> is just adding more work for me.
>
> In the end it is about making a server do something correct.  Do I want a 
> service to start after another service? I include the dependency between 
> the service resources directly.  The result is that I have much smaller 
> modules with obvious behavior.
>
> On Thursday, February 15, 2018 at 2:02:41 AM UTC+8, Peter Bauer wrote:
>>
>> hi,
>>
>> i was recently bitten by ordering issues caused by missing contain/anchor 
>> declarations in a PostgreSQL module which should have finished its job 
>> before configuring and starting the PuppetDB which is done by another 
>> module.
>> So here are my questions:
>> - is it possible to use the contain function also for defined resource 
>> types/defines? I ended up using anchors since i could not find out how to 
>> use contain here.
>> - am i the only one thinking that it is too error-prone and cumbersome to 
>> add a contain everytime a sub-class is instantiated in a module? Since it 
>> is not transitive it has to be added on every abstraction layer of a 
>> module, from the init.pp down to all sub-classes until there are just 
>> classes left declaring resources directly. And in case one contain is 
>> missing, that code may be executed in the wrong time.
>>
>> thx,
>> Peter
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/af7d8874-fb60-425b-82b5-bd69a9e5c518%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to