Hi I have a serires of servers that their hostname (not FQDN) is built in the same manner [header, 3 letters][collo, 4 letters][environment, 3 letters][number, 4 digits]. There''s no specific separator between each part of hostname. Is there way I can extract the collo part of the hostname in puppet? TIA Paolo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/M8d-zyzlHw8J. 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 can use regex for that Here is an piece of my code for doing that. In my case [environment, 1 letter][collo, 2 letters] if $hostname =~ /^(.)(..)/ { $global_env = $1 $location = $2 } Steven Date: Wed, 24 Oct 2012 07:14:50 -0700 From: paolo.supino@gmail.com To: puppet-users@googlegroups.com Subject: [Puppet Users] puppet facter variable substring Hi I have a serires of servers that their hostname (not FQDN) is built in the same manner [header, 3 letters][collo, 4 letters][environment, 3 letters][number, 4 digits]. There''s no specific separator between each part of hostname. Is there way I can extract the collo part of the hostname in puppet? TIA Paolo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/M8d-zyzlHw8J. 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.
Hi Steven Why the if statement? TIA Paolo On Wednesday, October 24, 2012 5:58:16 PM UTC+2, Steven wrote:> > You can use regex for that > > Here is an piece of my code for doing that. In my case [environment, 1 > letter][collo, 2 letters] > > if $hostname =~ /^(.)(..)/ { > $global_env = $1 > $location = $2 > } > > Steven > > > ------------------------------ > Date: Wed, 24 Oct 2012 07:14:50 -0700 > From: paolo....@gmail.com <javascript:> > To: puppet...@googlegroups.com <javascript:> > Subject: [Puppet Users] puppet facter variable substring > > Hi > > I have a serires of servers that their hostname (not FQDN) is built in the > same manner [header, 3 letters][collo, 4 letters][environment, 3 > letters][number, 4 digits]. > There''s no specific separator between each part of hostname. Is there way > I can extract the collo part of the hostname in puppet? > > > > TIA > Paolo > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/M8d-zyzlHw8J. > To post to this group, send email to puppet...@googlegroups.com<javascript:> > . > To unsubscribe from this group, send email to > puppet-users...@googlegroups.com <javascript:>. > 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 view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Z5GXvX1kvW4J. 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.
Not sure if puppet will let you access regex without being in some type of test. Also, just habit. I''m usually doing some validation in the regex. In this case, I''ve moved validation to after this and have it validate against data in hiera. Hiera has a list of the valid data center codes. Steven Date: Thu, 25 Oct 2012 01:13:04 -0700 From: paolo.supino@gmail.com To: puppet-users@googlegroups.com Subject: Re: [Puppet Users] puppet facter variable substring Hi Steven Why the if statement? TIA Paolo On Wednesday, October 24, 2012 5:58:16 PM UTC+2, Steven wrote: You can use regex for that Here is an piece of my code for doing that. In my case [environment, 1 letter][collo, 2 letters] if $hostname =~ /^(.)(..)/ { $global_env = $1 $location = $2 } Steven Date: Wed, 24 Oct 2012 07:14:50 -0700 From: paolo....@gmail.com To: puppet...@googlegroups.com Subject: [Puppet Users] puppet facter variable substring Hi I have a serires of servers that their hostname (not FQDN) is built in the same manner [header, 3 letters][collo, 4 letters][environment, 3 letters][number, 4 digits]. There''s no specific separator between each part of hostname. Is there way I can extract the collo part of the hostname in puppet? TIA Paolo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/M8d-zyzlHw8J. To post to this group, send email to puppet...@googlegroups.com. To unsubscribe from this group, send email to puppet-users...@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 view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Z5GXvX1kvW4J. 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.