mirror of https://github.com/apache/cloudstack.git
138 lines
4.7 KiB
Ruby
138 lines
4.7 KiB
Ruby
#-*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
include RbConfig
|
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
ISOUTIL=''
|
|
|
|
VPC_NAME="r-" + ENV['VPC_IP'].split('.').last + "-VM"
|
|
if ARGV[0] == 'up'
|
|
unless ENV['VPC_IP']
|
|
puts "\nPlease specify the VPC IP by settings the VPC_IP environment variable"
|
|
puts "Example: export VPC_IP=192.168.56.30"
|
|
puts ""
|
|
exit 1
|
|
end
|
|
|
|
|
|
case CONFIG['host_os']
|
|
when /mswin|windows/i
|
|
puts "Windows is not supported"
|
|
exit 1
|
|
when /linux|arch/i
|
|
ISOUTIL="mkisofs -J -o systemvm.iso ./iso"
|
|
when /sunos|solaris/i
|
|
puts "Solaris is not supported"
|
|
exit 1
|
|
when /darwin/i
|
|
ISOUTIL='hdiutil makehybrid -iso -joliet -o systemvm.iso ./iso/'
|
|
else
|
|
puts "This OS is not supported"
|
|
exit 1
|
|
end
|
|
|
|
puts "\nSetting the vagrant-key inside authorized_keys"
|
|
system 'rm -rf ./systemvm.iso'
|
|
system 'cp ../../../systemvm/dist/cloud-scripts.tgz iso/'
|
|
system 'cp ../../../systemvm/dist/systemvm.zip iso/'
|
|
|
|
system 'cat vagrant.pub > iso/authorized_keys'
|
|
system 'chmod 600 iso/authorized_keys'
|
|
|
|
puts "\nCreating the systemvm.iso file."
|
|
|
|
system ISOUTIL
|
|
end
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
|
|
config.vm.box = "cloudstack/systemvm"
|
|
config.vm.network "private_network", ip: ENV['VPC_IP'], auto_config: false
|
|
config.vm.synced_folder "vagrant", "/vagrant", disabled: true
|
|
|
|
config.ssh.forward_agent = true
|
|
config.ssh.username = "root"
|
|
config.ssh.host = ENV['VPC_IP']
|
|
config.ssh.port = 3922
|
|
config.ssh.guest_port = 3922
|
|
|
|
config.vm.provider "virtualbox" do |vb|
|
|
# enable or disable headless mode
|
|
vb.gui = true
|
|
vb.customize ["modifyvm", :id, "--memory", "256"]
|
|
vb.customize ["storagectl", :id, "--name", "IDE Controller", "--remove"]
|
|
vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", "1", "--type", "dvddrive", "--medium", "./systemvm.iso"]
|
|
vb.customize('pre-boot', ['modifyvm', :id, "--nic1", "none"])
|
|
vb.customize('pre-boot', ['setextradata', :id, 'VBoxInternal/Devices/pcbios/0/Config/DmiOEMVBoxRev', "cmdline:console=hvc0 vpccidr=172.16.0.0/16 domain=devcloud.local dns1=8.8.8.8 dns2=8.8.8.4 template=domP name=#{VPC_NAME} eth0ip=#{ENV['VPC_IP']} eth0mask=255.255.255.0 type=vpcrouter disable_rp_filter=true"])
|
|
end
|
|
|
|
|
|
#
|
|
# View the documentation for the provider you're using for more
|
|
# information on available options.
|
|
|
|
# Enable provisioning with CFEngine. CFEngine Community packages are
|
|
# automatically installed. For example, configure the host as a
|
|
# policy server and optionally a policy file to run:
|
|
#
|
|
# config.vm.provision "cfengine" do |cf|
|
|
# cf.am_policy_hub = true
|
|
# # cf.run_file = "motd.cf"
|
|
# end
|
|
#
|
|
# You can also configure and bootstrap a client to an existing
|
|
# policy server:
|
|
#
|
|
# config.vm.provision "cfengine" do |cf|
|
|
# cf.policy_server_address = "10.0.2.15"
|
|
# end
|
|
|
|
# Enable provisioning with Puppet stand alone. Puppet manifests
|
|
# are contained in a directory path relative to this Vagrantfile.
|
|
# You will need to create the manifests directory and a manifest in
|
|
# the file default.pp in the manifests_path directory.
|
|
#
|
|
# config.vm.provision "puppet" do |puppet|
|
|
# puppet.manifests_path = "manifests"
|
|
# puppet.manifest_file = "site.pp"
|
|
# end
|
|
|
|
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
|
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
|
# some recipes and/or roles.
|
|
#
|
|
# config.vm.provision "chef_solo" do |chef|
|
|
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
|
# chef.roles_path = "../my-recipes/roles"
|
|
# chef.data_bags_path = "../my-recipes/data_bags"
|
|
# chef.add_recipe "mysql"
|
|
# chef.add_role "web"
|
|
#
|
|
# # You may also specify custom JSON attributes:
|
|
# chef.json = { mysql_password: "foo" }
|
|
# end
|
|
|
|
# Enable provisioning with chef server, specifying the chef server URL,
|
|
# and the path to the validation key (relative to this Vagrantfile).
|
|
#
|
|
# The Opscode Platform uses HTTPS. Substitute your organization for
|
|
# ORGNAME in the URL and validation key.
|
|
#
|
|
# If you have your own Chef Server, use the appropriate URL, which may be
|
|
# HTTP instead of HTTPS depending on your configuration. Also change the
|
|
# validation key to validation.pem.
|
|
#
|
|
# config.vm.provision "chef_client" do |chef|
|
|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
|
# chef.validation_key_path = "ORGNAME-validator.pem"
|
|
# end
|
|
#
|
|
# If you're using the Opscode platform, your validator client is
|
|
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
|
#
|
|
# If you have your own Chef Server, the default validation client name is
|
|
# chef-validator, unless you changed the configuration.
|
|
#
|
|
# chef.validation_client_name = "ORGNAME-validator"
|
|
end
|