In my network every subnets default gateway is X.X.X.1. That router gateway is always running ntpd which I want to give be default as the ntp server in every hosts ntp.conf. Since there is no official "default gateway" fact yet, what I want to be able to do in my manifest is take the $ipaddress fact and turn it into the gateway for that subnet. For example... IP = 10.1.1.12 GW = 10.1.1.1 I''m using the puppetlabs-ntp module, so I should be able to do something like this in my classes...I think... I just need to know how to get the .1 address in there... class mycustomclass:ntp { class { "ntp": servers => [ DOT_ONE_ADDRESS_FOR_HOSTS_IP_GOES_HERE ], autoupdate => false, } } If this was raw ruby I could do some string magic to turn the last value to 1. I don''t know how to do that with the Puppet DSL though. Thanks, Matt -- 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.
Kinzel, David
2012-Feb-29 18:43 UTC
RE: [Puppet Users] Modifying a FACT Value In a Manifest
> In my network every subnets default gateway is X.X.X.1. That router gateway is always running ntpd which I want to give be default as the ntp server in every hosts ntp.conf.> Since there is no official "default gateway" fact yet, what I want to be able to do in my manifest is take the $ipaddress fact and turn it into the gateway for that subnet.Something like: $router = regsubst($ipaddress, ''[0-9]+$'', ''1'') Should replace all the last numbers of the ipaddress with simply 1. This email communication and any files transmitted with it may contain confidential and or proprietary information and is provided for the use of the intended recipient only. Any review, retransmission or dissemination of this information by anyone other than the intended recipient is prohibited. If you receive this email in error, please contact the sender and delete this communication and any copies immediately. Thank you. http://www.encana.com -- 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.
Peter Bukowinski
2012-Feb-29 19:01 UTC
Re: [Puppet Users] Modifying a FACT Value In a Manifest
On Feb 29, 2012, at 1:10 PM, Matt Mencel wrote:> In my network every subnets default gateway is X.X.X.1. That router gateway is always running ntpd which I want to give be default as the ntp server in every hosts ntp.conf. > > Since there is no official "default gateway" fact yet, what I want to be able to do in my manifest is take the $ipaddress fact and turn it into the gateway for that subnet. > > For example... > IP = 10.1.1.12 > GW = 10.1.1.1 > > I''m using the puppetlabs-ntp module, so I should be able to do something like this in my classes...I think... I just need to know how to get the .1 address in there... > > class mycustomclass:ntp { > class { "ntp": > servers => [ DOT_ONE_ADDRESS_FOR_HOSTS_IP_GOES_HERE ], > autoupdate => false, > } > } > > If this was raw ruby I could do some string magic to turn the last value to 1. I don''t know how to do that with the Puppet DSL though. > > Thanks, > MattOh, look. I get to be useful! I''ve done something similar for my computer cluster class. I base the ip of the eth4 interface off the ip of eth0, changing one octet from 39 to 38. Here''s the line: $eth4ip = regsubst($::ipaddress_eth0, ''\.39\.'', ''.38.'') For your purpose, you''d need to do something like this: $ntpip = regsubst($::ipaddress, ''[0-9]+$'', ''1'') -- Peter M. Bukowinski Sr. Systems Engineer Janelia Farm Research Campus, HHMI -- 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.
Thanks to both of you... :) Matt ------------------------------ *From: *"Peter Bukowinski" <pmbuko@gmail.com> *To: *puppet-users@googlegroups.com *Sent: *Wednesday, February 29, 2012 1:01:14 PM *Subject: *Re: [Puppet Users] Modifying a FACT Value In a Manifest On Feb 29, 2012, at 1:10 PM, Matt Mencel wrote: In my network every subnets default gateway is X.X.X.1. That router gateway is always running ntpd which I want to give be default as the ntp server in every hosts ntp.conf. Since there is no official "default gateway" fact yet, what I want to be able to do in my manifest is take the $ipaddress fact and turn it into the gateway for that subnet. For example... IP = 10.1.1.12 GW = 10.1.1.1 I''m using the puppetlabs-ntp module, so I should be able to do something like this in my classes...I think... I just need to know how to get the .1 address in there... class mycustomclass:ntp { class { "ntp": servers => [ DOT_ONE_ADDRESS_FOR_HOSTS_IP_GOES_HERE ], autoupdate => false, } } If this was raw ruby I could do some string magic to turn the last value to 1. I don''t know how to do that with the Puppet DSL though. Thanks, Matt Oh, look. I get to be useful! I''ve done something similar for my computer cluster class. I base the ip of the eth4 interface off the ip of eth0, changing one octet from 39 to 38. Here''s the line: $eth4ip = regsubst($::ipaddress_eth0, ''\.39\.'', ''.38.'') For your purpose, you''d need to do something like this: $ntpip = regsubst($::ipaddress, ''[0-9]+$'', ''1'') -- *Peter M. Bukowinski* Sr. Systems Engineer Janelia Farm Research Campus, HHMI -- 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. -- 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.