Hi folks, Still a beginner with Puppet. I'm trying to set up a simple class for building a sysctl.conf, and I've hit a stumbling block. I could go with the sysctl solutions other people have written with custom ruby functions or augeas, but solving the problem I'm having might be instructive for other Puppet problems down the road, if you follow, so I'm asking what I'm doing wrong.
(I'm just creating a dummy file and not even putting it in sysctl.conf while I'm learning the infrastructure, so don't be alarmed by the goofy parameter names and values. :) First I have a modules/sysctl/manifests/init.pp which includes (some stuff omitted): class sysctl { $params = { 'mem_max' => '5G' } $params['mem_min'] = '1G' ## template file resource here points at an ERB template ## which loops over the keys/values of the $params hash. ## sparing you the details of the file resource for now since it works fine. :) file { ... } } So far so good! I get a file which looks like mem_max = 5G mem_min = 1G Okay. Now I try to get fancy and create a defined type that would let me add more sysctl entries. In modules/sysctl/manifests/add_param.pp: define sysctl::add_param ( $value ) { notify { "Setting $title to $value": } ## for debugging purposes $sysctl::params[$title] = $value } And then I add to the sysctl class: ## add the extra param ## add_param { 'mem_avg': value => '3G' } notify { "The params are ${params}": } What happens is, I see: "Setting mem_avg to 3G The params are mem_max5Gmem_min1G" and the produced file does not contain the new parameter. So it looks like the defined type resource does indeed get instantiated, and its internal notify {} shows the right thing, but it doesn't actually add to the $sysctl::params hash. What makes this extra-frustrating is, it doesn't give any error message about not being able to, either -- it just silently fails. Can a defined type not modify the variables in its parent namespace? If not, why am I not getting an error message? If it can, what am I doing wrong? The use case for the whole defined type mess is, supposing later I want to do something like this, to set sysctl parameters specific to a given software class. class oracle { sysctl::add_param{ 'oracle_wants_lots_of_ram': value => '1' } } I'm perfectly fine with being told "your overall use case needs hiera" or something (which will probably have me coming back with more questions), but I'll particularly appreciate knowing why the thing I'm actually trying isn't working, as I'm still learning the basics. :) Thanks! BTW, this is with Puppet open source 3.0.0. Cheers, --Shawn -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/CsGGfCkcUVIJ. To post to this group, send email to puppet-users@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.