-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathVagrantfile
116 lines (101 loc) · 4.41 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
107
108
109
110
111
112
113
114
115
116
Vagrant.configure('2') do |config|
config.vm.box = 'dummy'
config.vm.box_url = 'https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box'
config.berkshelf.enabled = true
config.omnibus.chef_version = :latest
# Workaround password prompt delay: "Text will be echoed in the clear. Please
# install the HighLine or Termios libraries to suppress echoed text."
config.ssh.insert_key = false
config.vm.provider :aws do |aws, override|
# Workaround for "sudo: sorry, you must have a tty to run sudo" error. See
# https://github.com/mitchellh/vagrant/issues/1482 for details.
aws.user_data = "#!/bin/bash\nsed -i -e 's/^Defaults.*requiretty/# Defaults requiretty/g' /etc/sudoers"
# Workaround for "~/aws/keys/#{aws.region}/#{ENV['USER']}.pem", which for
# some reason expands to an object instead of a string. E.g. the following
# fails:
#
# override.ssh.private_key_path = ENV['VAGRANT_SSH_PRIVATE_KEY_PATH'] ||
# "~/aws/keys/#{aws.region}/#{ENV['USER']}.pem"
#
aws_region = ENV['VAGRANT_AWS_REGION'] || 'eu-west-1'
aws.region = aws_region
aws.keypair_name = ENV['VAGRANT_AWS_KEYPAIR_NAME'] || ENV['USER']
# See http://aws.amazon.com/ec2/instance-types/ for list of Amazon EC2
# instance types.
aws.instance_type = ENV['VAGRANT_AWS_INSTANCE_TYPE'] || 'm3.medium'
# Tag the EC2 instance for easier management and clean-up, especially on
# shared accounts.
aws.tags = {
'Name' => ENV['VAGRANT_AWS_TAG_NAME'] || 'MongoDB (started by vagrant-mongodb)',
'owner' => ENV['VAGRANT_AWS_TAG_OWNER'] || ENV['USER'],
'expire-on' => ENV['VAGRANT_AWS_TAG_EXPIRE'] || (Date.today + 30).to_s
}
# See http://aws.amazon.com/ec2/instance-types/#instance-details for the
# instance types that support this.
aws.ebs_optimized = false
# TODO Auto-create the security group, or at least document manual steps.
# Permit at least inbound ports on 22 (SSH) and 27017 (MongoDB).
aws.security_groups = [ 'mms-automation' ]
# List of CentOS 7 AMIs. Generated by tools/ami-ids/ami-ids.
aws.region_config 'ap-northeast-1', :ami => 'ami-89634988'
aws.region_config 'ap-southeast-1', :ami => 'ami-aea582fc'
aws.region_config 'ap-southeast-2', :ami => 'ami-bd523087'
aws.region_config 'eu-central-1', :ami => 'ami-7cc4f661'
aws.region_config 'eu-west-1', :ami => 'ami-e4ff5c93'
aws.region_config 'sa-east-1', :ami => 'ami-bf9520a2'
aws.region_config 'us-east-1', :ami => 'ami-96a818fe'
aws.region_config 'us-west-1', :ami => 'ami-6bcfc42e'
aws.region_config 'us-west-2', :ami => 'ami-c7d092f7'
override.ssh.username = 'centos'
override.ssh.private_key_path = ENV['VAGRANT_SSH_PRIVATE_KEY_PATH'] ||
"~/aws/keys/#{aws_region}/#{ENV['USER']}.pem"
end
# See http://docs.mongodb.org/manual/administration/production-notes/ for
# details.
config.vm.provision :chef_solo do |chef|
chef.add_recipe 'mosh'
chef.add_recipe 'utils'
chef.add_recipe 'ebs'
chef.add_recipe 'mongodb::10gen_repo'
chef.add_recipe 'mongodb'
if ENV['VAGRANT_DEBUG']
chef.log_level = :debug
end
chef.json = {
:mongodb => {
:dbpath => '/data',
:smallfiles => true # Speed up initial journal preallocation
},
:ebs => {
:access_key => ENV['AWS_ACCESS_KEY'],
:secret_key => ENV['AWS_SECRET_KEY'],
:fstype => 'ext4', # Or 'xfs'
:no_boot_config => true,
:md_read_ahead => 32, # Size in number of 512B sectors (16KB)
# :mdadm_chunk_size => 256,
}
}
if ENV['VAGRANT_EBS_RAID']
chef.json[:ebs][:raids] = {
'/dev/md0' => {
:num_disks => 4,
:disk_size => 10, # Size in GB
:raid_level => 10,
:fstype => chef.json[:ebs][:fstype],
:mount_point => '/data',
:mount_options => 'noatime,noexec',
# :piops => 2000, # Provisioned IOPS
# :uselvm => true
}
}
else
chef.json[:ebs][:volumes] = {
'/data' => {
:size => 20, # Size in GB
:fstype => chef.json[:ebs][:fstype],
:mount_options => 'noatime,noexec'
}
}
end
end
end