Christophe GUILLOUX
2008-May-13 12:22 UTC
[Puppet Users] variable name containing variable name
Hello, i''m new to puppet (and ruby). I have a problem when using a variable name containing a variable name and containing a reserved variable name : I have a class : class kernel-Linux-binary { $test = $operatingsystem ? { Fedora => "/usr/bin/test", default => undef } } and i want to call "test" and replace Linux by $kernel to have a generic call. If i write $kernel-$kernel-binary::test, puppet try to call Linux-Linux-binary::test What is the good solution ? -- | Christophe GUILLOUX - Service AMI - Bureau A017 | | Centre de Recherche INRIA Rennes - Bretagne Atlantique | | Campus de Beaulieu | | 35042 Rennes cedex, France | | PHONE : +33 (0) 29984 74 10 | FAX : +33 (0) 29984 71 71 | | WWW : http://www.inria.fr | JABBER : christophe.guilloux@irisa.fr |
Phillip Scholz
2008-May-13 12:45 UTC
[Puppet Users] Re: variable name containing variable name
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 what exactly do you want to get out of this call? Christophe GUILLOUX schrieb:> Hello, i''m new to puppet (and ruby). > > I have a problem when using a variable name containing a variable name > and containing a reserved variable name : > > I have a class : > > class kernel-Linux-binary { > $test = $operatingsystem ? { > Fedora => "/usr/bin/test", > default => undef > } > } > > and i want to call "test" and replace Linux by $kernel to have a generic > call. > > If i write $kernel-$kernel-binary::test, puppet try to call > Linux-Linux-binary::test > > What is the good solution ? >- -- Phillip Scholz Junior Linux System-Administrator IT Shared Hosting Linux - SaaS, Karlsruhe 1&1 Internet AG Brauerstraße 48 D-76135 Karlsruhe Tel. +49-721-91374-4818 phillip.scholz@1und1.de http://www.1und1.de/ Amtsgericht Montabaur HRB 6484 Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Achim Weiss Aufsichtsratsvorsitzender: Michael Scheeren -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIKY2G1MyrzuZeshoRAtabAJ9PGALK+mZfOFySvV2c+KTpHKXw7ACdH6U6 GjuGUXLCbJvLp34PcgYVCTM=W0s9 -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Phillip Scholz
2008-May-13 12:52 UTC
[Puppet Users] Re: variable name containing variable name
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 perhaps calling ${kernel-$kernel-binary::test} would solve your problem Christophe GUILLOUX schrieb:> Hello, i''m new to puppet (and ruby). > > I have a problem when using a variable name containing a variable name > and containing a reserved variable name : > > I have a class : > > class kernel-Linux-binary { > $test = $operatingsystem ? { > Fedora => "/usr/bin/test", > default => undef > } > } > > and i want to call "test" and replace Linux by $kernel to have a generic > call. > > If i write $kernel-$kernel-binary::test, puppet try to call > Linux-Linux-binary::test > > What is the good solution ? >- -- Phillip Scholz Junior Linux System-Administrator IT Shared Hosting Linux - SaaS, Karlsruhe 1&1 Internet AG Brauerstraße 48 D-76135 Karlsruhe Tel. +49-721-91374-4818 phillip.scholz@1und1.de http://www.1und1.de/ Amtsgericht Montabaur HRB 6484 Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Achim Weiss Aufsichtsratsvorsitzender: Michael Scheeren -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIKY751MyrzuZeshoRAksuAJ97pkanXGZFG80eLG2zmn9bKdeXqACeLV/m wV8AqCZTaxx3PkYd1ZgIZjM=V6xi -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe GUILLOUX
2008-May-13 13:01 UTC
[Puppet Users] Re: variable name containing variable name
Phillip Scholz a écrit :> perhaps calling ${kernel-$kernel-binary::test} would solve your problemalready tried :-( I have this error : warning: Configuration could not be instantiated: Parameter onlyif failed: ''${kernel-Linux-binary::test} -f /etc/init.d/sendmail'' is both unqualifed and specified no search path at /home/puppet/manifests/services/mail.pp:22 -- | Christophe GUILLOUX - Service AMI - Bureau A017 | | Centre de Recherche INRIA Rennes - Bretagne Atlantique | | Campus de Beaulieu | | 35042 Rennes cedex, France | | PHONE : +33 (0) 29984 74 10 | FAX : +33 (0) 29984 71 71 | | WWW : http://www.inria.fr | JABBER : christophe.guilloux@irisa.fr |
Phillip Scholz
2008-May-13 14:09 UTC
[Puppet Users] Re: variable name containing variable name
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 so you try to evaluate a valid binary for "test" what about setting "path => " within the exec you have in /home/puppet/manifests/services/mail.pp aroune line 22 ? if you set all paths where the test-binary may be on all you systems and just use "test" (not "/usr/bin/test") within the onlyif parameter it should work. doesn''t it? Christophe GUILLOUX schrieb:> Phillip Scholz a écrit : >> perhaps calling ${kernel-$kernel-binary::test} would solve your problem > > already tried :-( > > I have this error : > warning: Configuration could not be instantiated: Parameter onlyif > failed: ''${kernel-Linux-binary::test} -f /etc/init.d/sendmail'' is both > unqualifed and specified no search path at > /home/puppet/manifests/services/mail.pp:22 > >- -- Phillip Scholz Junior Linux System-Administrator IT Shared Hosting Linux - SaaS, Karlsruhe 1&1 Internet AG Brauerstraße 48 D-76135 Karlsruhe Tel. +49-721-91374-4818 phillip.scholz@1und1.de http://www.1und1.de/ Amtsgericht Montabaur HRB 6484 Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Achim Weiss Aufsichtsratsvorsitzender: Michael Scheeren -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIKaE21MyrzuZeshoRAsAqAJ4gXUvPMpi9V2r9ifCkFnwdi3QfQACgjKiv vivaqPdU9RwkElwBCKOpFf4=Gjk+ -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe GUILLOUX
2008-May-13 15:20 UTC
[Puppet Users] Re: variable name containing variable name
Phillip Scholz a écrit :> so you try to evaluate a valid binary for "test" > > what about setting "path => " within the exec you have in > /home/puppet/manifests/services/mail.pp aroune line 22 ? > if you set all paths where the test-binary may be on all you systems and > just use "test" (not "/usr/bin/test") within the onlyif parameter it > should work. doesn''t it?Yes it works :-) but it don''t resolve the truly problem. I think there is examples where it should be good to have generic code. For example, i can do : include "operatingsystem-$operatingsystem" and it''s very useful. -- | Christophe GUILLOUX - Service AMI - Bureau A017 | | Centre de Recherche INRIA Rennes - Bretagne Atlantique | | Campus de Beaulieu | | 35042 Rennes cedex, France | | PHONE : +33 (0) 29984 74 10 | FAX : +33 (0) 29984 71 71 | | WWW : http://www.inria.fr | JABBER : christophe.guilloux@irisa.fr |
Phillip Scholz
2008-May-13 16:42 UTC
[Puppet Users] Re: variable name containing variable name
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> include "operatingsystem-$operatingsystem"that one should work out of the box - if this generates an error it should look like "operatingsystem-${operatingsystem}" Yet, I am not quite sure when puppet needs those parentheses and when it doesn''t - but I never stumbled upon a case where puppet threw an error complaining about them beeing used. I guess it has something to do with strings - if you use a variable within a string those parentheses are necessary. In my classes I use lots of such calls - using variables in names for files, packages, services and so on - just to be sure nothing is declared twice and to reuse those declarations. Phillip Christophe GUILLOUX schrieb:> Phillip Scholz a écrit : >> so you try to evaluate a valid binary for "test" >> >> what about setting "path => " within the exec you have in >> /home/puppet/manifests/services/mail.pp aroune line 22 ? >> if you set all paths where the test-binary may be on all you systems and >> just use "test" (not "/usr/bin/test") within the onlyif parameter it >> should work. doesn''t it? > > Yes it works :-) but it don''t resolve the truly problem. > I think there is examples where it should be good to have generic code. > For example, i can do : > include "operatingsystem-$operatingsystem" > and it''s very useful. >- -- Phillip Scholz Junior Linux System-Administrator IT Shared Hosting Linux - SaaS, Karlsruhe 1&1 Internet AG Brauerstraße 48 D-76135 Karlsruhe Tel. +49-721-91374-4818 phillip.scholz@1und1.de http://www.1und1.de/ Amtsgericht Montabaur HRB 6484 Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Achim Weiss Aufsichtsratsvorsitzender: Michael Scheeren -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIKcTk1MyrzuZeshoRAj5uAKCSWEl7z4rCQXSoLIb9MDPnC0DCoQCdHRy/ rKdAcZV7zMdPdsx0aMbwHcc=deiU -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---