-
Notifications
You must be signed in to change notification settings - Fork 566
/
Vagrantfile
65 lines (52 loc) · 2.17 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
require 'yaml'
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'aws'
Vagrant.configure('2') do |config|
access_key_id = File.read('.vagrant_key_id').chomp
secret_access_key = File.read('.vagrant_secret_access_key').chomp
keypair = File.read('.vagrant_keypair_name').chomp
config.vm.box = 'dummy'
Dir['spec/serverspec/*'].each do |dname|
next unless File.directory?(dname)
# Convert spec/serverspec/ubuntu-precise into 'ubuntu-precise'
name = File.basename(dname)
spec_config = YAML.load_file(File.join(dname + '/config.yml'))
config.vm.synced_folder '.', '/vagrant/jenkins', type: 'rsync'
config.vm.define(name) do |node|
# This is a Vagrant-local hack to make sure we have properly udpated apt
# caches since AWS machines are definitely going to have stale ones
node.vm.provision 'shell',
:inline => 'if [ ! -f "/apt-cached" ]; then apt-get update && touch /apt-cached; fi'
node.vm.provision 'shell',
:inline => 'ln -sf /tmp/vagrant-puppet-2/modules-0 /tmp/vagrant-puppet-2/modules-0/jenkins'
node.vm.provision 'puppet' do |pp|
pp.module_path = [
'.',
'spec/fixtures/modules',
]
pp.manifests_path = "spec/serverspec/#{name}/manifests"
end
node.vm.provision :serverspec do |spec|
spec.pattern = "spec/serverspec/#{name}/*_spec.rb"
end
node.vm.provider :aws do |aws, override|
aws.access_key_id = access_key_id
aws.secret_access_key = secret_access_key
aws.keypair_name = keypair
hostname = "vagrant-jenkins-#{name}"
# Ensuring that our machines hostname is "correct" so Puppet will apply
# the right resources to it
aws.user_data = "#!/bin/sh
echo '#{hostname}' > /etc/hostname;
hostname '#{hostname}';"
aws.tags = {:Name => hostname}
# Ubuntu LTS 12.04 in us-west-2 with Puppet installed from the Puppet
# Labs apt repository
aws.ami = spec_config['ami']
aws.region = spec_config['region']
override.ssh.username = spec_config['username']
override.ssh.private_key_path = File.expand_path('~/.ssh/id_rsa')
end
end
end
end
# vim: ft=ruby