# question on included classes with parameters

I am running puppet 4.10.7 under foreman and have an issue with including declared classes under other classes. In particular, I have the puppet/yum module installed and am using it to define a set of yum repositories that will be installed for all systems. Now I want to define another class that will be applied to a subset of those systems and I need a yum repository defined only for those systems. I have tried multiple solutions, none of which work, What I'd like to do is in my init.pp have

 class batch ( $repo=false) { include yum if ($repo) {
yum::managed_repos($repo) } }  This obviously does not work to install the repository file. What would work in this case? edit retag close merge delete ## Comments 1 I think I'm still unclear on what you are trying to do... In puppet, you can only instantiate a single version of a class. If you declare the same class with different parameters, that is syntactically incorrect and your catalog will fail to compile ( 2018-01-24 10:55:37 -0500 )edit If you have a set of repos, with a specific subset under it, your only option is to either make two classes, or make a single class aware of the subset, and pass the parameters to it. In one case you're duplicating some code for readability/separation of concerns, in the other you are coupling ... ( 2018-01-24 10:57:09 -0500 )edit ... the two ideas together into a single class with some internal logic to apply different configurations to the internal parts, but that may make more sense for your org. ( 2018-01-24 10:57:51 -0500 )edit ## 1 Answer Sort by » oldest newest most voted No, you have to use resource-like class declarations in order to define class parameters (inside your Puppet manifest). That means, you have build expressions evaluating to the proper class parameter's value: class batch ( Optional[Array[String[1], 1]]$repo = undefined,
) {
class { 'yum':
managed_repos => \$repo,
}
}


I don't know whether the +> “plusignment” works on classes, too.

more