diff --git a/README.md b/README.md index 5c3289378a..cfcfe7c3f7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ DevStack is a set of scripts and utilities to quickly deploy an OpenStack cloud. # Goals -* To quickly build dev OpenStack environments in a clean Oneiric or Precise environment +* To quickly build dev OpenStack environments in a clean Ubuntu or Fedora environment * To describe working configurations of OpenStack (which code branches work together? what do config files look like for those branches?) * To make it easier for developers to dive into OpenStack so that they can productively contribute without having to understand every part of the system at once * To make it easy to prototype cross-project features diff --git a/files/000-default.template b/files/apache-horizon.template similarity index 77% rename from files/000-default.template rename to files/apache-horizon.template index f499ea073b..e54f16ced5 100644 --- a/files/000-default.template +++ b/files/apache-horizon.template @@ -1,13 +1,13 @@ WSGIScriptAlias / %HORIZON_DIR%/openstack_dashboard/wsgi/django.wsgi - WSGIDaemonProcess horizon user=%USER% group=%GROUP% processes=3 threads=10 + WSGIDaemonProcess horizon user=%USER% group=%GROUP% processes=3 threads=10 home=%HORIZON_DIR% + SetEnv APACHE_RUN_USER %USER% SetEnv APACHE_RUN_GROUP %GROUP% WSGIProcessGroup horizon DocumentRoot %HORIZON_DIR%/.blackhole/ Alias /media %HORIZON_DIR%/openstack_dashboard/static - Alias /vpn /opt/stack/vpn Options FollowSymLinks @@ -21,8 +21,9 @@ allow from all - ErrorLog /var/log/apache2/error.log + ErrorLog /var/log/%APACHE_NAME%/horizon_error.log LogLevel warn - CustomLog /var/log/apache2/access.log combined + CustomLog /var/log/%APACHE_NAME%/horizon_access.log combined +WSGISocketPrefix /var/run/%APACHE_NAME% diff --git a/files/pips/horizon b/files/pips/horizon index f15602e95b..c24754268d 100644 --- a/files/pips/horizon +++ b/files/pips/horizon @@ -1,3 +1,5 @@ +django-mailer # dist:f16 +django-nose # dist:f16 django-nose-selenium pycrypto==2.3 python-cloudfiles diff --git a/files/rpms/general b/files/rpms/general new file mode 100644 index 0000000000..af199d54f7 --- /dev/null +++ b/files/rpms/general @@ -0,0 +1,14 @@ +curl +euca2ools # only for testing client +git-core +openssh-server +psmisc +pylint +python-pep8 +python-pip +python-unittest2 +python-virtualenv +screen +tcpdump +unzip +wget diff --git a/files/rpms/glance b/files/rpms/glance new file mode 100644 index 0000000000..141fe9722c --- /dev/null +++ b/files/rpms/glance @@ -0,0 +1,8 @@ +python-argparse +python-eventlet +python-greenlet +python-paste-deploy +python-routes +python-sqlalchemy +python-wsgiref +pyxattr diff --git a/files/rpms/horizon b/files/rpms/horizon new file mode 100644 index 0000000000..3c5fbc1765 --- /dev/null +++ b/files/rpms/horizon @@ -0,0 +1,25 @@ +Django +django-registration +gcc +httpd # NOPRIME +mod_wsgi # NOPRIME +pylint +python-anyjson +python-boto +python-coverage +python-dateutil +python-eventlet +python-greenlet +python-httplib2 +python-kombu +python-migrate +python-mox +python-nose +python-paste +python-paste-deploy +python-pep8 +python-routes +python-sphinx +python-sqlalchemy +python-webob +pyxattr diff --git a/files/rpms/keystone b/files/rpms/keystone new file mode 100644 index 0000000000..59868c7f2f --- /dev/null +++ b/files/rpms/keystone @@ -0,0 +1,11 @@ +python-greenlet +python-lxml +python-paste +python-paste-deploy +python-paste-script +python-routes +python-setuptools +python-sqlalchemy +python-sqlite2 +python-webob +sqlite diff --git a/files/rpms/n-api b/files/rpms/n-api new file mode 100644 index 0000000000..0f08daace3 --- /dev/null +++ b/files/rpms/n-api @@ -0,0 +1 @@ +python-dateutil diff --git a/files/rpms/n-cpu b/files/rpms/n-cpu new file mode 100644 index 0000000000..1996a986b8 --- /dev/null +++ b/files/rpms/n-cpu @@ -0,0 +1,3 @@ +# Stuff for diablo volumes +iscsi-initiator-utils +lvm2 diff --git a/files/rpms/n-novnc b/files/rpms/n-novnc new file mode 100644 index 0000000000..24ce15ab7e --- /dev/null +++ b/files/rpms/n-novnc @@ -0,0 +1 @@ +numpy diff --git a/files/rpms/n-vol b/files/rpms/n-vol new file mode 100644 index 0000000000..df861aade0 --- /dev/null +++ b/files/rpms/n-vol @@ -0,0 +1,2 @@ +lvm2 +scsi-target-utils diff --git a/files/rpms/nova b/files/rpms/nova new file mode 100644 index 0000000000..1b1d47f738 --- /dev/null +++ b/files/rpms/nova @@ -0,0 +1,39 @@ +MySQL-python +curl +dnsmasq-utils # for dhcp_release +ebtables +gawk +iptables +iputils +kpartx +kvm +libvirt-bin # NOPRIME +libvirt-python +libxml2-python +m2crypto +mysql-server # NOPRIME +parted +python-boto +python-carrot +python-cheetah +python-eventlet +python-feedparser +python-gflags +python-greenlet +python-iso8601 +python-kombu +python-lockfile +python-migrate +python-mox +python-netaddr +python-paramiko +python-paste +python-paste-deploy +python-routes +python-sqlalchemy +python-suds +python-tempita +rabbitmq-server # NOPRIME +sqlite +sudo +vconfig diff --git a/files/rpms/swift b/files/rpms/swift new file mode 100644 index 0000000000..c9d49e9257 --- /dev/null +++ b/files/rpms/swift @@ -0,0 +1,18 @@ +curl +gcc +memcached # NOPRIME +python-configobj +python-coverage +python-devel +python-eventlet +python-greenlet +python-netifaces +python-nose +python-paste-deploy +python-setuptools +python-simplejson +python-webob +pyxattr +sqlite +xfsprogs +xinetd diff --git a/functions b/functions index 5114de1060..7072fdd8f6 100644 --- a/functions +++ b/functions @@ -298,21 +298,42 @@ function pip_install { # Service wrapper to restart services # restart_service service-name function restart_service() { - sudo /usr/sbin/service $1 restart + if [[ -z "$os_PACKAGE" ]]; then + GetOSVersion + fi + if [[ "$os_PACKAGE" = "deb" ]]; then + sudo /usr/sbin/service $1 restart + else + sudo /sbin/service $1 restart + fi } # Service wrapper to start services # start_service service-name function start_service() { - sudo /usr/sbin/service $1 start + if [[ -z "$os_PACKAGE" ]]; then + GetOSVersion + fi + if [[ "$os_PACKAGE" = "deb" ]]; then + sudo /usr/sbin/service $1 start + else + sudo /sbin/service $1 start + fi } # Service wrapper to stop services # stop_service service-name function stop_service() { - sudo /usr/sbin/service $1 stop + if [[ -z "$os_PACKAGE" ]]; then + GetOSVersion + fi + if [[ "$os_PACKAGE" = "deb" ]]; then + sudo /usr/sbin/service $1 stop + else + sudo /sbin/service $1 stop + fi } diff --git a/stack.sh b/stack.sh index 86e8203c15..debbc4ead3 100755 --- a/stack.sh +++ b/stack.sh @@ -32,6 +32,9 @@ GetOSVersion if [[ "$os_VENDOR" =~ (Ubuntu) ]]; then # 'Everyone' refers to Ubuntu releases by the code name adjective DISTRO=$os_CODENAME +elif [[ "$os_VENDOR" =~ (Fedora) ]]; then + # For Fedora, just use 'f' and the release + DISTRO="f$os_RELEASE" else # Catch-all for now is Vendor + Release + Update DISTRO="$os_VENDOR-$os_RELEASE.$os_UPDATE" @@ -72,7 +75,7 @@ if [[ ! -r $TOP_DIR/stackrc ]]; then echo "ERROR: missing $TOP_DIR/stackrc - did you grab more than just stack.sh?" exit 1 fi -source ./stackrc +source $TOP_DIR/stackrc # Destination path for installation ``DEST`` DEST=${DEST:-/opt/stack} @@ -83,14 +86,21 @@ DEST=${DEST:-/opt/stack} # Warn users who aren't on an explicitly supported distro, but allow them to # override check and attempt installation with ``FORCE=yes ./stack`` -if [[ ! ${DISTRO} =~ (oneiric|precise) ]]; then - echo "WARNING: this script has only been tested on oneiric and precise" +if [[ ! ${DISTRO} =~ (oneiric|precise|f16) ]]; then + echo "WARNING: this script has been tested on oneiric, precise and f16" if [[ "$FORCE" != "yes" ]]; then echo "If you wish to run this script anyway run with FORCE=yes" exit 1 fi fi +# Set the paths of certain binaries +if [[ "$os_PACKAGE" = "deb" ]]; then + NOVA_ROOTWRAP=/usr/local/bin/nova-rootwrap +else + NOVA_ROOTWRAP=/usr/bin/nova-rootwrap +fi + # stack.sh keeps the list of ``apt`` and ``pip`` dependencies in external # files, along with config templates and other useful files. You can find these # in the ``files`` directory (next to this script). We will reference this @@ -122,11 +132,16 @@ if [[ $EUID -eq 0 ]]; then # since this script runs as a normal user, we need to give that user # ability to run sudo - dpkg -l sudo || apt_get update && install_package sudo - + if [[ "$os_PACKAGE" = "deb" ]]; then + dpkg -l sudo || apt_get update && install_package sudo + STACK_GROUP=sudo + else + rpm -qa | grep sudo || install_package sudo + STACK_GROUP=wheel + fi if ! getent passwd stack >/dev/null; then echo "Creating a user called stack" - useradd -U -G sudo -s /bin/bash -d $DEST -m stack + useradd -U -G $STACK_GROUP -s /bin/bash -d $DEST -m stack fi echo "Giving stack user passwordless sudo priviledges" @@ -148,7 +163,12 @@ if [[ $EUID -eq 0 ]]; then exit 1 else # We're not root, make sure sudo is available - dpkg -l sudo || die "Sudo is required. Re-run stack.sh as root ONE TIME ONLY to set up sudo." + if [[ "$os_PACKAGE" = "deb" ]]; then + CHECK_SUDO_CMD="dpkg -l sudo" + else + CHECK_SUDO_CMD="rpm -q sudo" + fi + $CHECK_SUDO_CMD || die "Sudo is required. Re-run stack.sh as root ONE TIME ONLY to set up sudo." # UEC images /etc/sudoers does not have a '#includedir'. add one. sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers || @@ -163,7 +183,7 @@ else # Set up the rootwrap sudoers TEMPFILE=`mktemp` - echo "$USER ALL=(root) NOPASSWD: /usr/local/bin/nova-rootwrap" >$TEMPFILE + echo "$USER ALL=(root) NOPASSWD: $NOVA_ROOTWRAP" >$TEMPFILE chmod 0440 $TEMPFILE sudo chown root:root $TEMPFILE sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap @@ -549,6 +569,8 @@ fi # - ``# NOPRIME`` defers installation to be performed later in stack.sh # - ``# dist:DISTRO`` or ``dist:DISTRO1,DISTRO2`` limits the selection # of the package to the distros listed. The distro names are case insensitive. +# +# get_packages dir function get_packages() { local package_dir=$1 local file_to_parse @@ -558,7 +580,8 @@ function get_packages() { echo "No package directory supplied" return 1 fi - for service in general ${ENABLED_SERVICES//,/ }; do # Allow individual services to specify dependencies + for service in general ${ENABLED_SERVICES//,/ }; do + # Allow individual services to specify dependencies if [[ -e ${package_dir}/${service} ]]; then file_to_parse="${file_to_parse} $service" fi @@ -604,9 +627,13 @@ function get_packages() { done } -# install apt requirements -apt_get update -install_package $(get_packages $FILES/apts) +# install package requirements +if [[ "$os_PACKAGE" = "deb" ]]; then + apt_get update + install_package $(get_packages $FILES/apts) +else + install_package $(get_packages $FILES/rpms) +fi # install python requirements pip_install $(get_packages $FILES/pips | sort -u) @@ -722,6 +749,10 @@ if is_service_enabled rabbit; then install_package rabbitmq-server > "$tfile" 2>&1 cat "$tfile" rm -f "$tfile" + if [[ "$os_PACKAGE" = "rpm" ]]; then + # RPM doesn't start the service + restart_service rabbitmq-server + fi # change the rabbit password since the default is "guest" sudo rabbitmqctl change_password guest $RABBIT_PASSWORD fi @@ -732,13 +763,15 @@ fi if is_service_enabled mysql; then - # Seed configuration with mysql password so that apt-get install doesn't - # prompt us for a password upon install. - cat </etc/$APACHE_NAME/$APACHE_CONF" + restart_service $APACHE_NAME fi @@ -921,8 +983,13 @@ if is_service_enabled q-svc; then if [[ "$Q_PLUGIN" = "openvswitch" ]]; then # Install deps # FIXME add to files/apts/quantum, but don't install if not needed! - kernel_version=`cat /proc/version | cut -d " " -f3` - install_package openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version + if [[ "$os_PACKAGE" = "deb" ]]; then + kernel_version=`cat /proc/version | cut -d " " -f3` + install_package openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version + else + ### FIXME(dtroyer): Find RPMs for OpenVSwitch + echo "OpenVSwitch packages need to be located" + fi # Create database for the plugin/agent if is_service_enabled mysql; then mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS ovs_quantum;' @@ -1044,7 +1111,12 @@ if is_service_enabled n-cpu; then # Virtualization Configuration # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - install_package libvirt-bin + if [[ "$os_PACKAGE" = "deb" ]]; then + LIBVIRT_PKG_NAME=libvirt-bin + else + LIBVIRT_PKG_NAME=libvirt + fi + install_package $LIBVIRT_PKG_NAME # Force IP forwarding on, just on case sudo sysctl -w net.ipv4.ip_forward=1 @@ -1067,27 +1139,50 @@ if is_service_enabled n-cpu; then # splitting a system into many smaller parts. LXC uses cgroups and chroot # to simulate multiple systems. if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then - if [[ "$DISTRO" > natty ]]; then - install_package cgroup-lite + if [[ "$os_PACKAGE" = "deb" ]]; then + if [[ "$DISTRO" > natty ]]; then + install_package cgroup-lite + else + cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" + sudo mkdir -p /cgroup + if ! grep -q cgroup /etc/fstab; then + echo "$cgline" | sudo tee -a /etc/fstab + fi + if ! mount -n | grep -q cgroup; then + sudo mount /cgroup + fi + fi else - cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" - sudo mkdir -p /cgroup - if ! grep -q cgroup /etc/fstab; then - echo "$cgline" | sudo tee -a /etc/fstab - fi - if ! mount -n | grep -q cgroup; then - sudo mount /cgroup - fi + ### FIXME(dtroyer): figure this out + echo "RPM-based cgroup not implemented yet" + yum_install libcgroup-tools fi fi + if [[ "$os_PACKAGE" = "deb" ]]; then + LIBVIRT_DAEMON=libvirt-bin + else + # http://wiki.libvirt.org/page/SSHPolicyKitSetup + if ! grep ^libvirtd: /etc/group >/dev/null; then + sudo groupadd libvirtd + fi + sudo bash -c 'cat </etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla +[libvirt Management Access] +Identity=unix-group:libvirtd +Action=org.libvirt.unix.manage +ResultAny=yes +ResultInactive=yes +ResultActive=yes +EOF' + LIBVIRT_DAEMON=libvirtd + fi # The user that nova runs as needs to be member of libvirtd group otherwise # nova-compute will be unable to use libvirt. sudo usermod -a -G libvirtd `whoami` # libvirt detects various settings on startup, as we potentially changed # the system configuration (modules, filesystems), we need to restart # libvirt to detect those changes. - restart_service libvirt-bin + restart_service $LIBVIRT_DAEMON # Instance Storage @@ -1202,7 +1297,11 @@ if is_service_enabled swift; then s/%USER%/$USER/; s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,; " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf - sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync + if [[ "$os_PACKAGE" = "deb" ]]; then + sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync + else + sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync + fi # By default Swift will be installed with the tempauth middleware # which has some default username and password if you have @@ -1267,10 +1366,10 @@ if is_service_enabled swift; then swift_log_dir=${SWIFT_DATA_DIR}/logs rm -rf ${swift_log_dir} mkdir -p ${swift_log_dir}/hourly - sudo chown -R syslog:adm ${swift_log_dir} + sudo chown -R $USER:adm ${swift_log_dir} sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \ tee /etc/rsyslog.d/10-swift.conf - sudo restart rsyslog + restart_service rsyslog # This is where we create three different rings for swift with # different object servers binding on different ports. @@ -1304,10 +1403,12 @@ if is_service_enabled swift; then } && popd >/dev/null - sudo chmod +x /usr/local/bin/swift-* - # We then can start rsync. - sudo /etc/init.d/rsync restart || : + if [[ "$os_PACKAGE" = "deb" ]]; then + sudo /etc/init.d/rsync restart || : + else + sudo systemctl start xinetd.service + fi # First spawn all the swift services then kill the # proxy service so we can run it in foreground in screen. @@ -1332,9 +1433,6 @@ if is_service_enabled n-vol; then # # By default, the backing file is 2G in size, and is stored in /opt/stack. - # install the package - install_package tgt - if ! sudo vgs $VOLUME_GROUP; then VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DEST/nova-volumes-backing-file} VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-2052M} @@ -1357,10 +1455,15 @@ if is_service_enabled n-vol; then done fi - # tgt in oneiric doesn't restart properly if tgtd isn't running - # do it in two steps - sudo stop tgt || true - sudo start tgt + if [[ "$os_PACKAGE" = "deb" ]]; then + # tgt in oneiric doesn't restart properly if tgtd isn't running + # do it in two steps + sudo stop tgt || true + sudo start tgt + else + # bypass redirection to systemctl during restart + sudo /sbin/service --skip-redirect tgtd restart + fi fi NOVA_CONF=nova.conf @@ -1377,7 +1480,7 @@ add_nova_opt "[DEFAULT]" add_nova_opt "verbose=True" add_nova_opt "auth_strategy=keystone" add_nova_opt "allow_resize_to_same_host=True" -add_nova_opt "root_helper=sudo /usr/local/bin/nova-rootwrap" +add_nova_opt "root_helper=sudo $NOVA_ROOTWRAP" add_nova_opt "compute_scheduler_driver=$SCHEDULER" add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF_DIR/$NOVA_CONF" add_nova_opt "fixed_range=$FIXED_RANGE" @@ -1661,7 +1764,7 @@ screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler" screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ." screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF" screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth" -screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log" +screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/$APACHE_NAME/horizon_error.log" screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v" # Starting the nova-objectstore only if swift service is not enabled. diff --git a/unstack.sh b/unstack.sh index cfe2de6db4..7de0d749e5 100755 --- a/unstack.sh +++ b/unstack.sh @@ -49,7 +49,7 @@ if is_service_enabled n-vol; then echo "iSCSI target cleanup needed:" echo "$TARGETS" fi - sudo stop tgt + stop_service tgt fi if [[ -n "$UNSTACK_ALL" ]]; then