I have a node definition that passes a parameter that sets a certain version of code being installed on a node, like this... elements::customer { tfel0: ensure => running, enable => true, version_core => "1.18.29-1", ... } Our developers decided that versions of code after 1.22 need a new file deployed . I therefore need to do a numerical comparison on $version_core and it''s greater than or equal to 1.22, push this file. I can''t get it to work. I can''t do a pure mathematical comparison because the "-" is in the version number. I tried splitting that into two and passing the version as 1.18.29, but puppet complains about the ".".... you can''t pass a float to a definition? This is version 0.24.8.... what options do I have? Doug. -- 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 Mon, 26 Jul 2010, Douglas Garstang wrote: [need to compare two version numbers: "1.18.29-1" and "1.22"]> > I can''t do a pure mathematical comparison because the "-" is in the > version number. I tried splitting that into two and passing the > version as 1.18.29, but puppet complains about the ".".... you can''t > pass a float to a definition?You can pass a string to a definition. 1.18.29 doesn''t look like a float.> This is version 0.24.8.... what options do I have?You can use the versioncmp function. It didn''t quite work in puppet 0.24.8, but if you copy lib/puppet/parser/functions/versioncmp.rb from puppet-0.25.0 then it should work. See issue #2110. I think you want somethng like this: if (versioncmp($version, "1.22") >= 0) { # do stuff } --apb (Alan Barrett) -- 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 Alan. That did the trick. On Mon, Jul 26, 2010 at 10:27 AM, Alan Barrett <apb@cequrux.com> wrote:> On Mon, 26 Jul 2010, Douglas Garstang wrote: > [need to compare two version numbers: "1.18.29-1" and "1.22"] >> >> I can''t do a pure mathematical comparison because the "-" is in the >> version number. I tried splitting that into two and passing the >> version as 1.18.29, but puppet complains about the ".".... you can''t >> pass a float to a definition? > > You can pass a string to a definition. 1.18.29 doesn''t look like a float. > >> This is version 0.24.8.... what options do I have? > > You can use the versioncmp function. It didn''t quite work in puppet > 0.24.8, but if you copy lib/puppet/parser/functions/versioncmp.rb from > puppet-0.25.0 then it should work. See issue #2110. > > I think you want somethng like this: > > if (versioncmp($version, "1.22") >= 0) { > # do stuff > } > > --apb (Alan Barrett) > > -- > 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. > >-- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garstang@gmail.com Cell: +1-805-340-5627 -- 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.