Jason Antman
2013-Sep-18 12:36 UTC
[Puppet Users] ENC paramater interpolation in ENC, and inline templates
I''m in the process of rolling out a new homegrown ENC (we''ve decided on using an ENC over hiera; I know it''s not the way a lot of you are going, but it''s right for us) and am running into some issues with variable interpolation in ENC data. To give a concrete example, I''m using modules to configure puppetdb, puppet master, and puppet clients. So, there''s a bunch of shared data within an environment (like the server name, port, etc.). What I''d like to do is have my ENC set a top-level param hash like: puppet_config: server: puppet.example.com port: 8140 puppetdb_host: puppetdb.example.com and then interpolate that into my ENC-specified classes like: classes: puppet::client: server: "${puppet_config[server]}" So as far as I can tell, I''m running into two isses: 1) There''s no real hash interpolation, only inline templates. And I assume that I can''t put an inline template as the value of a class param. So it looks like that''s not going to be solved any time soon. 2) Even if I ditch the hash and just use straight params, i.e. classes: interpolate_test: ival: "${::my_ival}" parameters: my_ival: param_ival_value and then in interpolate_test: class interpolate_test($ival) { notice("interpolate_test - value of ival is ${ival}") notice("interpolate_test - value of ::my_ival is ${::my_ival}") } I end up seeing: Notice: Scope(Class[Interpolate_test]): interpolate_test - value of ival is ${::my_ival} Notice: Scope(Class[Interpolate_test]): interpolate_test - value of ::my_ival is param_ival_value Any ideas on how to get this to work? Is it even possible? Or do I just need to throw up my hands, and decide that either: a) I can''t use ENC params that way, so I''m just going to have to define these params over and over again and try to keep the same values in every place, or, b) I need to (yuck) build pre-YAML-serialization variable interpolation *into my ENC*... Thanks for any advice, Jason Antman -- 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.
jcbollinger
2013-Sep-19 14:08 UTC
[Puppet Users] Re: ENC paramater interpolation in ENC, and inline templates
On Wednesday, September 18, 2013 7:36:01 AM UTC-5, Jason Antman wrote:> > I''m in the process of rolling out a new homegrown ENC (we''ve decided on > using an ENC over hiera; I know it''s not the way a lot of you are going, > but it''s right for us) and am running into some issues with variable > interpolation in ENC data. > >That''s because Puppet does not do any interpolation of variable and parameter values specified by an ENC. Interpolation is a DSL feature, and using an ENC to declare variables and parameters bypasses the DSL. Therefore, if you want to use an ENC then it must be smart enough to output the needed values as literals. You might be able to massage that requirement a little, however, by creating wrapper classes for your ENC to declare, wherein the desired interpolation is performed and the results forwarded to the real target classes. 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.