Example-bootstrap: added readme, sample Vagrantfile

This commit is contained in:
Przemyslaw Kaminski 2015-09-07 15:42:46 +02:00
parent b64592f156
commit 925f791da8
3 changed files with 99 additions and 19 deletions

View File

@ -0,0 +1,12 @@
# Demo of the `solar_bootstrap` Resource
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.
Running
```bash
python example-bootstrap.py deploy
```
will deploy full Solar env to node `solar-dev2`.

79
examples/bootstrap/Vagrantfile vendored Normal file
View File

@ -0,0 +1,79 @@
# -*- 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

View File

@ -1,3 +1,5 @@
#!/usr/bin/env python
import click
import sys
import time
@ -12,19 +14,6 @@ from solar import errors
from solar.interfaces.db import get_db
GIT_PUPPET_LIBS_URL = 'https://github.com/CGenie/puppet-libs-resource'
# TODO
# Resource for repository OR puppet apt-module in run.pp
# add-apt-repository cloud-archive:juno
# To discuss: install stuff in Docker container
# NOTE
# No copy of manifests, pull from upstream (implemented in the puppet handler)
# Official puppet manifests, not fuel-library
db = get_db()
@ -38,15 +27,15 @@ def setup_resources():
signals.Connections.clear()
node3 = vr.create('node3', 'resources/ro_node/', {
'ip': '10.0.0.5',
'ssh_key': '/vagrant/.vagrant/machines/solar-dev3/virtualbox/private_key',
node2 = vr.create('node2', 'resources/ro_node/', {
'ip': '10.0.0.4',
'ssh_key': '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key',
'ssh_user': 'vagrant'
})[0]
solar_bootstrap3 = vr.create('solar_bootstrap3', 'resources/solar_bootstrap', {'master_ip': '10.0.0.2'})[0]
solar_bootstrap2 = vr.create('solar_bootstrap2', 'resources/solar_bootstrap', {'master_ip': '10.0.0.2'})[0]
signals.connect(node3, solar_bootstrap3)
signals.connect(node2, solar_bootstrap2)
has_errors = False
for r in locals().values():
@ -63,7 +52,7 @@ def setup_resources():
sys.exit(1)
resources_to_run = [
'solar_bootstrap3',
'solar_bootstrap2',
]