Added vagrant VM for developer use

This patch adds a vagrantfile and ansible playbook that captures
the instructions from the ironic developer quickstart. By using
'vagrant up', and configuring your local dev instance to use
192.168.99.11, you should be able to exercise your services locally.
Documentation has also been updated.

Change-Id: Ic4f42e59cbda968d301c797ef77ff98030c55c41
This commit is contained in:
Michael Krotscheck 2015-03-24 12:56:50 -07:00
parent 24b8ee4d38
commit ef237e0e5f
4 changed files with 253 additions and 23 deletions

3
.gitignore vendored
View File

@ -32,3 +32,6 @@ AUTHORS
ChangeLog ChangeLog
*.sqlite *.sqlite
*~ *~
# Vagrant
.vagrant

25
Vagrantfile vendored Normal file
View File

@ -0,0 +1,25 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.define 'ironic' do |ironic|
ironic.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id,'--memory', '2048']
end
ironic.vm.network 'private_network', ip: '192.168.99.11' # It goes to 11.
ironic.vm.provision 'ansible' do |ansible|
ansible.verbose = 'v'
ansible.playbook = 'vagrant.yml'
ansible.extra_vars = {
ip: '192.168.99.11'
}
end
end
end

View File

@ -95,6 +95,15 @@ virtual environment, you can do this without starting any other OpenStack
services. For example, this is useful for rapidly prototyping and debugging services. For example, this is useful for rapidly prototyping and debugging
interactions over the RPC channel, testing database migrations, and so forth. interactions over the RPC channel, testing database migrations, and so forth.
Step 1: System Dependencies
---------------------------
There are two ways you may use to install the required system dependencies:
Manually, or by using the included Vagrant file.
Option 1: Manual Install
########################
#. Install a few system prerequisites:: #. Install a few system prerequisites::
# install rabbit message broker # install rabbit message broker
@ -122,23 +131,6 @@ interactions over the RPC channel, testing database migrations, and so forth.
# sudo zypper install mariadb # sudo zypper install mariadb
# sudo systemctl start mysql.service # sudo systemctl start mysql.service
#. Clone the ``python-ironicclient`` repository and install it within
a virtualenv::
# from your home or source directory
cd ~
git clone https://git.openstack.org/openstack/python-ironicclient
cd python-ironicclient
tox -evenv -- echo 'done'
source .tox/venv/bin/activate
python setup.py develop
#. Export some ENV vars so the client will connect to the local services
that you'll start in the next section::
export OS_AUTH_TOKEN=fake-token
export IRONIC_URL=http://localhost:6385/
#. Clone the ``Ironic`` repository and install it within a virtualenv:: #. Clone the ``Ironic`` repository and install it within a virtualenv::
# activate the virtualenv # activate the virtualenv
@ -151,6 +143,8 @@ interactions over the RPC channel, testing database migrations, and so forth.
# install ironic within the virtualenv # install ironic within the virtualenv
python setup.py develop python setup.py develop
#. Create a configuration file within the ironic source directory::
# copy sample config and modify it as necessary # copy sample config and modify it as necessary
cp etc/ironic/ironic.conf.sample etc/ironic/ironic.conf.local cp etc/ironic/ironic.conf.sample etc/ironic/ironic.conf.local
@ -166,14 +160,51 @@ interactions over the RPC channel, testing database migrations, and so forth.
# turn off the periodic sync_power_state task, to avoid getting NodeLocked exceptions # turn off the periodic sync_power_state task, to avoid getting NodeLocked exceptions
sed -i "s/#sync_power_state_interval=60/sync_power_state_interval=-1/" etc/ironic/ironic.conf.local sed -i "s/#sync_power_state_interval=60/sync_power_state_interval=-1/" etc/ironic/ironic.conf.local
# initialize the ironic database #. Initialize the ironic database (optional)
# this defaults to storing data in ./ironic/ironic.sqlite
# ironic defaults to storing data in ./ironic/ironic.sqlite
# If using MySQL, you need to create the initial database # If using MySQL, you need to create the initial database
# mysql -u root -e "create schema ironic" # mysql -u root -e "create schema ironic"
# and switch the DB connection from sqlite to something else, eg. mysql # and switch the DB connection from sqlite to something else, eg. mysql
# sed -i "s/#connection=.*/connection=mysql:\/\/root@localhost\/ironic/" etc/ironic/ironic.conf.local # sed -i "s/#connection=.*/connection=mysql:\/\/root@localhost\/ironic/" etc/ironic/ironic.conf.local
At this point, you can continue to Step 2.
Option 2: Vagrant, VirtualBox, and Ansible
##########################################
This option requires `virtualbox <https://www.virtualbox.org//>`_,
`vagrant <http://www.vagrantup.com/downloads>`_, and
`ansible <http://www.ansible.com/home>`_. You may install these using your
favorite package manager, or by downloading from the provided links.
Next, run vagrant::
vagrant up
This will create a VM available to your local system at `192.168.99.11`,
will install all the necessary service dependencies,
and configure some default users. It will also generate
`./etc/ironic/ironic.conf.local` preconfigured for local dev work.
We recommend you compare and familiarize yourself with the settings in
`./etc/ironic/ironic.conf.sample` so you can adjust it to meet your own needs.
Step 2: Start the API
---------------------
Activate the virtual environment created in the previous section to run
the API::
# switch to the ironic source (Not necessary if you followed Option 1)
cd ironic
# activate the virtualenv
source .tox/venv/bin/activate
# install ironic within the virtualenv
python setup.py develop
# This creates the database tables. # This creates the database tables.
ironic-dbsync --config-file etc/ironic/ironic.conf.local create_schema ironic-dbsync --config-file etc/ironic/ironic.conf.local create_schema
@ -185,6 +216,31 @@ interactions over the RPC channel, testing database migrations, and so forth.
#. Open one more window (or screen session), again activate the venv, and then #. Open one more window (or screen session), again activate the venv, and then
start the conductor service and watch its output:: start the conductor service and watch its output::
Step 3: Install the Client
--------------------------
#. Clone the ``python-ironicclient`` repository and install it within a
virtualenv::
# from your home or source directory
cd ~
git clone https://git.openstack.org/openstack/python-ironicclient
cd python-ironicclient
tox -evenv -- echo 'done'
source .tox/venv/bin/activate
python setup.py develop
#. Export some ENV vars so the client will connect to the local services
that you'll start in the next section::
export OS_AUTH_TOKEN=fake-token
export IRONIC_URL=http://localhost:6385/
Step 4: Start the Conductor Service
-----------------------------------
Open one more window (or screen session), again activate the venv, and then
start the conductor service and watch its output::
# activate the virtualenv # activate the virtualenv
cd ironic cd ironic
source .tox/venv/bin/activate source .tox/venv/bin/activate
@ -192,10 +248,10 @@ interactions over the RPC channel, testing database migrations, and so forth.
# start the conductor service # start the conductor service
ironic-conductor -v -d --config-file etc/ironic/ironic.conf.local ironic-conductor -v -d --config-file etc/ironic/ironic.conf.local
You should now be able to interact with Ironic via the python client You should now be able to interact with Ironic via the python client (installed
(installed in the first window) and observe both services' debug outputs in Step 3) and observe both services' debug outputs in the other two
in the other two windows. This is a good way to test new features or windows. This is a good way to test new features or play with the functionality
play with the functionality without necessarily starting DevStack. without necessarily starting DevStack.
To get started, list the available commands and resources:: To get started, list the available commands and resources::

146
vagrant.yml Normal file
View File

@ -0,0 +1,146 @@
---
###############################################################################
# This ansible playbook installs all supporting software necessary to run the
# ironic service locally into the vagrant VM attached. Its intent is to provide
# a quickstart development environment that doesn't pollute an engineer's own
# machine.
#
# The vagrant vm's IP address is assumed to be 192.168.99.11
#
# http://docs.openstack.org/developer/ironic/dev/dev-quickstart.html#exercising-the-services-locally
#
- hosts: ironic
sudo: yes
tasks:
############################################################################
# APT Updates
############################################################################
# Make sure our VM's software is ~@Latest
- name: Apt Update
apt: update_cache=yes
upgrade=dist
cache_valid_time=86400
# Reboot if required.
- name: Reboot system if required
command: shutdown -r now 'Rebooting to complete system upgrade'
removes=/var/run/reboot-required
register: rebooted
- name: Wait for VM Reboot.
sudo: no
local_action: wait_for
port=22
host="{{ip}}"
search_regex=OpenSSH
delay=10
timeout=900
when: rebooted.changed
############################################################################
# Install all the needed packages in one go.
############################################################################
- name: Install Required Packages
apt: name={{item}}
state=present
with_items:
- rabbitmq-server
- python-mysqldb
- mysql-server
- mysql-client
############################################################################
# Configure rabbitmq.
############################################################################
- name: Ensure rabbitmq is running
service: name=rabbitmq-server
state=started
enabled=yes
- name: Add ironic RabbitMQ user
rabbitmq_user: user=ironic
password=ironic
vhost=/
configure_priv=.*
read_priv=.*
write_priv=.*
state=present
############################################################################
# Configure mysql.
############################################################################
- name: Configure MySQL
lineinfile: dest=/etc/mysql/my.cnf
line="bind-address={{ip}}"
regexp="^bind\-address"
notify: Restart MySQL
- name: Create MySQL Database
mysql_db: name=ironic state=present
- name: Create ironic MySQL user
mysql_user: name=ironic
password=ironic
host={{item}}
priv=ironic.*:ALL
state=present
with_items:
- localhost
- "%"
- name: Ensure mysql is running
service: name=mysql
state=started
enabled=yes
############################################################################
# Create ironic.conf.local configuration.
############################################################################
- name: Update local configuration with vagrant parameters.
sudo: no
local_action: ini_file dest=etc/ironic/ironic.conf.local
section="{{item.section}}"
option="{{item.option}}"
value="{{item.value}}"
with_items:
- {
section: 'glance',
option: 'auth_strategy', value: 'noauth'
}
- {
section: 'neutron',
option: 'auth_strategy', value: 'noauth'
}
- {
section: 'database',
option: 'connection', value: "mysql://ironic:ironic@{{ip}}/ironic"
}
- {
section: 'DEFAULT',
option: 'auth_strategy', value: 'noauth'
}
- {
section: 'DEFAULT',
option: 'enabled_drivers', value: 'fake_ipmitool'
}
- {
section: 'DEFAULT',
option: 'pecan_debug', value: 'true'
}
- {
section: 'oslo_messaging_rabbit',
option: 'rabbit_host', value: "{{ip}}"
}
- {
section: 'oslo_messaging_rabbit',
option: 'rabbit_userid', value: "ironic"
}
- {
section: 'oslo_messaging_rabbit',
option: 'rabbit_password', value: "ironic"
}
#############################################################################
# Handlers
#############################################################################
handlers:
- name: Restart MySQL
service: name=mysql
state=restarted
enabled=yes