Joel Heenan
2009-May-29 06:19 UTC
[Puppet Users] How do I access a nodes variables from outside the scope
I thought the following would work and allow me to access a nodes variables from within a definition. It seems that classes and nodes, while similar, are different from the point of view of qualified variables. Can someone confirm this? The obvious workaround is to define all variables within a class and include it but when the variables are node specific that seems a bit lame. define xen_guest($dom0) { $guest_ip = $name::$ip } node "a" { $ip = 10.10.10.1 } node "b" { xen_guest{ "a": dom0 => $name } } Joel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Joel Heenan
2009-May-29 06:40 UTC
[Puppet Users] Re: How do I access a nodes variables from outside the scope
I think I''m going to try and do this with external types. Joel On Fri, May 29, 2009 at 4:19 PM, Joel Heenan <joelh@planetjoel.com> wrote:> I thought the following would work and allow me to access a nodes variables > from within a definition. It seems that classes and nodes, while similar, > are different from the point of view of qualified variables. > > Can someone confirm this? > > The obvious workaround is to define all variables within a class and > include it but when the variables are node specific that seems a bit lame. > > define xen_guest($dom0) > { > $guest_ip = $name::$ip > } > > node "a" { > $ip = 10.10.10.1 > } > > node "b" { > xen_guest{ "a": > dom0 => $name > } > } > > Joel >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Paul Gear
2009-Jun-04 22:29 UTC
[Puppet Users] Re: How do I access a nodes variables from outside the scope
On May 29, 4:40 pm, Joel Heenan <jo...@planetjoel.com> wrote:> I think I''m going to try and do this with external types.I''d be very interested to see what you end up doing with this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Brandon Whalen
2009-Jun-04 22:59 UTC
[Puppet Users] Environment variable access inside an exec
I''ve spent some time looking at the example recipes and reading the docs on a problem, but I''m still stumped. I''m trying to add some options to my fstab and am finding some problems. I''m using the environment option to create an environment variable MNT_OPTS that I then reference as part of a sed call. I''m finding that MNT_OPTS is empty when I reference it. My exact code is below. #nosuid, nodev, and acl on /home exec { "sed -i ''s/\( \/home.*${MNT_OPTS}\)/\1,nosuid,nodev,acl/'' /etc/fstab": onlyif => "test `grep '' \/home '' /etc/fstab | grep -c nosuid` -eq 0", environment => "MNT_OPTS=`grep '' \/home '' /etc/fstab | awk ''{print $4}''`"; } Could someone tell me what I''m doing wrong and tell me what I need to do to fix it or point me at some examples. Regards, Brandon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RijilV
2009-Jun-04 23:04 UTC
[Puppet Users] Re: Environment variable access inside an exec
2009/6/4 Brandon Whalen <bwhalen@tresys.com>:> > I''ve spent some time looking at the example recipes and reading the docs on > a problem, but I''m still stumped. I''m trying to add some options to my fstab > and am finding some problems. I''m using the environment option to create an > environment variable MNT_OPTS that I then reference as part of a sed call. > I''m finding that MNT_OPTS is empty when I reference it. My exact code is > below. > > #nosuid, nodev, and acl on /home > exec { "sed -i ''s/\( \/home.*${MNT_OPTS}\)/\1,nosuid,nodev,acl/'' > /etc/fstab": > onlyif => "test `grep '' \/home '' /etc/fstab | grep -c nosuid` -eq 0", > environment => "MNT_OPTS=`grep '' \/home '' /etc/fstab | awk ''{print > $4}''`"; > } > > > Could someone tell me what I''m doing wrong and tell me what I need to do to > fix it or point me at some examples.Puppet is likely trying to find the value of MNT_OPTS before it hands it off to the shell. Give it a a go with escaping it, same with that $4 in your awk. .r'' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Steven VanDevender
2009-Jun-04 23:06 UTC
[Puppet Users] Environment variable access inside an exec
Brandon Whalen writes: > > I''ve spent some time looking at the example recipes and reading the docs on > a problem, but I''m still stumped. I''m trying to add some options to my fstab > and am finding some problems. I''m using the environment option to create an > environment variable MNT_OPTS that I then reference as part of a sed call. > I''m finding that MNT_OPTS is empty when I reference it. My exact code is > below. > > #nosuid, nodev, and acl on /home > exec { "sed -i ''s/\( \/home.*${MNT_OPTS}\)/\1,nosuid,nodev,acl/'' > /etc/fstab": > onlyif => "test `grep '' \/home '' /etc/fstab | grep -c nosuid` -eq 0", > environment => "MNT_OPTS=`grep '' \/home '' /etc/fstab | awk ''{print > $4}''`"; > } AUGH! THIS IS INSANE! I AM INSANE NOW! > Could someone tell me what I''m doing wrong and tell me what I need to do to > fix it or point me at some examples. I strongly suggest that you look at the "mount" resource type. This thing you are doing with ''sed'' is nasty and dangerous. > Regards, > Brandon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mike Renfro
2009-Jun-04 23:12 UTC
[Puppet Users] Re: Environment variable access inside an exec
On 6/4/2009 5:59 PM, Brandon Whalen wrote:> I''ve spent some time looking at the example recipes and reading the docs on > a problem, but I''m still stumped. I''m trying to add some options to my fstab > and am finding some problems. I''m using the environment option to create an > environment variable MNT_OPTS that I then reference as part of a sed call. > I''m finding that MNT_OPTS is empty when I reference it. My exact code is > below.Unless you''re specifically trying to add options to whatever /home entry already exists, you might want to use the builtin mount type. I know you can use it to specify all the mount options, but I''m not sure if you can use the ''+>'' operator to add options to whatever exists. http://reductivelabs.com/trac/puppet/wiki/TypeReference#mount -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
lance dillon
2009-Jun-05 13:59 UTC
[Puppet Users] Re: Environment variable access inside an exec
You could also use augeas to manage those options. On Thu, Jun 4, 2009 at 7:12 PM, Mike Renfro <renfro@tntech.edu> wrote:> > On 6/4/2009 5:59 PM, Brandon Whalen wrote: > > I''ve spent some time looking at the example recipes and reading the docs > on > > a problem, but I''m still stumped. I''m trying to add some options to my > fstab > > and am finding some problems. I''m using the environment option to create > an > > environment variable MNT_OPTS that I then reference as part of a sed > call. > > I''m finding that MNT_OPTS is empty when I reference it. My exact code is > > below. > > Unless you''re specifically trying to add options to whatever /home entry > already exists, you might want to use the builtin mount type. I know > you can use it to specify all the mount options, but I''m not sure if you > can use the ''+>'' operator to add options to whatever exists. > > http://reductivelabs.com/trac/puppet/wiki/TypeReference#mount > > -- > Mike Renfro / R&D Engineer, Center for Manufacturing Research, > 931 372-3601 / Tennessee Technological University > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---