This repository has been archived by the owner on Jan 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
65 lines (54 loc) · 2.26 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
Vagrant.configure(2) do |config|
config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
config.vm.define "default" do |default|
## General VM settings
default.vm.hostname = "uhosting.vagrant.dev"
## Network settings
default.vm.network "private_network", ip: '172.28.128.4'
## Synced folders
default.vm.synced_folder ".", "/etc/puppet/modules/uhosting"
default.vm.synced_folder ".", "/vagrant"
## Provisioning
$inline_provisioning = <<SCRIPT
if [ ! -f /etc/.shell_already_provisioned ]; then
echo "[INFO] Change sources.list to use ch mirror..."
sed -i 's/us.archive/ch.archive/g' /etc/apt/sources.list
echo "[INFO] Initial apt-get update..."
apt-get update >/dev/null
echo "[INFO] Configuration Puppet..."
sed -i '/templatedir/d' /etc/puppet/puppet.conf
. /vagrant/vagrant/install_puppet.sh
touch /etc/.shell_already_provisioned
else
echo "[INFO] shell provisioning already done..."
fi
SCRIPT
default.vm.provision :shell, inline: $inline_provisioning
default.librarian_puppet.puppetfile_dir = 'vagrant'
default.librarian_puppet.placeholder_filename = '.gitkeep'
default.vm.provision :puppet do |puppet|
puppet.manifests_path = "vagrant"
puppet.manifest_file = "default.pp"
puppet.hiera_config_path = "vagrant/hiera.yaml"
puppet.facter = { 'vagrant' => true }
puppet.options = "--verbose --modulepath /etc/puppet/modules:/vagrant/vagrant/modules"
end
# FACTER_vagrant='true' puppet apply --verbose --modulepath /etc/puppet/modules:/vagrant/vagrant/modules --hiera_config=/vagrant/vagrant/hiera.yaml --manifestdir /vagrant/vagrant /vagrant/vagrant/default.pp
## VirtualBox customization
default.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
end
## Read hiera YAML and put all server_names into landrush
config.landrush.enabled = true
hieradata = YAML.load_file('vagrant/hieradata.yaml')
hieradata['uhosting::sites'].each do |sitename,sitedata|
sitedata['server_names'].each do |server_name|
config.landrush.host server_name, '172.28.128.4'
config.landrush.host "#{server_name}.vagrant.dev", '172.28.128.4'
end
end
end