[Openstack-docs] [Training-Guides] sample script using devstack functions

Roger Luethi rl at patchworkscience.org
Fri Jun 13 08:02:48 UTC 2014


You may have heard that we are using devstack functions for the scripts
that build the training-labs cluster. There was some concern that
we intend to do training on devstack (i.e. code from development git
repos). That is not the case, we are currently pulling from Ubuntu's
Cloud Archive and Fedora's RDO repo.

devstack offers some helper functions which are particularly useful
for editing configuration files.

Take this section of the Ubuntu install guide, for instance:
http://docs.openstack.org/icehouse/install-guide/install/apt/content/basics-database-controller.html

The script below tries to stay close to the install guide. The meat of
it looks like this (the IP address is different, because we don't have
unified sample networks across all manuals yet):

#-----------------------------------------------------------------
echo "Sourced MySQL password from credentials: $DATABASE_PASSWORD"
sudo debconf-set-selections  <<< 'mysql-server mysql-server/root_password
password '$DATABASE_PASSWORD''
sudo debconf-set-selections <<< 'mysql-server
mysql-server/root_password_again password '$DATABASE_PASSWORD''

echo "Installing MySQL."
sudo apt-get install -y mysql-server python-mysqldb

echo "Configuring MySQL to accept requests by other nodes."
sudo bash -c "source $LIB_DIR/functions-common-devstack && \
    iniset /etc/mysql/my.cnf mysqld bind-address 10.10.10.51
    iniset /etc/mysql/my.cnf mysqld default-storage-engine innodb
    iniset /etc/mysql/my.cnf mysqld innodb_file_per_table 1
    iniset /etc/mysql/my.cnf mysqld collation-server utf8_general_ci
    iniset /etc/mysql/my.cnf mysqld init-connect \"'SET NAMES utf8'\"
    iniset /etc/mysql/my.cnf mysqld character-set-server utf8"

echo "Restarting MySQL service."
sudo service mysql restart

# TODO(rluethi) do we need mysql_secure_installation?
# XXX --use-default only in MySQL 5.7.4+ (Ubuntu 12.04 LTS: MySQL 5.5)
# mysql_secure_installation --use-default
#-----------------------------------------------------------------

iniset is a function provided by a devstack library. It allows us to
implement instructions like "set the following keys" without having to
sprinkle our scripts with sed and grep (or copying pre-made files into
place).

Roger



More information about the Openstack-docs mailing list