Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Vagrant support #667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ metadata.json
.chef
.swp
cookbooks.tgz
Berksfile
Berksfile.lock
openrc
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ Ensure you have [registered](http://wiki.opscode.com/display/chef/Cookbook+Fast+
`...`
`knife node run_list add nodeN 'role[single-compute]'`

## Testing ###

#### Vagrant ####

Requirements:

* Vagrant >= 1.3.0 - http://downloads.vagrantup.com/
* VirtualBox - https://www.virtualbox.org/wiki/Downloads
* Vagrant Plugins

vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-chef-zero
vagrant plugin install vagrant-berkshelf

* rcbops repo

git clone --recursive [email protected]:rcbops/chef-cookbooks.git

* Launch

vagrant up ubuntu1204

* Test

source openrc
nova boot --image cirros-image --flavor 1 Test
nova list
ping 192.168.1.2

Things you should know about

* Chef Environment - `environments/vagrant_allinone.json`
* Berkshelf - Vagrant will create a berkshelf file based on the contents of `.gitmodules` and `cookbooks`


## Custom template banners ##

Expand Down
87 changes: 87 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# make me a Berksfile from hints in .gitsubmodule
if ! File.exist?('Berksfile') or ENV['NEWBERKS']
puts "looks like you need a Berksfile ... Generating one now."
Berksfile = []
File.open(".gitmodules", "r").each_line do |line|
if match = /submodule "(.*?)\/(.*?)"/.match(line) and File.exist?("#{match[1]}/#{match[2]}")
Berksfile << "cookbook '#{match[2]}', path: '#{match[1]}/#{match[2]}'"
end
end
File.open("Berksfile", 'w') { |file| file.write(Berksfile.join("\n")) }
end

Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.require_plugin "vagrant-chef-zero"
Vagrant.require_plugin "vagrant-omnibus"

Vagrant.configure("2") do |config|
# Berkshelf plugin configuration
config.berkshelf.enabled = true

# Chef-Zero plugin configuration
config.chef_zero.enabled = true
config.chef_zero.chef_repo_path = "."

# Omnibus plugin configuration
config.omnibus.chef_version = :latest

# Port forwarding rules, for access to openstack services
config.vm.network "forwarded_port", guest: 443, host: 8443 # dashboard-ssl
config.vm.network "forwarded_port", guest: 4000, host: 4000 # chef-zero
config.vm.network "forwarded_port", guest: 8773, host: 8773 # compute-ec2-api
config.vm.network "forwarded_port", guest: 8774, host: 8774 # compute-api

# OpenStack-related settings
config.vm.network "private_network", ip: "192.168.100.60"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cpus", 2]
vb.customize ["modifyvm", :id, "--memory", 2048]
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end

# Ubuntu 12.04 Config
config.vm.define :ubuntu1204 do |ubuntu1204|
ubuntu1204.vm.hostname = "openstack"
ubuntu1204.vm.box = "opscode-ubuntu-12.04"
ubuntu1204.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
ubuntu1204.vm.provision :chef_client do |chef|
chef.environment = "vagrant-allinone"
chef.run_list = [ "recipe[apt::cacher-client]", "role[allinone]" ]
end
ubuntu1204.vm.provision :shell, :inline => <<-SCRIPT
cp /root/openrc /vagrant/openrc
chown vagrant /vagrant/openrc
SCRIPT
end

# Ubuntu 13.04 Config
config.vm.define :ubuntu1304 do |ubuntu1304|
ubuntu1304.vm.hostname = "openstack"
ubuntu1304.vm.box = "opscode-ubuntu-13.04"
ubuntu1304.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box"
ubuntu1304.vm.provision :chef_client do |chef|
chef.environment = "vagrant-allinone"
chef.run_list = [ "recipe[apt::cacher-client]", "role[allinone]" ]
end
ubuntu1304.vm.provision :shell, :inline => <<-SCRIPT
cp /root/openrc /vagrant/openrc
chown vagrant /vagrant/openrc
SCRIPT
end

# Centos 6.4 Config
config.vm.define :centos64 do |centos64|
centos64.vm.hostname = "openstack"
centos64.vm.box = "opscode-centos-6.4"
centos64.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box"
centos64.vm.provision :chef_client do |chef|
chef.environment = "vagrant-allinone"
chef.run_list = [ "role[allinone]" ]
end
centos64.vm.provision :shell, :inline => <<-SCRIPT
cp /root/openrc /vagrant/openrc
chown vagrant /vagrant/openrc
SCRIPT
end

end
49 changes: 49 additions & 0 deletions environments/vagrant_allinone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "vagrant-allinone",
"description": "Chef-server example environment",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
"developer_mode": false,
"enable_testing_repos": false,
"monitoring" : {
"metric_provider" : "collectd",
"procmon_provider" : "monit"
},
"glance": {
"image_upload": true,
"images": ["cirros"]
},
"nova": {
"ratelimit" : {
"api" : { "enabled" : true },
"volume" : { "enabled" : true }
},
"libvirt": { "virt_type": "qemu" },
"networks": {
"public": {
"label": "public",
"ipv4_cidr": "192.168.100.0/24",
"bridge": "br100",
"bridge_dev": "eth1",
"dns1": "8.8.8.8",
"dns2": "8.8.4.4"
}
}
},
"mysql": {
"allow_remote_root": true,
"root_network_acl": "%"
},
"osops_networks": {
"nova": "192.168.100.0/24",
"public": "192.168.100.0/24",
"management": "192.168.100.0/24"
},
"package_component": "havana"
}
}