[Ovirt-devel] [PATCH recipe] Move logic for appliance setup from kickstart to recipe
Perry Myers
pmyers at redhat.com
Sun Nov 9 07:45:59 UTC 2008
The only logic left in the kickstart is generic appliance setup information
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
appliances/ovirt/files/cobbler-import | 46 +++++++++++++++
appliances/ovirt/files/ovirt-server-appliance | 2 +-
appliances/ovirt/ovirt.pp.in | 33 ++++++-----
.../templates/ovirt-server-appliance-setup.erb | 60 ++++++++++++++++++++
4 files changed, 126 insertions(+), 15 deletions(-)
create mode 100644 appliances/ovirt/files/cobbler-import
diff --git a/appliances/ovirt/files/cobbler-import b/appliances/ovirt/files/cobbler-import
new file mode 100644
index 0000000..5695f12
--- /dev/null
+++ b/appliances/ovirt/files/cobbler-import
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Import Cobbler profiles on first boot
+
+url=http://download.fedora.redhat.com/pub/fedora/linux
+ksdir=/var/www/cobbler/ks_mirror
+
+set -x
+for dir in $ksdir/* ; do
+ base=$(basename $dir)
+ os=$(echo $base | cut -d '-' -f 1)
+ ver=$(echo $base | cut -d '-' -f 2)
+ arch=$(echo $base | cut -d '-' -f 2)
+
+ test -z "$os" -o -z "$ver" -o -z "$arch"
+ && { echo "Skipping $dir, not a valid cobbler profile" ; continue ; }
+
+ cobbler import --name=$os-$ver --arch=$arch \
+ --path=$dir
+ cobbler repo add --name=f$ver-$arch --arch=$arch --mirror-locally=0 \
+ --mirror=$url/releases/$ver/Everything/$arch/os
+ cobbler repo add --name=f$ver-$arch-updates --arch=$arch --mirror-locally=0 \
+ --mirror=$url/updates/$ver/$arch.newkey
+ sed -e 's#^reboot.*#poweroff#' /etc/cobbler/sample_end.ks \
+ > /etc/cobbler/sample-$os-$ver-$arch.ks
+ cobbler profile edit --name=$os-$ver-$arch \
+ --repos="f$ver-$arch f$ver-$arch-updates" \
+ --kickstart=/etc/cobbler/sample-$os-$ver-$arch.ks
+done
+
+# TODO extract Node boot params from /var/lib/tftboot/pxelinux.cfg/default
+# before Cobbler overwrites it
+cobbler distro add --name="oVirt-Node-$arch" --arch=$arch \
+ --initrd=/var/lib/tftpboot/initrd0.img --kernel=/var/lib/tftpboot/vmlinuz0 \
+ --kopts="rootflags=loop root=/ovirt-node-image.iso rootfstype=iso9660 ro console=ttyS0,115200n8 console=tty0"
+cobbler profile add --name=oVirt-Node-$arch --distro=oVirt-Node-$arch
+cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \
+ --name=node3 --mac=00:16:3e:12:34:57
+cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \
+ --name=node4 --mac=00:16:3e:12:34:58 --kopts="ovirt_init=scsi ovirt_local_boot"
+cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \
+ --name=node5 --mac=00:16:3e:12:34:59 --kopts="ovirt_init=scsi"
+
+set +x
+echo "Add new oVirt Nodes as Cobbler systems to make them PXE boot oVirt Node image directly."
+echo "oVirt-Node-$arch is also default boot option in Cobbler menu"
diff --git a/appliances/ovirt/files/ovirt-server-appliance b/appliances/ovirt/files/ovirt-server-appliance
index e7ba7bd..5cf530d 100644
--- a/appliances/ovirt/files/ovirt-server-appliance
+++ b/appliances/ovirt/files/ovirt-server-appliance
@@ -2,7 +2,7 @@
#
# ovirt-server-appliance oVirt Server Appliance service
#
-# chkconfig: 3 60 40
+# chkconfig: 3 96 4
# description: ovirt server appliance service
#
diff --git a/appliances/ovirt/ovirt.pp.in b/appliances/ovirt/ovirt.pp.in
index e06f72c..299a11d 100644
--- a/appliances/ovirt/ovirt.pp.in
+++ b/appliances/ovirt/ovirt.pp.in
@@ -136,17 +136,6 @@ file_replacement{"nat_forwarding" :
notify => Service[network]
}
-file {"/etc/init.d/ovirt-server-appliance":
- source => "puppet:///ovirt/ovirt-server-appliance",
- mode => 755
-}
-
-service {"ovirt-server-appliance":
- ensure => "running",
- enable => true ,
- require => [File["/etc/init.d/ovirt-server-appliance"], Service["network"], Service["httpd"]]
-}
-
service {"nfs":
ensure => "running",
enable => true,
@@ -169,15 +158,31 @@ file {"/usr/sbin/ovirt-server-appliance-setup":
mode => 755
}
+file {"/usr/sbin/cobbler-import":
+ source => "puppet:///ovirt/cobbler-import",
+ mode => 755
+}
+
single_exec {"ovirt_appliance_installation":
command => "/usr/sbin/ovirt-server-appliance-setup >> /var/log/ovirt-server-appliance-setup.log",
- require => [File["/usr/sbin/ovirt-server-appliance-setup"], Service["ovirt-server-appliance"],
- Exec["reload-firewall"]]
+ require => [File["/usr/sbin/ovirt-server-appliance-setup"], Exec["reload-firewall"]]
+}
+
+file {"/etc/init.d/ovirt-server-appliance":
+ source => "puppet:///ovirt/ovirt-server-appliance",
+ mode => 755
+}
+
+service {"ovirt-server-appliance":
+ ensure => "running",
+ enable => true ,
+ require => [File["/etc/init.d/ovirt-server-appliance"], Service["network"], Service["httpd"],
+ Single_exec["ovirt_appliance_installation"]]
}
single_exec {"ovirt_installation":
command => "/usr/sbin/ovirt-server-install >> /var/log/ovirt-server-install.log",
- require => [Service["postgresql"],Single_exec["ovirt_appliance_installation"]]
+ require => [Service["postgresql"],Service["ovirt-server-appliance"]]
}
#
diff --git a/appliances/ovirt/templates/ovirt-server-appliance-setup.erb b/appliances/ovirt/templates/ovirt-server-appliance-setup.erb
index 5fbf67a..fd080b3 100644
--- a/appliances/ovirt/templates/ovirt-server-appliance-setup.erb
+++ b/appliances/ovirt/templates/ovirt-server-appliance-setup.erb
@@ -1,5 +1,15 @@
#!/bin/bash
export PATH=/usr/kerberos/bin:$PATH
+
+# make sure to update the /etc/hosts with the list of all possible DHCP
+# addresses we can hand out; dnsmasq uses this
+sed -i -e 's/management\.priv\.ovirt\.org//' /etc/hosts
+echo "192.168.50.1 physical.priv.ovirt.org" >> /etc/hosts
+echo "192.168.50.2 management.priv.ovirt.org" >> /etc/hosts
+for i in `seq 3 252` ; do
+ echo "192.168.50.$i node$i.priv.ovirt.org" >> /etc/hosts
+done
+
# workaround for https://bugzilla.redhat.com/show_bug.cgi?id=451936
sed -i '/\[kdcdefaults\]/a \ kdc_ports = 88' /usr/share/ipa/kdc.conf.template
# set up freeipa
@@ -31,6 +41,56 @@ ipa-adduser -f Ovirt -l Admin -p <%= password %> <%= principal %>
ipa-modgroup -a ovirtadmin admins
ipa-moduser --setattr krbPasswordExpiration=19700101000000Z <%= principal %>
+# the code to contact the host we are running on and make it configure itself
+# note that this has to be done in rc.local (as opposed to ovirt-wui-dev)
+# because when ovirt-wui-dev starts, the host-browser is not yet running
+cat >> /etc/rc.d/rc.local << \EOF
+# Try to contact the host we are running on; if we succeed, we'll use it as
+# one of the managed nodes; if not, no big deal
+(exec 3<> /dev/tcp/192.168.50.1/7777 && echo "AWAKE" 1>&3 \
+ && exec 3<> /dev/tcp/192.168.50.1/7777 && echo "IDENTIFY" 1>&3) || :
+EOF
+
+# Create sparse files for iSCSI backing stores
+mkdir -p /mnt/data/ovirtiscsi
+mkdir -p /ovirtiscsi
+echo "/mnt/data/ovirtiscsi /ovirtiscsi bind bind 0 0" >> /etc/fstab
+mount /ovirtiscsi
+for i in `seq 1 5`; do
+ dd if=/dev/null of=/ovirtiscsi/iSCSI$i bs=1 count=1 seek=5G
+done
+
+# make an NFS directory with some small, fake disks and export them via NFS
+# to show off the NFS part of the WUI
+mkdir -p /mnt/data/ovirtnfs
+mkdir -p /ovirtnfs
+echo "/mnt/data/ovirtnfs /ovirtnfs bind bind 0 0" >> /etc/fstab
+mount /ovirtnfs
+for i in `seq 1 5`; do
+ dd if=/dev/zero of=/ovirtnfs/disk$i.dsk bs=1 count=1 seek=5G
+done
+echo "/ovirtnfs 192.168.50.0/24(rw,no_root_squash)" >> /etc/exports
+
+# add an NFS directory to use for Cobbler image storage
+mkdir -p /mnt/data/cobblernfs
+mkdir -p /cobblernfs
+echo "/mnt/data/cobblernfs /cobblernfs bind bind 0 0" >> /etc/fstab
+mount /cobblernfs
+echo "/cobblernfs 192.168.50.0/24(rw,no_root_squash)" >> /etc/exports
+
+# Import cobbler profiles
+/usr/sbin/cobbler-import
+
+# TODO use Augeas 0.3.0 Inifile lens
+sed -i -e "s/^module = authn_denyall.*/module = authn_configfile/" \
+ /etc/cobbler/modules.conf
+sed -i -e "s/^server:.*/server: '192.168.50.2'/" \
+ -e "s/^next_server:.*/next_server: '192.168.50.2'/" \
+ /etc/cobbler/settings
+sed -i -e '/kernel /a \\tIPAPPEND 2' /etc/cobbler/pxesystem.template
+sed -i -e "s/^ONTIMEOUT.*/ONTIMEOUT $(cat /tmp/cobbler-default)/" \
+ /etc/cobbler/pxedefault.template
+
# Turn off ace on appliance restarts until we make the installation scripts
# reentrant
chkconfig ace off
--
1.6.0.3
More information about the ovirt-devel
mailing list