This repository has been archived by the owner on May 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Vagrantfile
59 lines (51 loc) · 1.71 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
IP_BASE = "192.168.120."
SALT_PILLAR_DIR = "./_vagrant/salt/pillar"
DEFAULT_ROLES = [
"admin",
"hosts",
"ntp",
"salt-minion",
"sshd",
]
def configure_network(v, hostname, ip_offset)
v.vm.hostname = "#{hostname}.ubiquitous"
v.vm.network "private_network", ip: "#{IP_BASE}#{ip_offset}", netmask: "255.255.255.0"
end
def provision_master(v)
v.vm.synced_folder ".", "/srv/salt", type: "rsync"
v.vm.synced_folder SALT_PILLAR_DIR, "/srv/pillar", type: "rsync"
v.vm.provision "salt-master", type: "shell", path: "./_vagrant/salt/bootstrap-master",
args: [ "--auto-accept-minions" ]
end
def provision_minion(v, master, roles)
args = [
"--master", master,
"--environment", "base",
"--id", v.vm.hostname,
"--grain-environment", "dev",
]
(DEFAULT_ROLES + roles).each { |r| args.push("--grain-role", r) }
v.vm.synced_folder "./_vagrant", "/vagrant", type: "rsync"
v.vm.provision(
"salt-install", type: "shell",
path: "./_vagrant/salt/bootstrap-minion",
args: args)
v.vm.provision(
"salt-wait", type: "shell",
inline: "until salt-call test.ping; do sleep 1; done")
v.vm.provision(
"salt-apply", type: "shell",
inline: "salt-call --state-output mixed state.apply")
end
Vagrant.configure(2) do |config|
config.vm.box = "generic/ubuntu1804"
config.vm.synced_folder ".", "/vagrant", disabled: true
if Vagrant.has_plugin? "vagrant-hostmanager"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = false
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
end
instance_eval File.read("Vagrantfile.local"), "Vagrantfile.local"
end