From c652ded6f0abcef92567ef3ca7c02821c88e1e90 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Tue, 15 Sep 2015 14:09:57 +0200 Subject: [PATCH] Add slaves/master images to vagrant-settings.yaml Modified README for bootstrap --- Vagrantfile | 6 +- examples/bootstrap/README.md | 3 +- examples/bootstrap/Vagrantfile | 79 ------------------------- examples/bootstrap/vagrant-settings.yml | 5 ++ 4 files changed, 11 insertions(+), 82 deletions(-) delete mode 100644 examples/bootstrap/Vagrantfile create mode 100644 examples/bootstrap/vagrant-settings.yml diff --git a/Vagrantfile b/Vagrantfile index 650e3a44..89d789e8 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -30,7 +30,9 @@ end SLAVES_COUNT = cfg["slaves_count"] SLAVES_RAM = cfg["slaves_ram"] +SLAVES_IMAGE = cfg["slaves_image"] MASTER_RAM = cfg["master_ram"] +MASTER_IMAGE = cfg["master_image"] SYNC_TYPE = cfg["sync_type"] def ansible_playbook_command(filename, args=[]) @@ -48,7 +50,7 @@ slave_celery = ansible_playbook_command("celery.yaml", ["--skip-tags", "master"] Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.define "solar-dev", primary: true do |config| - config.vm.box = "cgenie/solar-master" + config.vm.box = MASTER_IMAGE config.vm.provision "shell", inline: solar_script, privileged: true config.vm.provision "shell", inline: master_celery, privileged: true @@ -85,7 +87,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| ip_index = i + 3 config.vm.define "solar-dev#{index}" do |config| # standard box with all stuff preinstalled - config.vm.box = "cgenie/solar-master" + config.vm.box = SLAVES_IMAGE config.vm.provision "file", source: "bootstrap/ansible.cfg", destination: "/home/vagrant/.ansible.cfg" config.vm.provision "shell", inline: slave_script, privileged: true diff --git a/examples/bootstrap/README.md b/examples/bootstrap/README.md index 9a1c5b9b..fbb7fadf 100644 --- a/examples/bootstrap/README.md +++ b/examples/bootstrap/README.md @@ -3,7 +3,8 @@ You need to instantiate Vagrant with a slave node which is unprovisioned (i.e. started from the `trusty64` Vagrant box). -You can start the boxes from the Vagrantfile in this directory. +You can start the boxes from the `Vagrantfile` in master directory and +`vagrant-settings.yml` from this directory. Running ```bash diff --git a/examples/bootstrap/Vagrantfile b/examples/bootstrap/Vagrantfile deleted file mode 100644 index 56bf3552..00000000 --- a/examples/bootstrap/Vagrantfile +++ /dev/null @@ -1,79 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -require 'yaml' - -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -# configs, custom updates _defaults -defaults_cfg = YAML.load_file('vagrant-settings.yml_defaults') -if File.exist?('vagrant-settings.yml') - custom_cfg = YAML.load_file('vagrant-settings.yml') - cfg = defaults_cfg.merge(custom_cfg) -else - cfg = defaults_cfg -end - -SLAVES_COUNT = cfg["slaves_count"] -SLAVES_RAM = cfg["slaves_ram"] -MASTER_RAM = cfg["master_ram"] - -def ansible_playbook_command(filename, args=[]) - "ansible-playbook -v -i \"localhost,\" -c local /vagrant/bootstrap/playbooks/#{filename} #{args.join ' '}" -end - -solar_script = ansible_playbook_command("solar.yml") - -slave_script = ansible_playbook_command("custom-configs.yml", ["-e", "master_ip=10.0.0.2"]) - -master_celery = ansible_playbook_command("celery.yml", ["--skip-tags", "slave"]) - -slave_celery = ansible_playbook_command("celery.yml", ["--skip-tags", "master"]) - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - - config.vm.define "solar-dev", primary: true do |config| - #config.vm.box = "deb/jessie-amd64" - #config.vm.box = "rustyrobot/deb-jessie-amd64" - #config.vm.box = "ubuntu/trusty64" - config.vm.box = "cgenie/solar-master" - - config.vm.provision "shell", inline: solar_script, privileged: true - config.vm.provision "shell", inline: master_celery, privileged: true - config.vm.provision "file", source: "~/.vagrant.d/insecure_private_key", destination: "/vagrant/tmp/keys/ssh_private" - config.vm.provision "file", source: "bootstrap/ansible.cfg", destination: "/home/vagrant/.ansible.cfg" - config.vm.network "private_network", ip: "10.0.0.2" - config.vm.host_name = "solar-dev" - - config.vm.provider :virtualbox do |v| - v.customize [ - "modifyvm", :id, - "--memory", MASTER_RAM, - "--paravirtprovider", "kvm" # for linux guest - ] - v.name = "solar-dev" - end - end - - SLAVES_COUNT.times do |i| - index = i + 1 - ip_index = i + 3 - config.vm.define "solar-dev#{index}" do |config| - config.vm.box = "ubuntu/trusty64" - - config.vm.network "private_network", ip: "10.0.0.#{ip_index}" - config.vm.host_name = "solar-dev#{index}" - - config.vm.provider :virtualbox do |v| - v.customize [ - "modifyvm", :id, - "--memory", SLAVES_RAM, - "--paravirtprovider", "kvm" # for linux guest - ] - v.name = "solar-dev#{index}" - end - end - end - -end diff --git a/examples/bootstrap/vagrant-settings.yml b/examples/bootstrap/vagrant-settings.yml new file mode 100644 index 00000000..ca4632f1 --- /dev/null +++ b/examples/bootstrap/vagrant-settings.yml @@ -0,0 +1,5 @@ +# rename it to vagrant-settings.yml then Vagrantfile +# will use values from this file + +slaves_count: 3 +slaves_image: ubuntu/trusty64