forked from bfraser/vagrant-lamp-puppet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
106 lines (86 loc) · 4.3 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Require YAML module
require 'yaml'
# Load custom settings
settings = YAML.load_file('custom.yaml')
components = %w(webserver)
Vagrant.configure(2) do |config|
# Automatically manage host entries (requires 'vagrant-hostmanager' plugin)
config.hostmanager.enabled = true
components.each do |component|
next component unless settings[component]['enabled']
(1..settings[component]['nodes']).each do |i|
hostname = "#{component}-%02d" % i
config.vm.define hostname do |node|
node.vm.box = 'base' # This will get overridden later
node.vm.hostname = "#{hostname}.example.com"
# Settings for VirtualBox provider
node.vm.provider :virtualbox do |virtualbox, override|
virtualbox.cpus = settings[component]['cpus']
virtualbox.memory = settings[component]['memory']
override.vm.box = settings[component]['image']
end
# Settings for libvirt provider (requires 'vagrant-libvirt' plugin)
node.vm.provider :libvirt do |libvirt, override|
libvirt.cpus = settings[component]['cpus']
libvirt.memory = settings[component]['memory']
override.vm.box = settings[component]['image']
override.nfs.functional = settings['libvirt']['nfs']
end
# Settings for AWS provider (requires 'vagrant-aws' plugin)
node.vm.provider :aws do |aws, override|
aws.access_key_id = settings['aws']['key']
aws.secret_access_key = settings['aws']['secret']
aws.keypair_name = settings['aws']['keypair']
aws.ami = settings[component]['image']
aws.instance_type = settings[component]['machine_type']
aws.region = settings['aws']['region']
aws.subnet_id = settings['aws']['subnet_id']
aws.security_groups = settings['aws']['security_group']
aws.associate_public_ip = settings['aws']['associate_public_ip']
aws.user_data = "#!/bin/bash\nhostname #{hostname}\necho #{hostname} > /etc/hostname"
# The base box, usually 'dummy'. Add using the following command:
# vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
override.vm.box = 'dummy'
override.ssh.username = settings['ssh']['username']
override.ssh.private_key_path = settings['ssh']['private_key_path']
override.nfs.functional = false # vm.network calls don't work with this plugin
end
# Settings for GCE provider (requires 'vagrant-google' plugin)
node.vm.provider :google do |google, override|
google.google_project_id = settings['google']['project_id']
google.google_client_email = settings['google']['client_email']
google.google_json_key_location = settings['google']['json_key_location']
google.name = "#{hostname}"
google.image = settings[component]['image']
google.machine_type = settings[component]['machine_type']
# The base box, usually 'gce'. Add using the following command:
# vagrant box add gce https://github.com/mitchellh/vagrant-google/raw/master/google.box
override.vm.box = 'gce'
override.ssh.username = settings['ssh']['username']
override.ssh.private_key_path = settings['ssh']['private_key_path']
end
# Install Puppet modules (needs 'vagrant-r10k' and 'puppet' plugins)
node.r10k.puppet_dir = 'puppet'
node.r10k.puppetfile_path = 'puppet/Puppetfile'
node.r10k.module_path = 'puppet/environments/development/vendor'
# Install Puppet (requires 'vagrant-puppet-install' plugin)
node.puppet_install.puppet_version = settings['puppet']['version']
# Provision with Puppet
node.vm.provision :puppet do |puppet|
puppet.environment_path = 'puppet/environments'
puppet.environment = 'development'
puppet.manifests_path = 'puppet/environments/development/manifests'
puppet.manifest_file = 'default.pp'
puppet.module_path = [
'puppet/environments/development/modules',
'puppet/environments/development/vendor'
]
puppet.hiera_config_path = 'puppet/hiera.yaml'
puppet.working_directory = '/tmp/vagrant-puppet'
end
end
end
end
end