Hi there! Is it possible to do something string converison like in puppet? My problem: I have a variable that contains a path ($variable = "some/value"). This variable is passed on as an option to an external script, which uses the variables content to generate I) a path and II) a filename, converting the "/" to "_" for that filename. I don´t really see a way to manage this file dynamically, when I want to talk to puppet about that file: file {"$variable": whatever => "$stuff"} puppet talks about the file "some/value" and not "some_value" as the script generated - so I need something string conversion like to tell puppet to replace the chars like the script does. Is there any way to do this? Thanks a lot for your help! _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On 11 June , 2007, at 05:53, simon wrote:> I don´t really see a way to manage this file dynamically, when I > want to > talk to puppet about that file: > file {"$variable": whatever => "$stuff"} > puppet talks about the file "some/value" and not "some_value" as the > script generated - so I need something string conversion like to tell > puppet to replace the chars like the script does. > Is there any way to do this?I don't believe there's a built-in way to do this right now. Maybe there's a better way to manage these files? _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Jun 11, 2007, at 4:53 AM, simon wrote:> Hi there! > > Is it possible to do something string converison like in puppet?Not without writing a custom function.> My problem: > I have a variable that contains a path ($variable = "some/value"). > This > variable is passed on as an option to an external script, which > uses the > variables content to generate I) a path and II) a filename, converting > the "/" to "_" for that filename. > > I don´t really see a way to manage this file dynamically, when I > want to > talk to puppet about that file: > file {"$variable": whatever => "$stuff"} > puppet talks about the file "some/value" and not "some_value" as the > script generated - so I need something string conversion like to tell > puppet to replace the chars like the script does. > Is there any way to do this?Unfortunately, the only way to do that right now is in a custom function; sorry. -- I think that all good, right thinking people in this country are sick and tired of being told that all good, right thinking people in this country are fed up with being told that all good, right thinking people in this country are fed up with being sick and tired. I''m certainly not, and I''m sick and tired of being told that I am. -- Monty Python --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On Thu, Jun 14, 2007 at 05:03:35PM -0500, Luke Kanies wrote:> On Jun 11, 2007, at 4:53 AM, simon wrote: > > > > Is it possible to do something string converison like in puppet? > > Not without writing a custom function.As someone new to Puppet, allow me to respectfully disagree. I''m not sure what the purpose of generate is, but it can be used to do string conversions: $raw = "initial var" $dig = generate("/bin/sh", "-c", "echo $raw | sed ''s/i/x/g''") alert($dig) If there''s something horribly wrong with doing this, please let me know. Alex
On Jun 15, 2007, at 1:10 AM, Alexander Taler wrote:> As someone new to Puppet, allow me to respectfully disagree. I''m > not sure what the purpose of generate is, but it can be used to > do string conversions: > > $raw = "initial var" > $dig = generate("/bin/sh", "-c", "echo $raw | sed ''s/i/x/g''") > alert($dig) > > If there''s something horribly wrong with doing this, please let > me know.You''re correct, that can be used to convert text. So, a function is still required, but you don''t have to write it. -- Discovery consists of seeing what everybody has seen and thinking what nobody has thought. -- Albert Szent-Gyorgyi --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 15 June 2007, Alexander Taler wrote:> On Thu, Jun 14, 2007 at 05:03:35PM -0500, Luke Kanies wrote: > > On Jun 11, 2007, at 4:53 AM, simon wrote: > > > Is it possible to do something string converison like in puppet? > > > > Not without writing a custom function. > > As someone new to Puppet, allow me to respectfully disagree. I''m > not sure what the purpose of generate is, but it can be used to > do string conversions: > > $raw = "initial var" > $dig = generate("/bin/sh", "-c", "echo $raw | sed ''s/i/x/g''") > alert($dig) > > If there''s something horribly wrong with doing this, please let > me know."Just" a few forks and execs. Put this instead into $rubysitedir/puppet/parser/functions/convert.rb: # convert a string module Puppet::Parser::Functions newfunction(:convert, :type => :rvalue) do |args| args[0].gsub(/i/, ''x'') end end Regards, David - -- - - hallo... wie gehts heute? - - *hust* gut *rotz* *keuch* - - gott sei dank kommunizieren wir über ein septisches medium ;) -- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGdwTQ/Pp1N6Uzh0URAn+GAJ9T/tyJs2Nsd/Uq8D2t11JHFsRwNQCfTH+n yzQeY3kfrw/gaSEtjtQ+Hio=6h2C -----END PGP SIGNATURE-----