Commit b2634d01 authored by David Johnson's avatar David Johnson

Make package installation optional, and separate install/upgrade.

Quit trying to apt-get packages if they're installed, unless the
user selects the new DO_APT_UPGRADE option.  Always install was nice
in the beginning, but it is no longer the best use case, and it can
cause uncertainty when failures happen (i.e., if new versions of
packages get installed that the scripts can't handle).  So now there
are three apt options in the scripts and in the geni-lib script:

DO_APT_UPDATE -- updates the apt cache (often hard to do pkg
  install/upgrade if the cache is out of date); defaults to 1
DO_APT_INSTALL -- if this is set 0, we don't install *anything*
  other than critical deps (think python-m2crypto); defaults to 1
DO_APT_UPGRADE -- if this is set 1, we always run apt-get install
  to either install and/or upgrade OpenStack packages and deps.
  The big change is that this now defaults to 0 -- so packages are
  not upgraded from their current versions if they exist.
parent 1c33830d
......@@ -30,7 +30,7 @@ fi
echo "*** Building an ARM64 image ..."
# need growpart
$APTGETINSTALL cloud-guest-utils
maybe_install_packages cloud-guest-utils
# Grab some files
wget http://boss.utah.cloudlab.us/downloads/vmlinuz-3.13.0-40-arm64-generic
......
......@@ -39,7 +39,7 @@ EOF
sysctl -p
$APTGETINSTALL neutron-plugin-ml2 neutron-plugin-openvswitch-agent
maybe_install_packages neutron-plugin-ml2 neutron-plugin-openvswitch-agent
sed -i -e "s/^\\(.*connection.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_host.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
......
......@@ -29,7 +29,7 @@ fi
$APTGETINSTALL ceilometer-agent-compute
maybe_install_packages ceilometer-agent-compute
# Just slap these in.
cat <<EOF >> /etc/nova/nova.conf
......
......@@ -29,8 +29,8 @@ if [ -f $SETTINGS ]; then
. $SETTINGS
fi
$APTGETINSTALL nova-compute sysfsutils
$APTGETINSTALL libguestfs-tools libguestfs0 python-guestfs
maybe_install_packages nova-compute sysfsutils
maybe_install_packages libguestfs-tools libguestfs0 python-guestfs
cat <<EOF >> /etc/nova/nova.conf
[DEFAULT]
......
......@@ -35,7 +35,7 @@ fi
#
# Setup mail to users
#
$APTGETINSTALL dma
maybe_install_packages dma
echo "Your OpenStack instance is setting up on `hostname` ." \
| mail -s "OpenStack Instance Setting Up" ${SWAPPER_EMAIL} &
......@@ -43,7 +43,7 @@ echo "Your OpenStack instance is setting up on `hostname` ." \
# Install the database
#
if [ -z "${DB_ROOT_PASS}" ]; then
$APTGETINSTALL mariadb-server python-mysqldb
maybe_install_packages mariadb-server python-mysqldb
service_stop mysql
# Change the root password; secure the users/dbs.
mysqld_safe --skip-grant-tables --skip-networking &
......@@ -73,7 +73,7 @@ fi
# Install a message broker
#
if [ -z "${RABBIT_PASS}" ]; then
$APTGETINSTALL rabbitmq-server
maybe_install_packages rabbitmq-server
service_restart rabbitmq-server
service_enable rabbitmq-server
......@@ -127,7 +127,7 @@ if [ -z "${KEYSTONE_DBPASS}" ]; then
echo "grant all privileges on keystone.* to 'keystone'@'localhost' identified by '$KEYSTONE_DBPASS'" | mysql -u root --password="$DB_ROOT_PASS"
echo "grant all privileges on keystone.* to 'keystone'@'%' identified by '$KEYSTONE_DBPASS'" | mysql -u root --password="$DB_ROOT_PASS"
$APTGETINSTALL keystone python-keystoneclient
maybe_install_packages keystone python-keystoneclient
ADMIN_TOKEN=`$PSWDGEN`
......@@ -255,7 +255,7 @@ if [ -z "${GLANCE_DBPASS}" ]; then
--adminurl http://$CONTROLLER:9292 \
--region regionOne
$APTGETINSTALL glance python-glanceclient
maybe_install_packages glance python-glanceclient
sed -i -e "s/^.*connection.*=.*$/connection = mysql:\\/\\/glance:${GLANCE_DBPASS}@$CONTROLLER\\/glance/" /etc/glance/glance-api.conf
# Just slap these in.
......@@ -309,7 +309,7 @@ if [ -z "${NOVA_DBPASS}" ]; then
NOVA_PASS=`$PSWDGEN`
# Make sure we're consistent with the clients
$APTGETINSTALL nova-api
maybe_install_packages nova-api
echo "create database nova" | mysql -u root --password="$DB_ROOT_PASS"
echo "grant all privileges on nova.* to 'nova'@'localhost' identified by '$NOVA_DBPASS'" | mysql -u root --password="$DB_ROOT_PASS"
......@@ -326,11 +326,11 @@ if [ -z "${NOVA_DBPASS}" ]; then
--adminurl http://$CONTROLLER:8774/v2/%\(tenant_id\)s \
--region regionOne
$APTGETINSTALL nova-api nova-cert nova-conductor nova-consoleauth \
maybe_install_packages nova-api nova-cert nova-conductor nova-consoleauth \
nova-novncproxy nova-scheduler python-novaclient
if [ ${ENABLE_NEW_SERIAL_SUPPORT} = 1 ]; then
$APTGETINSTALL nova-serialproxy
maybe_install_packages nova-serialproxy
mkdir -p $OURDIR/src
( cd $OURDIR/src && git clone https://github.com/larsks/novaconsole )
( cd $OURDIR/src && git clone https://github.com/liris/websocket-client )
......@@ -447,7 +447,7 @@ if [ -z "${NEUTRON_DBPASS}" ]; then
--internalurl http://$CONTROLLER:9696 \
--region regionOne
$APTGETINSTALL neutron-server neutron-plugin-ml2 python-neutronclient
maybe_install_packages neutron-server neutron-plugin-ml2 python-neutronclient
#
# Install a patch to make manual router interfaces less likely to hijack
......@@ -644,7 +644,7 @@ fi
if [ -z "${DASHBOARD_DONE}" ]; then
DASHBOARD_DONE=1
$APTGETINSTALL openstack-dashboard apache2 libapache2-mod-wsgi memcached python-memcache
maybe_install_packages openstack-dashboard apache2 libapache2-mod-wsgi memcached python-memcache
sed -i -e "s/OPENSTACK_HOST.*=.*\$/OPENSTACK_HOST = \"${CONTROLLER}\"/" \
/etc/openstack-dashboard/local_settings.py
......@@ -702,7 +702,7 @@ if [ -z "${CINDER_DBPASS}" ]; then
--adminurl http://${CONTROLLER}:8776/v2/%\(tenant_id\)s \
--region regionOne
$APTGETINSTALL cinder-api cinder-scheduler python-cinderclient
maybe_install_packages cinder-api cinder-scheduler python-cinderclient
sed -i -e "s/^\\(.*volume_group.*=.*\\)$/#\1/" /etc/cinder/cinder.conf
......@@ -801,7 +801,7 @@ if [ -z "${SWIFT_PASS}" ]; then
--adminurl http://${CONTROLLER}:8080 \
--region regionOne
$APTGETINSTALL swift swift-proxy python-swiftclient \
maybe_install_packages swift swift-proxy python-swiftclient \
python-keystoneclient python-keystonemiddleware memcached
mkdir -p /etc/swift
......@@ -997,7 +997,7 @@ if [ -z "${HEAT_DBPASS}" ]; then
--adminurl http://${CONTROLLER}:8000/v1 \
--region regionOne
$APTGETINSTALL heat-api heat-api-cfn heat-engine python-heatclient
maybe_install_packages heat-api heat-api-cfn heat-engine python-heatclient
sed -i -e "s/^.*connection.*=.*$/connection = mysql:\\/\\/heat:${HEAT_DBPASS}@$CONTROLLER\\/heat/" /etc/heat/heat.conf
# Just slap these in.
......@@ -1053,7 +1053,7 @@ if [ -z "${CEILOMETER_DBPASS}" ]; then
CEILOMETER_SECRET=`$PSWDGEN`
if [ "${CEILOMETER_USE_MONGODB}" = "1" ]; then
$APTGETINSTALL mongodb-server python-pymongo
maybe_install_packages mongodb-server python-pymongo
sed -i -e "s/^.*bind_ip.*=.*$/bind_ip = ${MGMTIP}/" /etc/mongodb.conf
......@@ -1070,7 +1070,7 @@ if [ -z "${CEILOMETER_DBPASS}" ]; then
MDONE=$?
done
else
$APTGETINSTALL mariadb-server python-mysqldb
maybe_install_packages mariadb-server python-mysqldb
echo "create database ceilometer" | mysql -u root --password="$DB_ROOT_PASS"
echo "grant all privileges on ceilometer.* to 'ceilometer'@'localhost' identified by '$CEILOMETER_DBPASS'" | mysql -u root --password="$DB_ROOT_PASS"
......@@ -1089,7 +1089,7 @@ if [ -z "${CEILOMETER_DBPASS}" ]; then
--adminurl http://${CONTROLLER}:8777 \
--region regionOne
$APTGETINSTALL ceilometer-api ceilometer-collector \
maybe_install_packages ceilometer-api ceilometer-collector \
ceilometer-agent-central ceilometer-agent-notification \
ceilometer-alarm-evaluator ceilometer-alarm-notifier \
python-ceilometerclient python-bson
......@@ -1279,7 +1279,7 @@ if [ -z "${TELEMETRY_SWIFT_DONE}" ]; then
chmod g+w /var/log/ceilometer
$APTGETINSTALL python-ceilometerclient
maybe_install_packages python-ceilometerclient
keystone role-create --name ResellerAdmin
keystone user-role-add --tenant service --user ceilometer \
......@@ -1321,15 +1321,15 @@ if [ -z "${TROVE_DBPASS}" ]; then
TROVE_PASS=`$PSWDGEN`
# trove on Ubuntu Vivid was broken at the time this was done...
$APTGETINSTALL trove-common
maybe_install_packages trove-common
if [ ! $? -eq 0 ]; then
touch /var/lib/trove/trove_test.sqlite
chown trove:trove /var/lib/trove/trove_test.sqlite
crudini --set /etc/trove/trove.conf database connection sqlite:////var/lib/trove/trove_test.sqlite
$APTGETINSTALL trove-common
maybe_install_packages trove-common
fi
$APTGETINSTALL python-trove python-troveclient python-glanceclient \
maybe_install_packages python-trove python-troveclient python-glanceclient \
trove-api trove-taskmanager trove-conductor
echo "create database trove" | mysql -u root --password="$DB_ROOT_PASS"
......@@ -1493,16 +1493,16 @@ if [ -z "${SAHARA_DBPASS}" ]; then
if [ ${APT_HAS_SAHARA} -eq 0 ]; then
# XXX: http://askubuntu.com/questions/555093/openstack-juno-sahara-data-processing-on-14-04
$APTGETINSTALL python-pip
maybe_install_packages python-pip
# sahara deps
$APTGETINSTALL python-eventlet python-flask python-oslo.serialization
maybe_install_packages python-eventlet python-flask python-oslo.serialization
pip install sahara
else
# This may fail because sahara's migration scripts use ALTER TABLE,
# which sqlite doesn't support
$APTGETINSTALL sahara-common
maybe_install_packages sahara-common
aserr=$?
$APTGETINSTALL sahara-api sahara-engine
maybe_install_packages sahara-api sahara-engine
fi
mkdir -p /etc/sahara
......@@ -1536,7 +1536,7 @@ EOF
# If the apt-get install had failed, do it again so that the configure
# step can succeed ;)
if [ ! $aserr -eq 0 ]; then
$APTGETINSTALL sahara-common sahara-api sahara-engine
maybe_install_packages sahara-common sahara-api sahara-engine
fi
sahara-db-manage --config-file /etc/sahara/sahara.conf upgrade head
......@@ -1585,7 +1585,7 @@ if [ 0 = 1 -a "$OSCODENAME" = "kilo" -a -n "$BAREMETALNODES" -a -z "${IRONIC_DBP
--adminurl http://${CONTROLLER}:6385 \
--region regionOne
$APTGETINSTALL ironic-api ironic-conductor python-ironicclient python-ironic
maybe_install_packages ironic-api ironic-conductor python-ironicclient python-ironic
crudini --set /etc/ironic/ironic.conf \
database connection "mysql://ironic:${IRONIC_DBPASS}@$CONTROLLER/ironic?charset=utf8"
......
......@@ -25,6 +25,7 @@ DATAVLANS=""
DATAVXLANS=0
USE_EXISTING_IPS=1
DO_APT_INSTALL=1
DO_APT_UPGRADE=0
DO_APT_UPDATE=1
ENABLE_NEW_SERIAL_SUPPORT=0
DO_UBUNTU_CLOUDARCHIVE=1
......@@ -69,8 +70,8 @@ SWAPPER=`cat $BOOTDIR/swapper`
# NB: force the install of python-m2crypto if geniuser
#
if [ "$SWAPPER" = "geniuser" ]; then
dpkg-query -l python-m2crypto | grep -q ii
if [ ! $? = 0 ]; then
dpkg -s python-m2crypto >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
apt-get install python-m2crypto
fi
......@@ -293,8 +294,8 @@ export DEBIAN_FRONTEND=noninteractive
# -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
APTGETINSTALLOPTS='-y'
APTGETINSTALL="apt-get install $APTGETINSTALLOPTS"
# Don't install/update packages if this is not set
if [ ! ${DO_APT_INSTALL} -eq 1 ]; then
# Don't install/upgrade packages if this is not set
if [ ${DO_APT_INSTALL} -eq 0 ]; then
APTGETINSTALL="/bin/true ${APTGETINSTALL}"
fi
......@@ -311,6 +312,47 @@ if [ ! -f $OURDIR/apt-updated -a "${DO_APT_UPDATE}" = "1" ]; then
touch $OURDIR/apt-updated
fi
are_packages_installed() {
retval=1
while [ ! -z "$1" ] ; do
dpkg -s "$1" >/dev/null 2>&1
if [ ! $? -eq 0 ] ; then
retval=0
fi
shift
done
return $retval
}
maybe_install_packages() {
if [ ! ${DO_APT_UPGRADE} -eq 0 ] ; then
# Just do an install/upgrade to make sure the package(s) are installed
# and upgraded; we want to try to upgrade the package.
$APTGETINSTALL $@
return $?
else
# Ok, check if the package is installed; if it is, don't install.
# Otherwise, install (and maybe upgrade, due to dependency side effects).
# Also, optimize so that we try to install or not install all the
# packages at once if none are installed.
are_packages_installed $@
if [ $? -eq 1 ]; then
return 0
fi
retval=0
while [ ! -z "$1" ] ; do
are_packages_installed $1
if [ $? -eq 0 ]; then
$APTGETINSTALL $1
retval=`expr $retval \| $?`
fi
shift
done
return $retval
fi
}
if [ ! -f /etc/apt/sources.list.d/cloudarchive-${OSCODENAME}.list \
-a ! -f $OURDIR/cloudarchive-added \
-a "${DO_UBUNTU_CLOUDARCHIVE}" = "1" ]; then
......@@ -326,7 +368,7 @@ fi
#
# We rely on crudini in a few spots, instead of sed whacking.
#
$APTGETINSTALL crudini
maybe_install_packages crudini
#
# Create IP addresses for the Management and Data networks, as necessary.
......
......@@ -38,7 +38,7 @@ EOF
sysctl -p
$APTGETINSTALL neutron-plugin-ml2 neutron-plugin-openvswitch-agent \
maybe_install_packages neutron-plugin-ml2 neutron-plugin-openvswitch-agent \
neutron-l3-agent neutron-dhcp-agent conntrack neutron-metering-agent
sed -i -e "s/^\\(.*connection.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
......
......@@ -30,7 +30,7 @@ if [ -f $LOCALSETTINGS ]; then
. $LOCALSETTINGS
fi
$APTGETINSTALL xfsprogs rsync
maybe_install_packages xfsprogs rsync
#
# First try to make LVM volumes; fall back to loop device in /storage. We use
......@@ -112,7 +112,7 @@ service rsync start
mkdir -p /var/log/swift
chown -R syslog.adm /var/log/swift
$APTGETINSTALL swift swift-account swift-container swift-object
maybe_install_packages swift swift-account swift-container swift-object
wget -O /etc/swift/account-server.conf \
"https://git.openstack.org/cgit/openstack/swift/plain/etc/account-server.conf-sample?h=stable/${OSCODENAME}"
......
......@@ -48,7 +48,7 @@ INTEGRATION_NETWORK_BRIDGE="br-int"
#
# Otherwise, first we need openvswitch.
#
$APTGETINSTALL openvswitch-common openvswitch-switch
maybe_install_packages openvswitch-common openvswitch-switch
# Make sure it's running
service_restart openvswitch
......
......@@ -32,7 +32,7 @@ fi
ARCH=`uname -m`
$APTGETINSTALL lvm2
maybe_install_packages lvm2
if [ "$ARCH" = "aarch64" ]; then
# XXX: have to copy the .bak versions back into place on uBoot-nodes.
......@@ -76,7 +76,7 @@ if [ $LVM -eq 0 ] ; then
vgcreate $VGNAME /dev/loop0
fi
$APTGETINSTALL cinder-volume python-mysqldb
maybe_install_packages cinder-volume python-mysqldb
if [ "${STORAGEHOST}" != "${CONTROLLER}" ]; then
# Just slap these in.
......
......@@ -16,7 +16,7 @@ fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
$APTGETINSTALL openvpn
maybe_install_packages openvpn
cp -p $OURDIR/$HOSTNAME.crt $OURDIR/$HOSTNAME.key /etc/openvpn/
cp -p $OURDIR/ca.crt /etc/openvpn
......
......@@ -22,7 +22,7 @@ if [ "$HOSTNAME" != "$NETWORKMANAGER" ]; then
exit 0;
fi
$APTGETINSTALL openvpn easy-rsa
maybe_install_packages openvpn easy-rsa
#
# Get our server CA config set up.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment