Hello puppet Team !

I have trouble upgrading some code from puppet-3.7 to puppet-4.8.

I have a class, a defined type, and a sub-defined type like this :

define mainclass::myress::sub {

   # access to : 
   # $mainclassvar
   # $myressvar
}

define mainclass::myress($arga = $title, $argb) {

   #access to $arga, $argb, $mainclassvar
   #to compute the value of :
   
   $myressvar = ....

   # and declare a new ressource
   mainclass::myress::sub { "$somethingunique":
      ...
}

class mainclass {

   $mainclassvar = "main"

   mainclass::myress { 'myressv1':
      argb => '1',
   }

   mainclass::myress { 'myressv2':
      argb => '2',
   }
}

So there is two "mainclass::myress" declaration. Each one have a different 
value of $myressvar inside the ressource. And each one declare one 
"mainclass::myress::sub" ressource. In puppet 3.7 everything works just 
like this. And

-> In the "mainclass::myress::sub" déclared by "myressv1" I can access the 
value of the "$myressvar" variable of the "myressv1" ressource just by 
"$myressvar". So using the "$myressvar" variable inside 
"mainclass::myress::sub" I get the value of the parent ressource.

In puppet 4.8 this is not allowed so I need to use maybe fully qualified 
name. But I don't know the best practice to access the parent ressources 
variables and the parent class variables.

I can pass all the variables by parameters. But there is many value to pass 
and they are mainly constants. So how can I do ?

In "mainclass::myress::sub" can I access to the main class variables like 
this  ?

define mainclass::myress::sub {

   $mainvar = $mainclass::mainclassvar
}

Or is this preferable to get the variable first in "mainclass::myress" and 
after in "mainclass::myress:sub" ?

And how can I access the "$myressvar" value of the parent ressources ? Is 
this works ?

define mainclass::myress::sub {

   $mainclassvar = $mainclass::mainclassvar
   $myressvar = $mainclass::myress::myressvar
}

Is this a good practice ?

If someone can help me.

Thanks !

Baptiste.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f665082a-3e81-470a-b218-48ff9be94b75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to