diff --git a/Berksfile b/Berksfile index 16c42c1..7a51ba9 100644 --- a/Berksfile +++ b/Berksfile @@ -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' diff --git a/README.md b/README.md index 4f989c5..3016d9f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Vagrantfile b/Vagrantfile index 3564826..c3a1492 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/cookbooks/devstack/files/default/autostack.sh b/cookbooks/devstack/files/default/autostack.sh deleted file mode 100755 index 246df2a..0000000 --- a/cookbooks/devstack/files/default/autostack.sh +++ /dev/null @@ -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 <" - -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 diff --git a/cookbooks/devstack/recipes/default.rb b/cookbooks/devstack/recipes/default.rb index 1664f7e..b311b5a 100644 --- a/cookbooks/devstack/recipes/default.rb +++ b/cookbooks/devstack/recipes/default.rb @@ -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. diff --git a/cookbooks/devstack/recipes/mon-ui.rb b/cookbooks/devstack/recipes/mon-ui.rb index 041fbed..3373d97 100644 --- a/cookbooks/devstack/recipes/mon-ui.rb +++ b/cookbooks/devstack/recipes/mon-ui.rb @@ -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 diff --git a/cookbooks/ds-build/README.md b/cookbooks/ds-build/README.md new file mode 100644 index 0000000..8c5b9dc --- /dev/null +++ b/cookbooks/ds-build/README.md @@ -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 diff --git a/cookbooks/ds-build/files/default/autostack.sh b/cookbooks/ds-build/files/default/autostack.sh new file mode 100755 index 0000000..7cf99ad --- /dev/null +++ b/cookbooks/ds-build/files/default/autostack.sh @@ -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" <` to login to a particular vm - Can also run `ssh vagrant@` to login diff --git a/split/Vagrantfile b/split/Vagrantfile index 3ecab4a..a84a375 100644 --- a/split/Vagrantfile +++ b/split/Vagrantfile @@ -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" diff --git a/split/roles/Api.json b/split/roles/Api.json index f8b8b54..2aa6ea0 100644 --- a/split/roles/Api.json +++ b/split/roles/Api.json @@ -9,8 +9,7 @@ "chef_type": "role", "run_list": [ "role[Basenode]", - "recipe[mon_api]", - "recipe[mini-mon::keystone]" + "recipe[mon_api]" ], "env_run_lists": { } diff --git a/split/roles/Devstack.json b/split/roles/Devstack.json index 12f3ddc..118ca51 100644 --- a/split/roles/Devstack.json +++ b/split/roles/Devstack.json @@ -13,7 +13,8 @@ "run_list": [ "recipe[devstack]", "recipe[devstack::mon-ui]", - "recipe[devstack::keystone]" + "recipe[devstack::keystone]", + "recipe[mon_agent]" ], "env_run_lists": { }