diff --git a/README.vagrant b/README.vagrant new file mode 100644 index 000000000..0dc556c36 --- /dev/null +++ b/README.vagrant @@ -0,0 +1,36 @@ +Vagrant support for developers +============================== +Bifrost vagrant file for developers can be found in the tools/vagrant_dev_env +directory. Running 'vagrant up' from with in this folder will bring up an Ubuntu +Trusty box with bifrost installed. + +By default the vm will have three interfaces: + eth0 - connected to a NAT network + eth1 - connected to Host-only network named: vboxnet1 + eth2 - bridged - adapter must be set in Vagrantfile + + +Walkthrough done on OS X: +------------------------- +Setup vagrant by: + Installing git + Installing virtualbox + Installing vagrant + Installing ansible + +Configure Vagrant with the correct box: + vagrant box add ubuntu/trusty64 + +Clone bifrost repo: + git clone https://github.com/openstack/bifrost.git + +change in to the bifrost directory + cd bifrost/tools/vagrant_dev_env + +edit Vagrantfile: + change public_key to correct key name + change network_interface to match your needs + change bridged adaptor + +Boot the vm with: + vagrant up diff --git a/doc/source/Vagrant.rst b/doc/source/Vagrant.rst new file mode 100644 index 000000000..832284f99 --- /dev/null +++ b/doc/source/Vagrant.rst @@ -0,0 +1 @@ +.. include:: ../../README.vagrant diff --git a/doc/source/index.rst b/doc/source/index.rst index dff0cd849..6c670f8b0 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -8,6 +8,7 @@ Contents: readme contributing + Vagrant Indices and tables ================== diff --git a/tools/vagrant_dev_env/Vagrantfile b/tools/vagrant_dev_env/Vagrantfile new file mode 100644 index 000000000..d4587102e --- /dev/null +++ b/tools/vagrant_dev_env/Vagrantfile @@ -0,0 +1,47 @@ +# -*- 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 'bifrost' do |bifrost| + bifrost.vm.provider :virtualbox do |vb| + vb.customize ['modifyvm', :id, '--memory', '4096', '--cpus', '1', '--cpuexecutioncap', '80'] + # the setting below are to improve performance on mac's and should have little impact elsewhere. + vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + vb.customize ["modifyvm", :id, "--nictype1", "Am79C973"] + vb.customize ["modifyvm", :id, "--nictype2", "Am79C973"] + vb.customize ["modifyvm", :id, "--nictype3", "Am79C973"] + end + + # Set up private NAT'd network + bifrost.vm.network 'private_network', ip: '192.168.99.10' # it goes to 11 + # This assumes you have DHCP on your bridged network. if not you will need + # to statically configure to allow Bifrost to manage hardware attached to + # the bridged interface. + # NOTE(TheJulia): Is there a way to abstract the bridged networking... + # NOTE(NobodyCam): until the above is done this needs to be set to a valid interface + bifrost.vm.network 'public_network', bridge: '' + + # besure we get the entire bifrost directory tree + bifrost.vm.synced_folder "../../.", "/home/vagrant/bifrost", type: "rsync" + + bifrost.vm.provision 'ansible' do |ansible| + ansible.verbose = 'v' + ansible.playbook = 'vagrant.yml' + ansible.extra_vars = { + # set key file name here + public_key: 'id_rsa.pub', + # Edit the network_interface to match your needs: + # eth0 - connected to a Nat network + # eth1 - connected to Host-only network named: 'vboxnet1' + # eth2 - bridged - Interface must also be set above + network_interface: 'eth2' + } + end + end +end diff --git a/tools/vagrant_dev_env/vagrant.yml b/tools/vagrant_dev_env/vagrant.yml new file mode 100644 index 000000000..503a9e425 --- /dev/null +++ b/tools/vagrant_dev_env/vagrant.yml @@ -0,0 +1,75 @@ +--- +############################################################################### +# +# +- hosts: bifrost + sudo: yes + tasks: + ############################################################################ + # Install some reqired bits into the vm + ############################################################################ + # Make sure our VM's software is ~@Latest + - name: Apt Update + apt: update_cache=yes + upgrade=dist + cache_valid_time=86400 + when: ansible_distribution == 'Ubuntu' + + - name: Install easy_install + apt: name=python-setuptools state=present + when: ansible_distribution == 'Ubuntu' + + - name: Install python-dev + apt: name=python-dev state=present + when: ansible_distribution == 'Ubuntu' + + # these would also be installed by 'Prepare VM for Bifrost' + # below As they are larger packages I think its worth installing + # them on their own. + - name: Install erlang-base + apt: name=erlang-base state=present + when: ansible_distribution == 'Ubuntu' + + - name: Install Rabbit-Server + apt: name=rabbitmq-server state=present + when: ansible_distribution == 'Ubuntu' + + - name: Install MySql-Server + apt: name=mysql-server state=present + when: ansible_distribution == 'Ubuntu' + + # get ip for public_network + - name: Get ip + shell: ip addr show eth2 | grep inet | grep -v inet6 | awk '{print $2}' | cut -d/ -f1 + register: guest_ip + + # 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="{{guest_ip.stdout}}" + search_regex=OpenSSH + delay=10 + timeout=900 + when: rebooted.changed + + - name: Copy SSH public key into VM + copy: src=~/.ssh/{{public_key}} dest=~/.ssh/id_rsa.pub + + - name: Ensure /opt/stack folder exists + file: path=/opt/stack state=directory owner=vagrant + + - name: Prepare VM for Bifrost + command: /home/vagrant/bifrost/scripts/env-setup.sh + + - name: Install Bifrost + shell: source /opt/stack/ansible/hacking/env-setup && ansible-playbook -vvvv -i inventory/localhost install.yaml -e network_interface={{network_interface}} + args: + chdir: /home/vagrant/bifrost/playbooks + executable: /bin/bash +