Jeff Schroeder wrote:
On Tue, Jun 23, 2009 at 10:48 AM, Leonid Flaks<flaks(a)bnl.gov>
wrote:
> I made two changes keep_ssh_host_keys snippet - list-harddrives does not
> work on fedora 11, also RAID array supprt is added. I see similar snippet
> keep_rhn_kees which could be patched in similar way. I tested it on fedora
> only.
Looks good but I've got a few comments. This might be a bug in
anaconda's list-harddrives which should be filed upstream. Are you at
liberty to share your hardware specs of the server / array that isn't
showing any output in list-harddrives? Comment inline.
This was tested on an old
box (from Pine computers) with just one IDE
drive. I'll test on Dell Optiplex 755 next.
> diff --git a/snippets/keep_ssh_host_keys b/snippets/keep_ssh_host_keys
> index 527c992..655de7f 100644
> --- a/snippets/keep_ssh_host_keys
> +++ b/snippets/keep_ssh_host_keys
> @@ -10,11 +10,7 @@ insmod /lib/ext3.o
>
> mkdir -p /tmp/ssh
>
> -drives=$(list-harddrives | awk '{print $1}')
> -for disk in $drives; do
> - DISKS="$DISKS $(fdisk -l /dev/$disk | awk '/^\/dev/{print
$1}')"
> -done
> -
> +DISKS=$(cat /proc/partitions | sed -n
> '/^.*\(sd[a-z][1-9].*\)/{s||/dev/\1|p}')
Sed supports filenames as arguments so the cat is redundant. This
Yes, no need for
cat.
doesn't work with HP raid controllers using the cciss driver
(/dev/cciss/c0d0 for an equiv of /dev/sda). It also doesn't work for
exotic storage such as fusion io where list-harddrives does in both
cases.
Now after reading you comment I remember having old VAlinux system with
hardware RAID on DAC960 controller which had similar device structure.
Here is an example /proc/partitions for you to look at on an HP server:
major minor #blocks name
104 0 292935982 cciss/c0d0
104 1 265041 cciss/c0d0p1
104 2 8385930 cciss/c0d0p2
104 3 284278207 cciss/c0d0p3
104 16 1464678702 cciss/c0d1
While much uglier to look at, this works in all cases I could throw at
it including the two mentioned above:
awk '{if ($NF !~ "name" && $NF ~ "^[a-zA-Z]") print
$NF}'
/proc/partitions | sed -e 's:^:/dev/:g'
Does this look ok to you?
You can the modify print to put /dev/ in it, so no need
for sed ;-)
awk '{if ($NF !~ "name" && $NF ~ "^[a-zA-Z]") print
"/dev/"$NF}'
/proc/partitions
I checked on my system with software RAID, it would output all md and
sd{a,b} devices, but we are checking only regular partitions in this
part. On the other hand, md devices are not even created at this moment.
Need to sit on this for a moment.
> # Try to find the keys on ordinary partitions
> for disk in $DISKS; do
> name=$(basename $disk)
> @@ -33,6 +29,28 @@ for disk in $DISKS; do
> rm -r /tmp/$name
> done
>
> +# Try software RAID
> +if [ "$keys_found" = "no" ]; then
> + if mdadm -As; then
> + RDISKS="$(awk '/md/{print $1}' /proc/mdstat)"
> + for rdisk in $RDISKS; do
> + mkdir -p /tmp/$rdisk
> + mount /dev/$rdisk /tmp/$rdisk
> + [ $? -eq 0 ] || continue # Skip to the next partition if the
> mount fails
> + # Copy current ssh host keys out to be reused
> + if [ -d /tmp/${rdisk}/etc/ssh ]; then
> + cp -a /tmp/${rdisk}/etc/ssh/ssh_host* /tmp/ssh
> + keys_found="yes"
> + umount /tmp/$rdisk
> + break
> + fi
> + umount /tmp/$rdisk
> + rm -r /tmp/$rdisk
> + done
> + fi
> +fi
> +
> +
> # Try LVM if that didn't work
> if [ "$keys_found" = "no" ]; then
> lvm lvmdiskscan
This looks fantastic and thanks for helping to make cobbler better. I
wonder if there is any way to break this up and make this re-usable.
ssh host keys, rhn files, and puppet certs all require something very
similar. Can you re-do this patch with the above comments fixed
please?
One more thing to add to the list is cfengine keys. There are two files
localhost.priv and localhost.pub which sit in /var/cfengine/ppkeys/
I am not familiar with puppet. Where are the puppet certs stored?
In order to get it going, I think we can patch existing snippet (before
Mike removes it from distribution as broken!) and meanwhile see what
could be done to re-use it for other programs.
I see two different ways to re-use the code here - first create N simple
snippets - one for each program, which just set up environment to use in
another snippet which would do scanning of the hardware looking for
files and copying them if found. The second approach would be to have
one snippet, which would check for everything that it can find and use
some metha data to limit search only to keys/certs that it was asked
for. Not sure which path is better. I don't think I want to scan
hardware more then once though.
Thanks,
Leon