Simon J Mudd
2008-Oct-10 16:56 UTC
[Puppet Users] puppet, facter and using non-scalar values
Hello all, I''ve been using puppet for a while now and have an issue I''ve not seen clearly answered. One of the issues I want to address in puppet is to manage LVM, the volume groups and logical volumes on a series of servers. Starting from a small base configuration I would like to configure the logical volumes on the server. However this doesn''t seem to be a thing that puppet knows about directly. My first thought is to create some custom facts which store the volume group names and within each volume group the logical volumes. This is not ideally stored as a couple of scalar values. So how should I store this? Facter would seem to be the best thing to adjust adding some custom facts but from what I can see all facter facts are single scalar values. So am I approaching the problem incorrectly? My initial thought is that I''d like to populate some sort of variable volume_group_info as a hash of hashes, the first hash being indexed on the volume group names and the second on the logical volume group names in each volume group. Still being new to ruby I''m trying to work out how to do this straight in ruby but I''m sure this can be done, and if so my question would by how to translate this into puppet code. I''m initally looking at doing something like: -- snip -- vol_groups = Hash.new puts vol_groups.to_s if FileTest.exists?("/usr/sbin/lvs") %x{/usr/sbin/lvs --noheadings 2>/dev/null}.split("\n").each do |line| if line =~ /\s+(\S+)\s+(\S+)/ puts "match vg: " + $2 + ", lv: " + $1 lvname = $1 vgname = $2 # now fill lvname into vol_groups by vgname... end end end -- snip -- Can anyone comment on this idea? Simon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-Oct-13 15:05 UTC
[Puppet Users] Re: puppet, facter and using non-scalar values
On Oct 10, 2008, at 11:56 AM, Simon J Mudd wrote:> > Hello all, > > I''ve been using puppet for a while now and have an issue I''ve not > seen clearly answered. One of the issues I want to address in puppet > is to manage LVM, the volume groups and logical volumes on a series > of servers. > > Starting from a small base configuration I would like to configure the > logical volumes on the server. > > However this doesn''t seem to be a thing that puppet knows about > directly. > My first thought is to create some custom facts which store the volume > group names and within each volume group the logical volumes. This is > not ideally stored as a couple of scalar values.What are you going to be doing with the facts? Wouldn''t you want to just declaratively manage the whole set of groups and volumes and such? It''s not like you can iterate over the groups in Puppet or anything.> > So how should I store this? Facter would seem to be the best thing to > adjust adding some custom facts but from what I can see all facter > facts > are single scalar values. > > So am I approaching the problem incorrectly? My initial thought is > that I''d like to populate some sort of variable volume_group_info as a > hash of hashes, the first hash being indexed on the volume group names > and the second on the logical volume group names in each volume group.The problem is that Puppet isn''t really set up to use this hash of hashes to make resources, and really, what''s the value of doing so anyway, since you''d just be telling Puppet to manage what it''s already discovered, right? -- Due to circumstances beyond your control, you are master of your fate and captain of your soul. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Simon J Mudd
2008-Oct-16 07:27 UTC
[Puppet Users] Re: puppet, facter and using non-scalar values
Hi Luke, Sorry for not replying earlier. I missed your reply. On Oct 13, 2008, at 5:05 pm Luke Kanies wrote:> What are you going to be doing with the facts? Wouldn''t you want to > just declaratively manage the whole set of groups and volumes and such?In this particular case I want to create and mount various non-root partitions on which later applications will be installed. Due to slightly different install procedures on some boxes the base volume group names are different and so I need to determine what the volume group is called before calling lvs to create the logical volume/partion (which takes the volume group as one of the parameters). Thus until now I''ve been using a custom define (which I sent to this list) to create the logical volume of the specified size, format and mount it if it is not already mounted. That''s fine if I know the volume group name but that (unfortunately) varies between different types of servers. So now I want to be able to check the number of volume groups on the server, and if it is only one (the normal case) use _that_ volume group as the name for creating logical volumes. In other cases the sysadmin will have to resolve the problem.> It''s not like you can iterate over the groups in Puppet or anything.No, but if I could use the information about existing volume groups I could proceed further by creating logical volumes on top of them, and then further continue with application installation and configuration.> > So how should I store this? Facter would seem to be the best thing to > > adjust adding some custom facts but from what I can see all facter > > facts > > are single scalar values. > > > So am I approaching the problem incorrectly? My initial thought is > > that I''d like to populate some sort of variable volume_group_info as a > > hash of hashes, the first hash being indexed on the volume group names > > and the second on the logical volume group names in each volume group. > > The problem is that Puppet isn''t really set up to use this hash of > hashes to make resources, and really, what''s the value of doing so > anyway, since you''d just be telling Puppet to manage what it''s already > discovered, right?Or using what it has already discovered to "fix missing elements", in this case missing partitions, which need to be built. You have a facility to mount non-mounted partitions. How is this any different? Or should I be doing this by creating custom puppet functions which return a list of volume group names, or a list of logical volumes for each volume group? Perhaps after coming from cfengine (which has it''s own issues) I''m more used to be able to create "custom facts" or "custom conditions" based on running a simple shell script, and using those facts/conditions to later perform other tasks. So I''m trying to see how this should be solved using puppet. The only thing that surprises me is that I don''t see recipes or archives which mention the use of LVM for configuring servers with puppet yet this seems to be such a basic task of building a server. And at least 2 platforms I know use LVM: Linux and AIX, though I imagine other UNIX platforms do too. Simon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Simon J Mudd
2008-Oct-16 08:30 UTC
[Puppet Users] Re: puppet, facter and using non-scalar values
sjmudd@pobox.com (Simon J Mudd) writes:> The only thing that surprises me is that I don''t see recipes or archives > which mention the use of LVM for configuring servers with puppet yet > this seems to be such a basic task of building a server. And at least > 2 platforms I know use LVM: Linux and AIX, though I imagine other UNIX > platforms do too.Actually I''m wrong. There is a ticket http://reductivelabs.com/trac/puppet/ticket/475 which mentions this. One thing perhaps it''s missing is having the list of volume groups and logical volumes in a place that can be used to check for their existence. For volume groups something list a list/hash of volume groups. If this is not possible a : separated list of volume groups. That would be something like: # vgs VG #PV #LV #SN Attr VSize VFree xxxxx.wl0.org 1 23 0 wz--n- 465.56G 186.53G usbdisk.wl0.org 1 2 0 wz--n- 465.56G 32.00M or $volume_groups = "xxxxx.wl0.org:usbdisk.wl0.org" Logical volume information is more difficult as you have multiple logical volumes under each volume group so storing in a scalar is ugly and would produce very large strings. So I have something similar on one of my machines: # lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv.vm.fc7 vg00 -wi-ao 10.00G lv.vm.fedora8 vg00 -wi-ao 10.00G lv.vm.fedora9 vg00 -wi-ao 10.00G lv.vm.rhel5 vg00 -wi-ao 10.00G lv.vm.rhel4 vg00 -wi-ao 10.00G lv.vm.rhel3 vg00 -wi-ao 10.00G lvbackup vg00 -wi-ao 10.00G lvhome vg00 -wi-ao 1.00G lvmirror vg00 -wi-ao 10.00G lvopenpkg vg00 -wi-ao 5.00G lvroot vg00 -wi-ao 20.00G lvswap vg00 -wi-ao 4.00G lvtmp vg00 -wi-ao 1.00G lvvar vg00 -wi-ao 2.00G lvusr.local.rhel4 vg00 -wi-ao 1.00G LogVol01 usbdisk -wi-a- 1.94G LogVol00 usbdisk -wi-ao 463.59G And this would give rather a huge scalar value if vg/lv were concatenated and colon separated. Ideally I''d like to be able to check vg_exists( ''usbdisk'' ) lv_exists( ''usbdisk/LogVol00'' ) It seems that the puppet functions are run on the server and not on the client so I''m not sure how I could write a function to collect/return the information I need as obviously it needs to be run on the client to be of any use. Again I may be misunderstanding something. Writing shell scripts which return an appropriate exist status to perform these tests is trivial, but I don''t see how to collect the information and then use it elsewhere from within puppet. Simon> > Simon > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---