New DevStack server build profile, various fixes

Change-Id: Ifadef35f9abcc5e8b4d9efecb0fa2a345cd380fc
This commit is contained in:
David Schroeder 2014-07-16 13:14:32 -06:00
parent 88c81e7726
commit 4c4b9d42a8
18 changed files with 362 additions and 111 deletions

View File

@ -6,6 +6,7 @@ end
cookbook 'mini-mon', path: './cookbooks/mini-mon'
cookbook 'devstack', path: './cookbooks/devstack'
cookbook 'ds-build', path: './cookbooks/ds-build'
cookbook 'mon_api', git: 'https://github.com/hpcloud-mon/cookbooks-mon_api'
cookbook 'kafka', git: 'https://github.com/hpcloud-mon/cookbooks-kafka'
cookbook 'mon_agent', git: 'https://github.com/hpcloud-mon/cookbooks-mon_agent'

View File

@ -144,6 +144,7 @@ To run any of these alternate configs, simply run the Vagrant commands from with
(not symlinked) into the subdir as well. See the README.md in the subdir for more details.
- `split` subdir - The various monitoring components split into their own VMs. The split setup runs Vertica by default rather than influxdb.
- `ds-build` subdir - This is used for building a new devstack server image. It does not typically need to be run.
In the past other alternative setups were working including running mini-mon in HP Public Cloud and scripts for putting it on baremetal. These are no
longer supported.

6
Vagrantfile vendored
View File

@ -25,20 +25,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# One vm just for devstack (to access the UI)
config.vm.define "devstack" do |ds|
ds.vm.hostname = "devstack"
ds.vm.box = "cyrusbio/devstack"
ds.vm.box = "monasca/devstack"
ds.vm.network :private_network, ip: "192.168.10.5"
ds.vm.network :private_network, ip: "10.1.2.44"
ds.vm.provider "virtualbox" do |vb|
vb.memory = 5280
vb.cpus = 4
end
# Upgrade to chef 11, this is only needed because all vms share a bershelf config and though most of the cookbooks are unused
# by devstack it still chokes on ones that don't compile with chef 10
ds.vm.provision "shell", inline: "curl -L https://www.opscode.com/chef/install.sh | bash"
ds.vm.provision :chef_solo do |chef|
chef.roles_path = "roles"
chef.data_bags_path = "data_bags"
chef.add_role "Devstack"
chef.arguments = '--force-formatter'
end
end

View File

@ -1,50 +0,0 @@
#!/usr/bin/env bash
IFS="
"
unpriv_user=$USER
basedir=`dirname $0`
if [ ! -e $basedir/stack-screenrc ]; then
echo "$basedir/stack-screenrc not found. Did you run ./stack.sh?"
exit 1
fi
for line in `cat $basedir/stack-screenrc |tr -d "\r"`; do
if [[ $line == stuff* ]]; then
# Extract the command line to run this service
command=`echo "$line" |sed 's/^stuff //;s/"//g'`
base_command=`echo $command |sed 's:.*bin/::;s/ .*//'`
# Skip screen sessions that are only a tail command
[[ $command == *tail* ]] && continue
# Determine an appropriate log directory
parent=`echo "$command" |cut -d' ' -f2 |sed 's/;//'`
logdir="/var/log/`basename $parent`"
logfile="$base_command.log"
echo "Creating /etc/init/$base_command.conf"
sudo tee "/etc/init/$base_command.conf" >/dev/null <<EOF
description "$base_command server"
author "David Schroeder <david.schroeder@hp.com>"
start on (filesystem and net-device-up IFACE!=lo)
stop on runlevel [016]
pre-start script
mkdir -p $logdir
chown $unpriv_user:root $logdir
end script
respawn
exec su -c "$command --log-dir=$logdir --log-file=$logfile" $unpriv_user
EOF
# Fire up the service
service $base_command restart
fi
done

View File

@ -1,30 +1,3 @@
# Turn a devstack image (https://vagrantcloud.com/cyrusbio/devstack) into
# something useful to mini-mon
admin_token = 'ADMIN'
my_ip = '192.168.10.5'
ks_conf = '/etc/keystone/keystone.conf'
# Modify keystone configuration to...
## ...bind to all IPs
execute "sed -i.bak1 's^\\(.*bind_host = \\).*^\\10.0.0.0^' #{ks_conf}"
# ...set the default admin token
execute "sed -i.bak2 's^\\(admin_token = \\).*^\\1#{admin_token}^' #{ks_conf}"
# ...set endpoints that other mini-mon nodes can use
execute "sed -i.bak3 's^\\(.*endpoint = http://\\).*\\(:.*\\)^\\1#{my_ip}\\2^' #{ks_conf}"
# Regular devstack relies on a user manually running "rejoin-stack.sh" which
# fires up a bunch of screen sessions, one for each process. We don't really
# want that here. Instead autostack.sh will create upstart scripts for each
# devstack process, sendnig its output to real log files under /var/log/.
cookbook_file "autostack.sh" do
mode 0755
owner "vagrant"
path "/home/vagrant/devstack/autostack.sh"
action :create_if_missing
end
execute "/home/vagrant/devstack/autostack.sh"
# As of 2014-07-10, Keystone is no longer run as a daemon, but under Apache.
# Therefore, this recipe, which prepared keystone.conf for mini-mon use,
# is no longer necessary, but left in place in case future tweaks are needed.

View File

@ -15,11 +15,13 @@ execute "ln -sv /usr/local/lib/python2.7/dist-packages/monitoring /opt/stack/hor
execute "ln -sv /usr/local/lib/python2.7/dist-packages/cosmos/overcloud /opt/stack/horizon/openstack_dashboard/dashboards/overcloud"
# install grafana and integrate with horizon
execute "git clone https://github.com/hpcloud-mon/grafana.git /opt/stack/grafana"
execute "cp /opt/stack/grafana/src/config.sample.js /opt/stack/grafana/src/config.js"
execute "mkdir -p /opt/stack/horizon/grafana/static"
execute "touch /opt/stack/horizon/grafana/__init__.py"
execute "ln -sv /opt/stack/grafana/src /opt/stack/horizon/grafana/static/grafana"
if !::File.exists?("/opt/stack/horizon/grafana/static/grafana")
execute "git clone https://github.com/hpcloud-mon/grafana.git /opt/stack/grafana"
execute "cp /opt/stack/grafana/src/config.sample.js /opt/stack/grafana/src/config.js"
execute "mkdir -p /opt/stack/horizon/grafana/static"
execute "touch /opt/stack/horizon/grafana/__init__.py"
execute "ln -sv /opt/stack/grafana/src /opt/stack/horizon/grafana/static/grafana"
end
# Bounce the webserver
service "apache2" do

View File

@ -0,0 +1,29 @@
ds-build cookbook
=========================
Builds a Devstack VM around Ubuntu Trusty
This box is used by the Monasca OpenStack monitoring platform.
Based on Ubuntu 14.04 LTS (Trusty Tahr), the box includes
DevStack with the following services enabled:
- Ceilometer
- Cinder
- Glance
- Heat
- Horizon
- Keystone
- Neutron
- Nova
- Swift
Additionally, rather than running in screen sessions, all services are started
on boot using Upstart scripts, with logging in appropriate directories under
`/var/log/`.
Requirements
------------
Recipes
---------
- default - Installs devstack from source, creates upstart scripts

View File

@ -0,0 +1,105 @@
#!/usr/bin/env bash
# Change Internal Field Separator to split on newlines only
IFS="
"
unpriv_user=$1
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
log='/opt/stack/logs/stack.sh.log'
usage="Usage: autostack.sh [username]
where [username] is an unprivileged user under whom all DevStack
processes will run."
if [ "$UID" != 0 ]; then
echo "Please run this script as root or under sudo so that it can write to"
echo " the /etc/init/ directory and start up the services."
echo
echo "$usage"
exit 1
fi
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then
echo "$usage"
exit 1
fi
cd $basedir
echo "Cloning devstack"
su $unpriv_user -c "git clone https://github.com/openstack-dev/devstack.git || exit 1"
echo "Copying local.conf"
cp $basedir/local.conf $basedir/devstack
# Kick off stack.sh in the background
echo "Running stack.sh (this will take a while, output in $log)"
su $unpriv_user -c $basedir/devstack/stack.sh 2>&1 &
# Wait for stack.sh to complete by watching the log file for $donestring
donestring='This is your host ip'
while [ `tail -1 $log 2>/dev/null |grep -c "$donestring"` = 0 ]; do
sleep 5
done
# Kill off the now-idle stack.sh process
pkill -f devstack/stack.sh
if [ ! -e $basedir/devstack/stack-screenrc ]; then
echo "$basedir/devstack/stack-screenrc not found. Did stack.sh fail?"
exit 1
fi
for line in `cat $basedir/devstack/stack-screenrc |tr -d "\r"`; do
if [[ $line == stuff* ]]; then
echo
# Extract the command line to run this service
command=`echo "$line" |sed 's/^stuff //;s/"//g'`
base_command=`echo $command |sed 's:.*bin/::;s/ .*//'`
# Skip screen sessions that are only a tail command
[[ $command == *tail* ]] && continue
# Ceilometer's stack-screenrc invocation differs from all the others
if [ `echo "$command" |grep -c ceilometer` = 1 ]; then
base_command=`echo $command |sed "s/cd ; //;s/ libvirtd '//;s/ .*//"`
parent='/opt/stack/ceilometer'
else
# Determine an appropriate log directory
parent=`echo "$command" |cut -d' ' -f2 |sed 's/;//'`
fi
logdir="/var/log/`basename $parent`"
logfile="$base_command.log"
echo "Creating /etc/init/$base_command.conf"
cat > "/etc/init/$base_command.conf" <<EOF
description "$base_command server"
start on (filesystem and net-device-up IFACE!=lo)
stop on runlevel [016]
pre-start script
mkdir -p $logdir
chown $unpriv_user:root $logdir
end script
respawn
exec su -c "$command --log-dir=$logdir --log-file=$logfile" $unpriv_user
EOF
# Swift processes do not support logfiles, so modify the init script
if [ `echo "$command" |grep -c swift` = 1 ]; then
sed -i 's/--log.*"/"/' /etc/init/$base_command.conf
fi
# Fire up the service
service $base_command restart
fi
done
echo "autostack.sh complete, no errors."
exit 0

View File

@ -0,0 +1,41 @@
[[local|localrc]]
ADMIN_PASSWORD=admin
MYSQL_PASSWORD=pass
RABBIT_PASSWORD=pass
SERVICE_PASSWORD=pass
SERVICE_TOKEN=ADMIN
LOGFILE=$DEST/logs/stack.sh.log
## For Keystone
KEYSTONE_TOKEN_FORMAT=UUID
#KEYSTONE_AUTH_HOST=0.0.0.0
#KEYSTONE_SERVICE_HOST=0.0.0.0
#KEYSTONE_ADMIN_BIND_HOST=0.0.0.0
# Enable the swift services
enable_service s-proxy s-object s-container s-account s-api
## For Swift
SWIFT_REPLICAS=1
SWIFT_HASH=011688b44136573e209e
# Ceilometer
# Enable the ceilometer metering services
enable_service ceilometer-acompute ceilometer-acentral ceilometer-anotification ceilometer-collector
# Enable the ceilometer alarming services
enable_service ceilometer-alarm-evaluator ceilometer-alarm-notifier
# Enable the ceilometer api services
enable_service ceilometer-api
# Neutron
Q_PLUGIN=linuxbridge
disable_service n-net
enable_service neutron q-svc q-agt q-dhcp q-l3 q-meta
enable_service q-fwaas q-vpn q-metering
# Glance
enable_service g-api g-reg

View File

@ -0,0 +1,8 @@
name "ds-build"
maintainer "Mon Team"
maintainer_email "hpcs-mon@hp.com"
license "All rights reserved"
description "Build customized devstack server"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.1"
depends "apt"

View File

@ -0,0 +1,37 @@
# Create a devstack image (https://vagrantcloud.com/monasca/devstack)
# from the latest devstack source
# Install git
package 'git' do
action :install
end
# Remove apt proxy (populated by default in ubuntu/trusty64)
file "/etc/apt/apt.conf.d/01proxy" do
action :delete
end
# Load up devstack configuration and installer script
cookbook_file "local.conf" do
mode 0755
owner "vagrant"
path "/home/vagrant/local.conf"
action :create_if_missing
end
cookbook_file "autostack.sh" do
mode 0755
owner "vagrant"
path "/home/vagrant/autostack.sh"
action :create_if_missing
end
# Install devstack if it hasn't been installed yet
if !::File.exists?("/home/vagrant/devstack/stack-screenrc")
log "Please wait while devstack is installed. This WILL take a while." do
level :info
end
execute "/home/vagrant/autostack.sh vagrant"
end

45
ds-build/README.md Normal file
View File

@ -0,0 +1,45 @@
The ds-build Vagrant profile installs the latest DevStack onto an Ubuntu
Trusty virtual machine, activating extra services and setting it up to
run out of Upstart rather than screen sessions.
Default admin credentials are username `admin` and password `admin`.
# Services Enabled
The following services are enabled:
- Ceilometer
- Cinder
- Glance
- Heat
- Horizon
- Keystone
- Neutron
- Nova
- Swift
Note that with Neutron, `Q_PLUGIN` is set to linuxbridge rather than
openvswitch.
# Upstart instead of screen
The cookbook includes a script which creates Upstart init scripts for each of
the services. It also sets up log files in the `/var/log/` directory. When
the VM is booted, all DevStack processes will start automatically.
# Usage
## Initial build
From within this directory, run this command to build the server:
`vagrant up`
The DevStack installation will take a long time, and you can follow its
progress from another terminal by running `vagrant ssh` and then
`tail -f /opt/stack/logs/stack.sh.log`
## Packaging for VagrantCloud
From within the `ds-build` directory, run this command to build a new
VagrantCloud box image after `vagrant up` completed successfully:
```
box='devstack.box'; [ -e ../$box ] && rm -v ../$box ; vagrant package devstack --output $box
```

42
ds-build/Vagrantfile vendored Normal file
View File

@ -0,0 +1,42 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Set working dir to root of repo
Dir.chdir ".."
VAGRANTFILE_API_VERSION = "2" # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Settings for all vms
config.berkshelf.enabled = true
# Handle local proxy settings
if Vagrant.has_plugin?("vagrant-proxyconf")
if ENV["http_proxy"]
config.proxy.http = ENV["http_proxy"]
end
if ENV["https_proxy"]
config.proxy.https = ENV["https_proxy"]
end
if ENV["no_proxy"]
config.proxy.no_proxy = ENV["no_proxy"]
end
end
config.vm.define "devstack" do |ds|
ds.vm.hostname = "devstack"
ds.vm.box = "ubuntu/trusty64"
ds.vm.network :private_network, ip: "192.168.10.5"
ds.vm.provider "virtualbox" do |vb|
vb.memory = 5280
vb.cpus = 4
end
ds.vm.provision :chef_solo do |chef|
chef.roles_path = "roles"
chef.add_role "Devstack-Build"
chef.arguments = '--force-formatter'
end
end
end

View File

@ -0,0 +1,19 @@
{
"name": "Devstack-Build",
"description": "Builds up a devstack server with all available services running",
"json_class": "Chef::Role",
"default_attributes": {
"apt": {
"periodic_update_min_delay": 60
}
},
"override_attributes": {
},
"chef_type": "role",
"run_list": [
"recipe[mini-mon]",
"recipe[ds-build]"
],
"env_run_lists": {
}
}

View File

@ -11,6 +11,9 @@ monitoring system can scale but also is useful for some development scenarios.
- `thresh` at `192.168.10.14`
- `vertica` at `192.168.10.8`
- The management console is at https://192.168.10.8:5450
- `devstack` at `192.168.10.5`
- The web interface is at http://192.168.0.5
- username `admin`, password `admin`
- Run `vagrant help` for more info
- Run `vagrant ssh <vm name>` to login to a particular vm
- Can also run `ssh vagrant@<ip address>` to login

35
split/Vagrantfile vendored
View File

@ -40,6 +40,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
config.vm.define "devstack" do |devstack|
devstack.vm.hostname = 'devstack'
devstack.vm.box = "monasca/devstack"
devstack.vm.network :private_network, ip: "192.168.10.5"
devstack.vm.provider "virtualbox" do |vb|
vb.memory = 5280
vb.cpus = 4
end
devstack.vm.provision :chef_solo do |chef|
chef.roles_path = "roles"
chef.data_bags_path = "data_bags"
chef.add_role "Devstack"
chef.arguments = '--force-formatter'
end
end
config.vm.define "kafka" do |kafka|
kafka.vm.hostname = 'kafka'
kafka.vm.box = "kuhlmant/precise64_chef11"
@ -79,25 +95,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
config.vm.define "devstack" do |devstack|
devstack.vm.hostname = 'devstack'
devstack.vm.box = "cyrusbio/devstack"
devstack.vm.network :private_network, ip: "192.168.10.5"
devstack.vm.network :private_network, ip: "10.1.2.44"
devstack.vm.provider "virtualbox" do |vb|
vb.memory = 5280
vb.cpus = 4
end
# Upgrade to chef 11, this is only needed because all vms share a bershelf config and though most of the cookbooks are unused
# by devstack it still chokes on ones that don't compile with chef 10
ds.vm.provision "shell", inline: "curl -L https://www.opscode.com/chef/install.sh | bash"
devstack.vm.provision :chef_solo do |chef|
chef.roles_path = "roles"
chef.data_bags_path = "data_bags"
chef.add_role "Devstack"
end
end
config.vm.define "persister" do |persister|
persister.vm.hostname = 'persister'
persister.vm.box = "kuhlmant/precise64_chef11"

View File

@ -9,8 +9,7 @@
"chef_type": "role",
"run_list": [
"role[Basenode]",
"recipe[mon_api]",
"recipe[mini-mon::keystone]"
"recipe[mon_api]"
],
"env_run_lists": {
}

View File

@ -13,7 +13,8 @@
"run_list": [
"recipe[devstack]",
"recipe[devstack::mon-ui]",
"recipe[devstack::keystone]"
"recipe[devstack::keystone]",
"recipe[mon_agent]"
],
"env_run_lists": {
}