Am I missing some clever way to use variables containing a dash in the name? We''re using LDAP nodes I may have a node like this example: dn: cn=ns01.domain.com,cn=machines,o=domain cn: ns01.domain.com objectClass: top objectClass: puppetClient ipHostNumber: 192.201.112.90 parentnode: basenode-without-autofs puppetclass: default_access console-port: 7025@cyclada4 And I''d like to access ''console-port'' as a variable in a manifest. In ruby land I end up resorting to stupid tricks like instance_variable_get(''@console-port'') or [''console-port''] to get this. Any suggestions besides a hackier implementation of get_var() function? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Trevor Vaughan
2010-May-07 00:46 UTC
Re: [Puppet Users] ldap node attributes containing dash ( - )
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I don''t think that ruby itself allows variables with dashes in the name since it will probably interpret them as minus signs and try to interpret the variables around the symbol. Trevor On 05/06/2010 07:31 PM, donavan wrote:> Am I missing some clever way to use variables containing a dash in the > name? > > We''re using LDAP nodes I may have a node like this example: > > dn: cn=ns01.domain.com,cn=machines,o=domain > cn: ns01.domain.com > objectClass: top > objectClass: puppetClient > ipHostNumber: 192.201.112.90 > parentnode: basenode-without-autofs > puppetclass: default_access > console-port: 7025@cyclada4 > > And I''d like to access ''console-port'' as a variable in a manifest. In > ruby land I end up resorting to stupid tricks like > instance_variable_get(''@console-port'') or [''console-port''] to get > this. > > Any suggestions besides a hackier implementation of get_var() function? >- -- Trevor Vaughan Vice President, Onyx Point, Inc. email: tvaughan@onyxpoint.com phone: 410-541-ONYX (6699) pgp: 0x6C701E94 - -- This account not approved for unencrypted sensitive information -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkvjYvoACgkQyWMIJmxwHpTm9ACeO7bvFMVPYLaIRi9mOjZvPOPA TYAAn03GCbYaC+5kr/AogVsJ7o12dNLd =aaay -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
donavan
2010-May-07 17:44 UTC
[Puppet Users] Re: ldap node attributes containing dash ( - )
On May 6, 5:46 pm, Trevor Vaughan <tvaug...@onyxpoint.com> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > I don''t think that ruby itself allows variables with dashes in the name > since it will probably interpret them as minus signs and try to > interpret the variables around the symbol.Right. Which is why, in ActiveLdap for example, I would have to use a string with the hash access method:>> ns01.cn=> "ns01.domain.com">> ns01.dns-nsNoMethodError: undefined method `dns'' for #<Machine:0x240ea28>>> ns01["cn"]=> "ns01.domain.com">> ns01["dns-ns"]=> "10041801" And in other cases I could use the instance_variable_get method to pull it out:>> ns01.instance_variable_get("@data")["dns-ns"]=> ["10041801"] But I don''t have either of those from a manifest. So I can trysomething like get_var[1]. I was just hoping someone out there had a cleaner work around for me. [1] http://projects.puppetlabs.com/projects/puppet/wiki/Ldap_Nodes -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
donavan
2010-May-07 17:54 UTC
[Puppet Users] Re: ldap node attributes containing dash ( - )
On May 6, 4:31 pm, donavan <dona...@desinc.net> wrote:> Am I missing some clever way to use variables containing a dash in the > name? > > We''re using LDAP nodes I may have a node like this example:..> And I''d like to access ''console-port'' as a variable in a manifest.Reading over I realize this may not be clear to people not using LdapNodes[1]. "All attributes on the LDAP nodes are assigned as variables in the Puppet configuration". This gives you puppet variables like $ipHostNumber for free. I have an LDAP attribute I need to check from inside my manifest. The issue is the attribute name contains a dash. So I can''t use the regular semantics of $<attribute name> to access it. Any way to get this attribute without a hacky function/template? [1] http://projects.puppetlabs.com/projects/puppet/wiki/Ldap_Nodes -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Jesús M. Navarro
2010-May-07 20:16 UTC
Re: [Puppet Users] Re: ldap node attributes containing dash ( - )
On Friday 07 May 2010 19:54:18 donavan wrote:> On May 6, 4:31 pm, donavan <dona...@desinc.net> wrote: > > Am I missing some clever way to use variables containing a dash in the > > name? > > > > We''re using LDAP nodes I may have a node like this example: > > .. > > > And I''d like to access ''console-port'' as a variable in a manifest. > > Reading over I realize this may not be clear to people not using > LdapNodes[1]. "All attributes on the LDAP nodes are assigned as > variables in the Puppet configuration". This gives you puppet > variables like $ipHostNumber for free. > > I have an LDAP attribute I need to check from inside my manifest. The > issue is the attribute name contains a dash. So I can''t use the > regular semantics of $<attribute name> to access it. Any way to get > this attribute without a hacky function/template?Won''t use the ${variable-name} version do the trick? Cheers. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
donavan
2010-May-08 01:59 UTC
[Puppet Users] Re: ldap node attributes containing dash ( - )
On May 7, 1:16 pm, "Jesús M. Navarro" <jesus.nava...@andago.com> wrote:> Won''t use the ${variable-name} version do the trick? > Cheers.I tried that initially, but it wouldn''t pass --parseonly (.24.8) so I didn''t commit it. Let me check manually.. Yeah, parseonly and actual catalog compilation both fail: err: Could not parse for environment production: Could not match ''$ {dns-ns}'' at init.pp:38 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.