Hi, I''m trying retrieve some information from the real world from within puppet. I''d initially hoped that I could do this: $xen_version = exec { "apt-cache search xen-hypervisor | head -n 1 | cut -d- -f3-5": path => "/usr/bin:/usr/sbin:/bin", cwd => "/tmp", require => [ Package["apt"], Package["coreutils"] ] } but when it didn''t work I remembered that facter is the way to do this type of thing. Now I''m not a ruby programmer (and don''t have the time to learn it in its entirety) but have had a quick look at the examples and understand what''s going on. My issue is that there doesn''t seem to be a ruby api for the debian apt-* utilities so I''m not sure where to go from here. What I''m trying to achieve is, in essence, to find the latest xen-hypervisor package within the apt respository to then dynamically configure puppet to install that package. Yes, I''m aware that the idea behind package { "xen-hypervisor": ensure => latest } is meant to achieve what I''m looking for but because there are multiple packages I need to be more specific in my package selection. Therefore, I''d like to determine what is available (by some means - like the $xen_version example above) and code the package definition like this: package { "xen-hypervisor-$xen_version": ensure => latest } This way, when the package version changes in the repository I get the very latest package without having to change my scripts. How can I achieve what I want to achieve either in puppet, facter, ruby etc. (simply)? Regards, Andrew _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Adam Jacob
2007-Mar-09 21:57 UTC
Re: Information from the real world into Puppet (simply)?
On Mar 9, 2007, at 1:39 PM, Andrew Leach wrote:> Hi, > > I''m trying retrieve some information from the real world from > within puppet. I''d initially hoped that I could do this: > > $xen_version = exec { "apt-cache search xen-hypervisor | head - > n 1 | cut -d- -f3-5": > path => "/usr/bin:/usr/sbin:/bin", > cwd => "/tmp", > require => [ Package["apt"], Package["coreutils"] ] > } > > but when it didn''t work I remembered that facter is the way to do > this type of thing. > Now I''m not a ruby programmer (and don''t have the time to learn it > in its entirety) but have had a quick look at the examples and > understand what''s going on. My issue is that there doesn''t seem to > be a ruby api for the debian apt-* utilities so I''m not sure where > to go from here.Just do what you were planning to do already, just do it in facter: require ''facter'' Facter.add("xen-hypervisor-version") do setcode "apt-cache search xen-hypervisor | head -n 1 | cut -d- -f3-5" confine ''operatingsystem'', ''Debian'' end Would do the trick. You could then reference $xen-hypervisor-version in your puppet manifest. Adam
David Schmitt
2007-Mar-09 23:50 UTC
Re: Information from the real world into Puppet (simply)?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 09 March 2007 22:39, Andrew Leach wrote:> What I'm trying to achieve is, in essence, to find the latest > xen-hypervisor package within the apt respository to then dynamically > configure puppet to install that package. Yes, I'm aware that the idea > behind > > package { "xen-hypervisor": > ensure => latest > } > > is meant to achieve what I'm looking for but because there are multiple > packages I need to be more specific in my package selection. Therefore, I'd > like to determine what is available (by some means - like the $xen_version > example above) and code the package definition like this: > > package { "xen-hypervisor-$xen_version": > ensure => latest > } > > This way, when the package version changes in the repository I get the very > latest package without having to change my scripts. > > How can I achieve what I want to achieve either in puppet, facter, ruby > etc. (simply)?You'll want to look at the xen-linux-system-$KVERS-xen-$ARCH package which depends on the right hypervisor for the given kernel. If you don't want to upgrade the kernel automatically you can use the operatingsystemrelease fact which is essentially $(uname -r). The newest kernel can be fetched by using linux-image-2.6-xen-$ARCH which also depends on the most recent kernel. To use this information automatically - which I would not recommend - Adam Jacob has already pointed you in the right direction. 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) iD8DBQFF8fLl/Pp1N6Uzh0URAqDXAKCTgQGi6g43RsIYhVtXF9IgPs6f3ACfRZaH qwEEctUmlODOaIe1tLaJUKE=jf87 -----END PGP SIGNATURE----- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Maybe Matching Threads
- Xen 4.4.2 (with XSA-132) in virt6-testing
- A question related with symbol reference?
- r26 - in trunk/debian: . patches
- [PATCH] x86/EFI: define and use EFI_DIR make variable, defaulting to /usr/lib64/efi
- [PATCH 0/3] xen: various changes to what we install in /boot