I need to convert a value from facter to lower case for inclusion in a path. Is there a built-in function for that? David -- 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.
On Thu, Jul 21, 2011 at 4:10 PM, David Kavanagh <dkavanagh@gmail.com> wrote:> I need to convert a value from facter to lower case for inclusion in a > path. Is there a built-in function for that?Not builtin, but you can use this: https://github.com/puppetlabs/puppetlabs-functions/blob/master/lib/puppet/parser/functions/downcase.rb Nan -- 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.
On Thu, 21 Jul 2011 16:10:02 -0400, David Kavanagh wrote:> > I need to convert a value from facter to lower case for inclusion in a > path. Is there a built-in function for that? > > David >Hm...doesn''t actually look like there is. % ls -1 lib/puppet/parser/functions create_resources.rb defined.rb extlookup.rb fail.rb file.rb fqdn_rand.rb generate.rb include.rb inline_template.rb md5.rb realize.rb regsubst.rb require.rb search.rb sha1.rb shellquote.rb split.rb sprintf.rb tagged.rb tag.rb template.rb versioncmp.rb It would be pretty easy to add a custom function that does this (and we really should have to_lower, and to_upper functions that are available out of the box). In the meantime, you should be able to do this with something like (replacing upcase with downcase): file { "/tmp/bar": ensure => file, content => inline_template("<%= hostname.upcase %>") } This was only tested against the current master branch of Puppet, so your mileage may vary. -- Jacob Helwig ,---- | Join us for PuppetConf, September 22nd and 23rd in Portland, OR | http://bit.ly/puppetconfsig `----
On Thu, 21 Jul 2011 16:31:39 -0400, Nan Liu wrote:> > On Thu, Jul 21, 2011 at 4:10 PM, David Kavanagh <dkavanagh@gmail.com> wrote: > > I need to convert a value from facter to lower case for inclusion in a > > path. Is there a built-in function for that? > > Not builtin, but you can use this: > > https://github.com/puppetlabs/puppetlabs-functions/blob/master/lib/puppet/parser/functions/downcase.rb > > Nan >So, why don''t we have downcase in core Puppet? :-\ -- Jacob Helwig ,---- | Join us for PuppetConf, September 22nd and 23rd in Portland, OR | http://bit.ly/puppetconfsig `----
* David Kavanagh <dkavanagh at gmail.com> [2011/07/21 16:10]:> I need to convert a value from facter to lower case for inclusion > in a path. Is there a built-in function for that?$ cat /tmp/foo.pp $foo = "STUFF" $foo_l = inline_template("<%= foo.downcase %>") notice("$foo -> $foo_l") $ puppet /tmp/foo.pp notice: Scope(Class[main]): STUFF -> stuff -- I look for what needs to be done.... After all, that''s how the universe designs itself. -- R. Buckminster Fuller -- 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.
On Thu, Jul 21, 2011 at 13:43, Jacob Helwig <jacob@puppetlabs.com> wrote:> On Thu, 21 Jul 2011 16:31:39 -0400, Nan Liu wrote: >> >> On Thu, Jul 21, 2011 at 4:10 PM, David Kavanagh <dkavanagh@gmail.com> wrote: >> > I need to convert a value from facter to lower case for inclusion in a >> > path. Is there a built-in function for that? >> >> Not builtin, but you can use this: >> >> https://github.com/puppetlabs/puppetlabs-functions/blob/master/lib/puppet/parser/functions/downcase.rb > > So, why don''t we have downcase in core Puppet? :-\Because about one in five of them is not actually *finished*, some of them seem to replicate core functionality, the testing is weak, and they all actually pass the tests that are currently defined – even the functions that are literally just "do nothing at all". Progress is being made to bring them up to standard, but I am still vaguely surprised they have not started to merge in as they get done, and that they are being developed aside from the core. Daniel -- ⎋ Puppet Labs Developer – http://puppetlabs.com ♲ Made with 100 percent post-consumer electrons -- 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.
> Because about one in five of them is not actually *finished*So currently the incomplete functions are: date is_float is_integer is_numberic is_valid_domain_name is_valid_ip_address is_valid_mac_address is_valid_netmask rand squeeze If anyone wants to help complete these - I''m happy to take patches :-). My day job is a professional services engineer so I work on these items when I possibly can - so any help is appreciated.> some of them seem to replicate core functionality,Which ones in particular?> the testing is weakSo I pushed out patches previously to solve a lot of the testing on these. Any particular problems you still see?> and they all actually pass the tests that are currently defined – even the > functions that are literally just "do nothing at all".Apologies - feel free to raise bugs on these ones if you like.> Progress is being made to bring them up to standard, but I am still > vaguely surprised they have not started to merge in as they get done, > and that they are being developed aside from the core.Surprised? Why? No one has asked me - at least not directly (I work in the UK so I don''t always hear about these ideas) :-). ken. -- "Join us for PuppetConf, September 22nd and 23rd in Portland, OR: http://bit.ly/puppetconfsig" -- 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.