-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
76 lines (61 loc) · 2.38 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
require 'logger'
log = Logger.new(STDOUT)
# Local vars
repo_provision_dir = 'provision'
provisioning_path = '/home/vagrant/provision'
# Load dev env configuration
if File.exist?('dev_config.yml')
dev_config = YAML.load_file('dev_config.yml')
else
log.fatal("Configuration file \"dev_config.yml\" wasn't found! Please create it based on the template.")
exit 1
end
# 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.
Vagrant.configure("2") do |config|
config.vm.box = "generic/fedora35"
config.vm.hostname = "vagrant-#{`hostname`[0..-2]}"
config.vbguest.auto_update = false
config.ssh.forward_agent = true
if dev_config["port_mapping"]
dev_config["port_mapping"].each do |host, guest|
config.vm.network "forwarded_port", host: host, guest: guest
end
end
config.vm.network "private_network", ip: "192.168.60.60"
# Disabling the default /vagrant share
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder repo_provision_dir, provisioning_path, create: true
config.vm.synced_folder dev_config["dev_dir"], "/home/vagrant/gitrepo", create: true
# create and share dirs between the host and the VM
dev_config["synced_dir_mapping"].each do |item|
Dir.mkdir(item['host_path']) if ! Dir.exist?(item['host_path'])
config.vm.synced_folder item['host_path'], item['guest_path'], create: true
end
config.vm.provider "virtualbox" do |vb|
vb.memory = "6144"
vb.cpus = 2
end
# Some preparations for ansible-galaxy to run successfully
config.vm.provision "shell" do |s|
s.inline = <<-SCRIPT
dnf -y install git
SCRIPT
end
config.vm.provision "ansible_local" do |ansible|
ansible.install_mode = :pip_args_only
ansible.pip_install_cmd = "sudo dnf -y install python3-pip"
ansible.pip_args = "-r /home/vagrant/provision/requirements.txt"
ansible.provisioning_path = provisioning_path
ansible.galaxy_role_file = "requirements.yml"
ansible.playbook = "site.yml"
ansible.verbose = "-vv"
end
# Run custom user's provision script if exists
config.vm.provision "shell", inline: "sudo bash #{provisioning_path}/custom.sh" if File.exist?("#{repo_provision_dir}/custom.sh")
end