]>
Commit | Line | Data |
---|---|---|
109c6b75 LSJ |
1 | # -*- mode: ruby -*- |
2 | # vi: set ft=ruby : | |
3 | ||
4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure | |
5 | # configures the configuration version (we support older styles for | |
6 | # backwards compatibility). Please don't change it unless you know what | |
7 | # you're doing. | |
8 | Vagrant.configure(2) do |config| | |
9 | #Define if running desktop OS to yes otherwise no | |
10 | Desktop = "no" | |
11 | #Define the number of nodes to spin up | |
12 | N = 3 | |
13 | ||
14 | #Iterate over nodes | |
15 | (1..N).each do |node_id| | |
16 | nid = (node_id - 1) | |
17 | ||
18 | config.vm.define "node#{nid}" do |node| | |
19 | node.vm.box = "mrlesmithjr/centos-7" | |
20 | node.vm.provider "virtualbox" do |vb| | |
21 | vb.memory = "1024" | |
22 | vb.cpus = "1" | |
23 | if Desktop == "yes" | |
24 | vb.gui = true | |
25 | vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxvga"] | |
26 | vb.customize ["modifyvm", :id, "--accelerate3d", "on"] | |
27 | vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
28 | vb.customize ["modifyvm", :id, "--vram", "128"] | |
29 | vb.customize ["modifyvm", :id, "--hwvirtex", "on"] | |
30 | end | |
31 | end | |
32 | node.vm.hostname = "node#{nid}" | |
33 | ### Define additional network adapters below | |
34 | node.vm.network :private_network, ip: "192.168.202.#{200 + nid}" | |
35 | ||
36 | ### Define port forwards below | |
37 | # node.vm.network "forwarded_port", guest: 80, host: "#{8080 + nid}" | |
38 | # node.vm.network "forwarded_port", guest: 3000, host: "#{3000 + nid}" | |
39 | ||
40 | if node_id == N | |
41 | node.vm.provision :shell, path: "bootstrap.sh", keep_color: "true" #runs initial shell script | |
42 | node.vm.provision "ansible" do |ansible| #runs bootstrap Ansible playbook | |
43 | ansible.limit = "all" | |
44 | ansible.playbook = "bootstrap.yml" | |
45 | end | |
46 | node.vm.provision "ansible" do |ansible| #runs Ansible playbook for installing roles/executing tasks | |
47 | ansible.limit = "all" | |
48 | ansible.playbook = "playbook.yml" | |
49 | ansible.groups = { | |
50 | "test-nodes" => [ | |
51 | "node0", | |
52 | "node1" | |
53 | ], | |
54 | "prod-nodes" => [ | |
55 | "node2" | |
56 | ] | |
57 | } | |
58 | end | |
59 | end | |
60 | ||
61 | end | |
62 | end | |
63 | end |