-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
executable file
·96 lines (83 loc) · 2.86 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
if ENV['GIGABLOG_BOX'] == 'aws'
box = "dummy"
box_url = "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box"
else
box = "nrel/CentOS-6.7-x86_64"
box_url = "https://vagrantcloud.com/nrel/boxes/CentOS-6.7-x86_64/versions/1.0.0/providers/virtualbox.box"
end
Vagrant.configure(2) do |config|
# Vagrant virtual environment box to build from
config.vm.box = box
# URL from where config.vm.box will be fetched if not on user's system
config.vm.box_url = box_url
# Cache packages to reduce provisioning time
if Vagrant.has_plugin?("vagrant-cachier")
#Configure cached packages to be shared between instances of same base box
config.cache.scope = :box
end
# Forward ports from guest to host
config.vm.network "forwarded_port", guest: 80, host: 9170
config.vm.network "forwarded_port", guest: 3306, host: 9171
# Configure shared folder
config.vm.synced_folder ".", "/vagrant"
# Use rsync for shared folders - required for AWS deployment
config.vm.allowed_synced_folder_types = :rsync
FileUtils.mkpath("./log")
FileUtils.chmod_R 0777, ["./log"]
####################
#### VirtualBox ####
####################
config.vm.provider :virtualbox do |vb|
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate//vagrant","1"]
end
#############
#### AWS ####
#############
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.keypair_name = ENV['AWS_KEYPAIR_NAME']
# aws.ami = "ami-1bfa2b78" # selinux disabled
aws.ami = "ami-b85e86db" # selinux on
aws.region = ENV['AWS_DEFAULT_REGION']
aws.instance_type = "t2.small"
aws.elastic_ip = ENV['AWS_GIGABLOG_ELASTIC_IP']
aws.tags = {
'Name' => 'gigablog',
'Deployment' => 'test',
}
aws.security_groups = ENV['AWS_SECURITY_GROUPS']
override.ssh.username = "centos"
override.ssh.private_key_path = ENV['AWS_SSH_PRIVATE_KEY_PATH']
end
# Enable provisioning with chef solo
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = [
"chef/site-cookbooks",
"chef/chef-cookbooks",
]
chef.environments_path = 'chef/environments'
################################
#### Set server environment ####
################################
chef.environment = "aws_restore"
if ENV['GIGABLOG_BOX'] == 'aws'
chef.add_recipe "aws"
else
chef.add_recipe "vagrant"
end
# You may also specify custom JSON attributes:
chef.json = {
:gigablog_box => ENV['GIGABLOG_BOX'],
:environment => "vagrant",
:gigablog => {
:server_names => ["localhost"],
:log_dir => "/vagrant/log",
}
}
# Additional chef settings to put in solo.rb
chef.custom_config_path = "Vagrantfile.chef"
end
end