[Ovirt-devel] [PATCH recipe] Split ovirt-appliance init script into storage and dnsmasq
Perry Myers
pmyers at redhat.com
Fri Nov 14 09:07:27 UTC 2008
This makes the appliance a little more deterministic in setup.
DNS services must be working correctly prior to calling the
ovirt-server-appliance-setup script, but storage can't be activated
until after. Splitting up these two services allows us to set up
the dependencies properly in the puppet file.
This fixes a transient bug where the appliance would start but
the services would fail to configure properly. I was seeing
this around 25% of the time with appliance firstboot.
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
Makefile.am | 3 +-
appliances/ovirt/files/ovirt-dnsmasq.conf | 25 ++++++
appliances/ovirt/files/ovirt-server-appliance | 87 --------------------
appliances/ovirt/files/ovirt-storage | 72 ++++++++++++++++
appliances/ovirt/ovirt.pp.in | 31 +++++--
.../templates/ovirt-server-appliance-setup.erb | 16 ++++
6 files changed, 137 insertions(+), 97 deletions(-)
create mode 100644 appliances/ovirt/files/ovirt-dnsmasq.conf
delete mode 100644 appliances/ovirt/files/ovirt-server-appliance
create mode 100644 appliances/ovirt/files/ovirt-storage
diff --git a/Makefile.am b/Makefile.am
index 4f7f939..2505208 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,7 +30,8 @@ EXTRA_DIST = \
appliances/ovirt/files/qpidd.conf \
appliances/ovirt/files/ovirt-cfgdb \
appliances/ovirt/files/ovirt.repo \
- appliances/ovirt/files/ovirt-server-appliance \
+ appliances/ovirt/files/ovirt-dnsmasq.conf \
+ appliances/ovirt/files/ovirt-storage \
appliances/ovirt/files/ovirt-splash.xpm.gz \
appliances/ovirt/templates/ovirt-server-appliance-setup.erb \
appliances/ovirt/templates/terminal.erb
diff --git a/appliances/ovirt/files/ovirt-dnsmasq.conf b/appliances/ovirt/files/ovirt-dnsmasq.conf
new file mode 100644
index 0000000..716ccd4
--- /dev/null
+++ b/appliances/ovirt/files/ovirt-dnsmasq.conf
@@ -0,0 +1,25 @@
+interface=eth1
+dhcp-range=192.168.50.6,192.168.50.252
+dhcp-host=00:16:3e:12:34:57,192.168.50.3
+dhcp-host=00:16:3e:12:34:58,192.168.50.4
+dhcp-host=00:16:3e:12:34:59,192.168.50.5
+domain=priv.ovirt.org
+srv-host=_ovirt._tcp,management.priv.ovirt.org,80
+srv-host=_ipa._tcp,management.priv.ovirt.org,80
+srv-host=_ldap._tcp,management.priv.ovirt.org,389
+srv-host=_collectd._tcp,management.priv.ovirt.org,25826
+srv-host=_qpidd._tcp,management.priv.ovirt.org,5672
+srv-host=_identify._tcp,management.priv.ovirt.org,12120
+enable-tftp
+tftp-root=/var/lib/tftpboot
+dhcp-boot=pxelinux.0
+dhcp-option=option:router,192.168.50.2
+dhcp-option=option:ntp-server,192.168.50.2
+dhcp-option=12
+no-resolv
+local=/priv.ovirt.org/
+server=192.168.122.1
+
+
+
+
diff --git a/appliances/ovirt/files/ovirt-server-appliance b/appliances/ovirt/files/ovirt-server-appliance
deleted file mode 100644
index 5cf530d..0000000
--- a/appliances/ovirt/files/ovirt-server-appliance
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-#
-# ovirt-server-appliance oVirt Server Appliance service
-#
-# chkconfig: 3 96 4
-# description: ovirt server appliance service
-#
-
-# Source functions library
-. /etc/init.d/functions
-TARGET_ID=32101
-
-start() {
- echo -n "Starting ovirt-server-appliance: "
- dnsmasq -i eth1 -F 192.168.50.6,192.168.50.252 \
- -G 00:16:3e:12:34:57,192.168.50.3 -G 00:16:3e:12:34:58,192.168.50.4 \
- -G 00:16:3e:12:34:59,192.168.50.5 \
- -s priv.ovirt.org \
- -W _ovirt._tcp,management.priv.ovirt.org,80 \
- -W _ipa._tcp,management.priv.ovirt.org,80 \
- -W _ldap._tcp,management.priv.ovirt.org,389 \
- -W _collectd._tcp,management.priv.ovirt.org,25826 \
- -W _qpidd._tcp,management.priv.ovirt.org,5672 \
- -W _identify._tcp,management.priv.ovirt.org,12120 \
- --enable-tftp --tftp-root=/var/lib/tftpboot -M pxelinux.0 \
- -O option:router,192.168.50.2 -O option:ntp-server,192.168.50.2 \
- --dhcp-option=12 \
- -R --local /priv.ovirt.org/ --server 192.168.122.1
-
- # Set up the fake iscsi target
- tgtadm --lld iscsi --op new --mode target --tid $TARGET_ID \
- -T ovirtpriv:storage
-
- #
- # Now associate them to the LVs
- #
- tgtadm --lld iscsi --op new --mode logicalunit --tid $TARGET_ID \
- --lun 1 -b /ovirtiscsi/iSCSI3
- tgtadm --lld iscsi --op new --mode logicalunit --tid $TARGET_ID \
- --lun 2 -b /ovirtiscsi/iSCSI4
- tgtadm --lld iscsi --op new --mode logicalunit --tid $TARGET_ID \
- --lun 3 -b /ovirtiscsi/iSCSI5
-
- #
- # Now make them available
- #
- tgtadm --lld iscsi --op bind --mode target --tid $TARGET_ID -I ALL
-
- echo_success
- echo
-}
-
-stop() {
- echo -n "Stopping ovirt-server-appliance: "
-
- # stop access to the iscsi target
- tgtadm --lld iscsi --op unbind --mode target --tid $TARGET_ID -I ALL
-
- # unbind the LUNs
- tgtadm --lld iscsi --op delete --mode logicalunit --tid $TARGET_ID --lun 3
- tgtadm --lld iscsi --op delete --mode logicalunit --tid $TARGET_ID --lun 2
- tgtadm --lld iscsi --op delete --mode logicalunit --tid $TARGET_ID --lun 1
-
- # shutdown the target
- tgtadm --lld iscsi --op delete --mode target --tid $TARGET_ID
-
- kill $(cat /var/run/dnsmasq.pid)
-
- echo_success
- echo
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo "Usage: ovirt-server-appliance {start|stop|restart}"
- exit 2
-esac
diff --git a/appliances/ovirt/files/ovirt-storage b/appliances/ovirt/files/ovirt-storage
new file mode 100644
index 0000000..2679995
--- /dev/null
+++ b/appliances/ovirt/files/ovirt-storage
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# ovirt-storage Set up storage for oVirt Server Appliance
+#
+# chkconfig: 3 96 4
+# description: oVirt Appliance Storage Services
+#
+
+# Source functions library
+. /etc/init.d/functions
+TARGET_ID=32101
+
+prog="ovirt-storage"
+num_iscsi_luns=5
+
+start() {
+ echo -n "Starting $prog: "
+
+ # Set up the fake iscsi target
+ tgtadm --lld iscsi --op new --mode target --tid $TARGET_ID \
+ -T ovirtpriv:storage
+
+ #
+ # Now associate them to the LVs
+ #
+ for i in `seq 1 $num_iscsi_luns` ; do
+ tgtadm --lld iscsi --op new --mode logicalunit --tid $TARGET_ID \
+ --lun $i -b /ovirtiscsi/iSCSI$i
+ done
+
+ #
+ # Now make them available
+ #
+ tgtadm --lld iscsi --op bind --mode target --tid $TARGET_ID -I ALL
+
+ echo_success
+ echo
+}
+
+stop() {
+ echo -n "Stopping $prog: "
+
+ # stop access to the iscsi target
+ tgtadm --lld iscsi --op unbind --mode target --tid $TARGET_ID -I ALL
+
+ # unbind the LUNs
+ for i in `seq 1 $num_iscsi_luns` ; do
+ tgtadm --lld iscsi --op delete --mode logicalunit --tid $TARGET_ID --lun $i
+ done
+
+ # shutdown the target
+ tgtadm --lld iscsi --op delete --mode target --tid $TARGET_ID
+
+ echo_success
+ echo
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 2
+esac
diff --git a/appliances/ovirt/ovirt.pp.in b/appliances/ovirt/ovirt.pp.in
index 9ac4c12..70ca04b 100644
--- a/appliances/ovirt/ovirt.pp.in
+++ b/appliances/ovirt/ovirt.pp.in
@@ -153,6 +153,18 @@ service {"qpidd":
enable => true
}
+file {"/etc/dnsmasq.d/ovirt-dnsmasq.conf":
+ source => "puppet:///ovirt/ovirt-dnsmasq.conf",
+ mode => 644
+}
+
+service {"dnsmasq":
+ ensure => "running",
+ enable => true ,
+ require => [File["/etc/dnsmasq.d/ovirt-dnsmasq.conf"],
+ Service["network"]]
+}
+
file {"/usr/sbin/ovirt-server-appliance-setup":
content => template("ovirt-server-appliance-setup.erb"),
mode => 755
@@ -161,7 +173,8 @@ file {"/usr/sbin/ovirt-server-appliance-setup":
single_exec {"ovirt_appliance_installation":
command => "/usr/sbin/ovirt-server-appliance-setup >> /var/log/ovirt-server-appliance-setup.log 2>&1",
require => [File["/usr/sbin/ovirt-server-appliance-setup"],
- Exec["reload-firewall"],Augeas["network_scripts"]]
+ Exec["reload-firewall"],Augeas["network_scripts"],
+ Service["dnsmasq"]]
}
file {"/usr/sbin/cobbler-import":
@@ -188,23 +201,23 @@ single_exec {"cobbler-import":
Single_exec["ovirt_appliance_installation"]]
}
-file {"/etc/init.d/ovirt-server-appliance":
- source => "puppet:///ovirt/ovirt-server-appliance",
+file {"/etc/init.d/ovirt-storage":
+ source => "puppet:///ovirt/ovirt-storage",
mode => 755
}
-service {"ovirt-server-appliance":
+service {"ovirt-storage":
ensure => "running",
enable => true ,
- require => [File["/etc/init.d/ovirt-server-appliance"],
- Service["network"], Service["httpd"],
- Single_exec["ovirt_appliance_installation"],
- Single_exec["cobbler-import"]]
+ require => [File["/etc/init.d/ovirt-storage"],
+ Service["network"],
+ Single_exec["ovirt_appliance_installation"]]
}
single_exec {"ovirt_installation":
command => "/usr/sbin/ovirt-server-install >> /var/log/ovirt-server-install.log 2>&1",
- require => [Service["postgresql"],Service["ovirt-server-appliance"]]
+ require => [Service["postgresql"],Service["ovirt-storage"],Service["dnsmasq"],
+ Single_exec["ovirt_appliance_installation"],Single_exec["cobbler-import"]]
}
diff --git a/appliances/ovirt/templates/ovirt-server-appliance-setup.erb b/appliances/ovirt/templates/ovirt-server-appliance-setup.erb
index 93cb2e5..bc542d6 100644
--- a/appliances/ovirt/templates/ovirt-server-appliance-setup.erb
+++ b/appliances/ovirt/templates/ovirt-server-appliance-setup.erb
@@ -1,15 +1,28 @@
#!/bin/bash
export PATH=/usr/kerberos/bin:$PATH
+set -x
+set -e
+
# 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
+sed -i -e 's/management//' /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
+service dnsmasq reload
+
+# FIXME: This is a temporary fix to correct a problem in the puppet config
+# dependencies. Sometimes the network will not get restarted with the right
+# DNS server until after this script runs, which causes the IPA setup to fail.
+# Once we remove the need for dhcp from the client (by only having a single
+# interface with 50.2 as the address) this hack will go away
+echo "nameserver 192.168.50.2" > /etc/resolv.conf
+
# 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
@@ -81,3 +94,6 @@ echo "/cobblernfs 192.168.50.0/24(rw,no_root_squash)" >> /etc/exports
# Turn off ace on appliance restarts until we make the installation scripts
# reentrant
chkconfig ace off
+
+set +x
+set +e
--
1.6.0.3
More information about the ovirt-devel
mailing list