Cleanup of Vagrantfile and related

This commit is contained in:
Jedrzej Nowak 2016-05-04 20:00:51 +02:00
parent 72b9ab56fd
commit a96f686f08
2 changed files with 27 additions and 66 deletions

68
Vagrantfile vendored
View File

@ -30,6 +30,7 @@ else
cfg = defaults_cfg
end
SLAVES_COUNT = cfg["slaves_count"]
SLAVES_RAM = cfg["slaves_ram"]
SLAVES_IPS = cfg["slaves_ips"]
@ -44,38 +45,26 @@ MASTER_CPUS = cfg["master_cpus"]
SLAVES_CPUS = cfg["slaves_cpus"]
PARAVIRT_PROVIDER = cfg.fetch('paravirtprovider', false)
PREPROVISIONED = cfg.fetch('preprovisioned', true)
SOLAR_DB_BACKEND = cfg.fetch('solar_db_backend', 'riak')
# Initialize noop plugins only in case of PXE boot
require_relative 'bootstrap/vagrant_plugins/noop' unless PREPROVISIONED
def ansible_playbook_command(filename, args=[])
"ansible-playbook -v -i \"localhost,\" -c local /vagrant/deploy/solar/bootstrap/playbooks/#{filename} #{args.join ' '}"
end
def shell_script(filename, env=[], args=[])
"/bin/bash -c \"#{env.join ' '} #{filename} #{args.join ' '} \""
end
solar_script = ansible_playbook_command("solar.yaml")
# NOTE(bogdando) w/a for a centos7 issue
fix_six = shell_script("/vagrant/deploy/solar/bootstrap/playbooks/fix_centos7_six.sh")
# solar_script = ansible_playbook_command("solar.yaml")
master_pxe = ansible_playbook_command("pxe.yaml")
get_solar = shell_script("/vagrant/deploy/get-solar.sh")
# master_pxe = ansible_playbook_command("pxe.yaml")
# get_solar = shell_script("/vagrant/deploy/get-solar.sh")
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "solar-dev", primary: true do |config|
config.vm.define "solar", primary: true do |config|
config.vm.box = MASTER_IMAGE
config.vm.box_version = MASTER_IMAGE_VERSION
config.vm.provision "shell", inline: get_solar
config.vm.provision "shell", inline: fix_six, privileged: true
config.vm.provision "shell", inline: solar_script, privileged: true, env: {"SOLAR_DB_BACKEND": SOLAR_DB_BACKEND}
config.vm.provision "shell", inline: master_pxe, privileged: true unless PREPROVISIONED
# config.vm.provision "shell", inline: get_solar
# config.vm.provision "shell", inline: solar_script, privileged: true, env: {"SOLAR_DB_BACKEND": SOLAR_DB_BACKEND}
config.vm.provision "file", source: "~/.vagrant.d/insecure_private_key", destination: "/vagrant/tmp/keys/ssh_private"
config.vm.host_name = "solar-dev"
config.vm.host_name = "solar"
config.vm.provider :virtualbox do |v|
v.memory = MASTER_RAM
@ -89,7 +78,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if PARAVIRT_PROVIDER
v.customize ['modifyvm', :id, "--paravirtprovider", PARAVIRT_PROVIDER] # for linux guest
end
v.name = "solar-dev"
v.name = "solar"
end
config.vm.provider :libvirt do |libvirt|
@ -120,30 +109,17 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
SLAVES_COUNT.times do |i|
index = i + 1
ip_index = i + 3
config.vm.define "solar-dev#{index}" do |config|
config.vm.define "node-#{index}" do |config|
# Standard box with all stuff preinstalled
config.vm.box = SLAVES_IMAGE
config.vm.box_version = SLAVES_IMAGE_VERSION
config.vm.host_name = "solar-dev#{index}"
config.vm.host_name = "node-#{index}"
if PREPROVISIONED
#TODO(bogdando) figure out how to configure multiple interfaces when was not PREPROVISIONED
ind = 0
SLAVES_IPS.each do |ip|
config.vm.network :private_network, ip: "#{ip}#{ip_index}", :dev => "solbr#{ind}", :mode => 'nat'
ind = ind + 1
end
else
# Disable attempts to install guest os and check that node is booted using ssh,
# because nodes will have ip addresses from dhcp, and vagrant doesn't know
# which ip to use to perform connection
config.vm.communicator = :noop
config.vm.guest = :noop_guest
# Configure network to boot vm using pxe
config.vm.network "private_network", adapter: 1, ip: "10.0.0.#{ip_index}"
config.vbguest.no_install = true
config.vbguest.auto_update = false
ind = 0
SLAVES_IPS.each do |ip|
config.vm.network :private_network, ip: "#{ip}#{ip_index}", :dev => "solbr#{ind}", :mode => 'nat'
ind = ind + 1
end
config.vm.provider :virtualbox do |v|
@ -158,7 +134,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if PARAVIRT_PROVIDER
v.customize ['modifyvm', :id, "--paravirtprovider", PARAVIRT_PROVIDER] # for linux guest
end
v.name = "solar-dev#{index}"
v.name = "node-#{index}"
end
config.vm.provider :libvirt do |libvirt|
@ -171,14 +147,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
libvirt.disk_bus = "virtio"
end
if PREPROVISIONED
if SYNC_TYPE == 'nfs'
config.vm.synced_folder ".", "/vagrant", type: "nfs"
end
if SYNC_TYPE == 'rsync'
config.vm.synced_folder ".", "/vagrant", type: "rsync",
if SYNC_TYPE == 'nfs'
config.vm.synced_folder ".", "/vagrant", type: "nfs"
end
if SYNC_TYPE == 'rsync'
config.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__args: ["--verbose", "--archive", "--delete", "-z"]
end
end
end
end

View File

@ -1,14 +1,14 @@
# copy it to vagrant-settings.yaml then Vagrantfile
# will use values from this file
slaves_count: 0
slaves_ram: 1024
master_image: solar-project/solar-master
master_image: solar-project/solar-minimal
master_image_version: null
slaves_image: fc23
slaves_image_version: null
master_ram: 1024
master_ram: 512
master_cpus: 1
slaves_ram: 1024
slaves_count: 2
slaves_image: yk0/ubuntu-xenial
slaves_image_version: null
master_ips:
- 10.0.0.2
- 10.1.0.2
@ -27,16 +27,3 @@ slaves_ips:
# Uncomment following option to change it.
# Possible options are: rsync, nfs
# sync_type: nfs
# Use vagrant image in order to perform provisioning
preprovisioned: true
# Use pxe bootstrap in order to bootstrap nodes
# it should be used in order to provision nodes
# by solar
# preprovisioned: false
# needed for starting / preparing db server
# you can choose from riak | postgresql
solar_db_backend: riak