Maxim Ianoglo
2013-Mar-28 12:48 UTC
[Puppet Users] puppet 3.x selectors with hashes - syntax error
Hello, I am facing a issue that is not present in Puppet version 2.X. At construction like: $panel_tcp_in = $control_panel ? { cpanel => {''admin_interface'' => ''2087'', ''user_interface'' => ''2077,2078,2082,2083,2086,2095,2096''}, directadmin => {''admin_interface'' => ''2222'', ''user_interface'' => ''2222''}, plesk => {''admin_interface'' => ''8443'', ''user_interface'' => ''8443''}, default => {''admin_interface'' => '''', ''user_interface'' => ''''} } I am getting: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ''{''; expected ''}'' at .... on node .... Did anyone face such issue before ? may be there is custom patch or something that could fix this ... i have open issue request: http://projects.puppetlabs.com/issues/19908 OS: CentOS 6 64 bit Ruby: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux] Puppet: 3.1.1 Thank you. -- Maxim Ianoglo -- 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Mar-29 13:24 UTC
[Puppet Users] Re: puppet 3.x selectors with hashes - syntax error
It looks like a bug to me, but there''s a pretty easy workaround: pull out the selector body as a hash of hashes, and select the desired value via ordinary hash indexing. The only trick is handling the ''default'' case, but that''s doable: $panel_options = { cpanel => {''admin_interface'' => ''2087'', ''user_interface'' => ''2077,2078,2082,2083,2086,2095,2096''}, directadmin => {''admin_interface'' => ''2222'', ''user_interface'' => ''2222''}, plesk => {''admin_interface'' => ''8443'', ''user_interface'' => ''8443''} } if has_key($panel_options, $control_panel) { $panel_tcp_in = $panel_options[$control_panel] } else { $panel_tcp_in = {''admin_interface'' => '''', ''user_interface'' => ''''} } Note that the ''has_key'' function is not built-in; instead, it comes from Puppetlabs'' "stdlib" add-in module. You can achieve the same thing without, but it''s longer and uglier. 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.