-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
103 lines (79 loc) · 4.29 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'''
/**
* Tasting Mesos DC/OS
*
* Vagrantfile for Linux Containers Mesos DC/OS (Operating System Level Virtualization)
* and also for
* - tasting my simple python Flask application (over apache/httpd) on docker images
* @author Adriano Vieira <adriano.svieira at gmail.com>
Copyright 2016 Adriano dos Santos Vieira
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* @license @see LICENCE
*/
'''
VAGRANTFILE_API_VERSION = "2"
OSLV_CPU = 2
OSLV_MEMORY = 1024
OSLV_MANAGER_FQDN = "mesos.dcos"
OSLV_GROUP = 'DC_OS'
OSLV_NODES = 3
OSLV_PVTNET = "192.168.50.10"
ipv4 = OSLV_PVTNET.split('.')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |virtualbox| # Virtualbox.settings
virtualbox.customize [ "modifyvm", :id, "--cpus", OSLV_CPU ]
virtualbox.customize [ "modifyvm", :id, "--memory", OSLV_MEMORY ]
virtualbox.customize [ "modifyvm", :id, "--name", OSLV_MANAGER_FQDN ]
virtualbox.customize [ "modifyvm", :id, "--groups", "/#{OSLV_GROUP}" ]
end # end Virtualbox.settings
config.vm.box = "adrianovieira/centos7-vbox5.0.24"
config.vm.box_check_update = false
# shared folder between host and VM (may be for development porposes)
config.vm.synced_folder ".", "/home/vagrant/shared"
config.vm.provision "dcos-mesos-install_prereqs", type: "shell",
path: "setup/dcos-mesos-install_prereqs.sh"
config.vm.provision "ssh-id_rsa.pub-setup", type: "shell",
inline: "sudo cat /home/vagrant/shared/setup/ssh_key-id_rsa.pub >> /home/vagrant/.ssh/authorized_keys"
(1..(OSLV_NODES)).each do |node_id|
config.vm.define "dcos_node#{node_id}" do |dcos| # define-VM DC/OS nodes
dcos.vm.provision "hostname-setup", type: "shell",
inline: "sudo hostnamectl set-hostname dcos_node#{node_id}"
node_ipv4 = [ipv4[0], ipv4[1],ipv4[2], (ipv4[3].to_i+node_id)>=250?(ipv4[3].to_i-node_id):ipv4[3].to_i+node_id ].join('.')
dcos.vm.network "private_network", ip: node_ipv4 #, virtualbox__intnet: "mesos_dcos_net"
dcos.vm.provider "virtualbox" do |virtualbox| # Virtualbox.settings
virtualbox.customize [ "modifyvm", :id, "--name", "dcos_node#{node_id}" ]
end # end Virtualbox.settings
end # end-of-define-VM DC/OS nodes
end # end-of-define-VM-loop node_id
# DC/OS Master
config.vm.define "dcos_master" do |dcos| # define-VM DC/OS nodes
dcos.vm.provider "virtualbox" do |virtualbox| # Virtualbox.settings
virtualbox.customize [ "modifyvm", :id, "--memory", 2048 ]
virtualbox.customize [ "modifyvm", :id, "--name", "dcos_master" ]
end # end Virtualbox.settings
# standard sync folder between host and VM (not host shared)
config.vm.synced_folder "./genconf", "/home/vagrant/dcos-install/genconf", type: "rsync"
#dcos.vm.network "public_network", ip: OSLV_PVTNET
dcos.vm.network "forwarded_port", guest: 80, host: 1080
dcos.vm.network "forwarded_port", guest: 8181, host: 8181
dcos.vm.network "forwarded_port", guest: 8080, host: 8080
dcos.vm.provision "hostname-setup", type: "shell",
inline: "sudo hostnamectl set-hostname dcos_master"
dcos.vm.provision "ssh_key-setup", type: "shell",
inline: "sudo cp /home/vagrant/shared/setup/ssh_key-id_rsa /home/vagrant/dcos-install/genconf/ssh_key;
sudo chmod 0600 /home/vagrant/dcos-install/genconf/ssh_key;
sudo chown vagrant:vagrant /home/vagrant/dcos-install/genconf/ssh_key;
sudo cp /home/vagrant/shared/setup/ssh_key-id_rsa /home/vagrant/.ssh/id_rsa;
sudo chown vagrant:vagrant /home/vagrant/.ssh/id_rsa;
sudo chmod 0600 /home/vagrant/.ssh/id_rsa;"
dcos.vm.network "private_network", ip: OSLV_PVTNET #, virtualbox__intnet: "mesos_dcos_net"
end # end-of-define-VM DC/OS nodes
end # end-of-file