-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
69 lines (60 loc) · 2.54 KB
/
Vagrantfile
File metadata and controls
69 lines (60 loc) · 2.54 KB
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
# https://docs.observium.org/install_debian/
# Here are some tips for making the most of Ansible and Ansible playbooks.
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "512"
vb.cpus = 1
end
config.vm.define "control-machine" do |webtier|
webtier.vm.box = "bento/ubuntu-18.04"
webtier.vm.hostname = "control-machine"
webtier.vm.network "private_network", ip: "192.168.45.20"
webtier.vm.network "forwarded_port", guest: 80, host: 80
webtier.vm.provider "virtualbox" do |vb|
vb.name = "control-machine"
vb.memory = "512"
end
webtier.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
echo "control-machine up && running"
SHELL
webtier.vm.provision "ansible_local" do |ansible|
ansible.playbook = "deploy.yml"
ansible.become = true
end
end
config.vm.define "ansi01" do |webtier|
webtier.vm.box = "bento/ubuntu-18.04"
webtier.vm.hostname = "ansi01"
webtier.vm.network "private_network", ip: "192.168.45.21"
webtier.vm.provider "virtualbox" do |vb|
vb.name = "ansi01"
vb.memory = "512"
end
# https://www.vagrantup.com/docs/provisioning/ansible_local.html
# ansible-galaxy command is executed by default as vagrant user
# Setting galaxy_roles_path to a folder like /etc/ansible/roles will fail
# ansible-galaxy will extract the role a second time in /home/vagrant/.ansible/roles/.
# if your playbook uses become to run as root, it will fail with a "role was not found" error.
# To work around that, you can use ansible.galaxy_command to prepend the command with sudo
webtier.vm.provision "ansible_local" do |ansible|
ansible.playbook = "deploy01.yml"
ansible.become = true
ansible.galaxy_role_file = "/vagrant/requirements.yml"
ansible.galaxy_roles_path = "/etc/ansible/roles"
ansible.galaxy_command = "sudo ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force"
end
webtier.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
echo "ansi01 up && running"
SHELL
end
end