Skip to content

Instantly share code, notes, and snippets.

@jtopjian
Created January 16, 2014 08:50
Show Gist options
  • Save jtopjian/8451744 to your computer and use it in GitHub Desktop.
Save jtopjian/8451744 to your computer and use it in GitHub Desktop.
Personal Vagrantfile
require 'vagrant-openstack-plugin'
# Specify a list of possible server names
servers = [
'puppet', 'jenkins', 'builder',
'cloud', 'c01',
'swift', 's01', 's02',
'mysql', 'mysql-01', 'mysql-02', 'mysql-03',
]
# The domain to create the FQDN
domain = 'example.com'
Vagrant.configure("2") do |config|
# "dummy" box because we're using Glance
config.vm.box = "dummy"
# SSH
config.ssh.private_key_path = "~/.ssh/id_rsa"
# Basic OpenStack options
# Note that an openrc file needs sourced before using
config.vm.provider :openstack do |os|
os.username = ENV['OS_USERNAME']
os.api_key = ENV['OS_PASSWORD']
os.flavor = /n1.medium/
os.image = '4042220e-4f5e-4398-9054-39fbd75a5dd7'
os.endpoint = "#{ENV['OS_AUTH_URL']}/tokens"
os.keypair_name = "home"
os.ssh_username = "ubuntu"
os.security_groups = ['default', 'openstack']
end
# Loop through each server and define it
servers.each do |server|
fqdn = "#{server}.#{domain}"
config.vm.define fqdn do |vm|
# If there is a special bootstrap file for a server, use it
# If not, use a generic bootstrap script
if File.exists?("bootstraps/#{server}-bootstrap.sh")
shell_script = "bootstraps/#{server}-bootstrap.sh"
else
shell_script = 'bootstraps/bootstrap.sh'
end
# Special options for cloud.z.terrarum.net
if fqdn =~ /cloud/
vm.vm.provider :openstack do |os|
os.flavor = /n1.small/
end
end
# Special options for mysql-named vms
if fqdn =~ /mysql/
shell_script = "bootstraps/mysql-bootstrap.sh"
vm.vm.provider :openstack do |os|
os.flavor = /n1.small/
end
end
if fqdn =~ /s[0-9]+/
shell_script = "bootstraps/swift-bootstrap.sh"
vm.vm.provider :openstack do |os|
os.flavor = /n1.large/
end
end
if fqdn =~ /swift/
shell_script = "bootstraps/swift-bootstrap.sh"
vm.vm.provider :openstack do |os|
os.flavor = /n1.small/
end
end
config.vm.provision 'shell', path: shell_script
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment