-
Notifications
You must be signed in to change notification settings - Fork 14
/
Vagrantfile.aws_ubuntu-2204
executable file
·70 lines (60 loc) · 2.9 KB
/
Vagrantfile.aws_ubuntu-2204
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# workaround to deal with "undefined method `except' for #<Hash:...> (NoMethodError)"
# see https://github.com/mitchellh/vagrant-aws/issues/566
class Hash
def slice(*keep_keys)
h = {}
keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
h
end unless Hash.method_defined?(:slice)
def except(*less_keys)
slice(*keys - less_keys)
end unless Hash.method_defined?(:except)
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# when provisioning symlink home/ directory to /home/vagrant
config.vm.provision :shell, inline: "ln -s /home/$(logname) /home/vagrant"
# Remove "desktop" from the args below if only accessing via SSH
# Remove "mosrs" from the args below if not accessing the Met Office Science Repository Service
config.vm.provision :shell, path: "install.sh", args: "ubuntu 2204 desktop mosrs x2go"
config.ssh.forward_x11 = true
# workaround to prevent use of SMB shared folders
# see https://github.com/mitchellh/vagrant-aws/issues/365
config.vm.allowed_synced_folder_types = [:rsync]
# AWS box: must use dummy box - run this command prior to bringing VM up
# vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
# (do not run in metomi-vms directory)
# bring up using: vagrant up --provider=aws
# Environment variables defined within aws-credentials file, but can be hard-coded here
# (do NOT commit key and secret information back to a public repo)
config.vm.provider :aws do |aws, override|
# need to set up a user within the AWS console prior to bringing VM up
aws.access_key_id = ENV['AWS_KEY'] # user key
aws.secret_access_key = ENV['AWS_SECRET'] # user secret
aws.keypair_name = ENV['AWS_KEYNAME'] # name of key as named on AWS region (no file ext.)
aws.security_groups = "MyIP" # use MyIP - need to set this manually in console
# Ubuntu-22.04.5 LTS in the London region (eu-west-2)
# Subscription is required to launch this instance
# OS/VM type determined from AMI - get this from list when searching for instance to launch
aws.region = "eu-west-2"
aws.ami = "ami-0f4dabdf4d255799d"
# Name the VM so it can be found in the EC2 instance list
aws.tags = {
'Name' => "metomi-vms"
}
# VM size
# free tier size: 1xCPU/1GB RAM (only 8GB disk as standard)
#aws.instance_type = "t2.micro"
# larger VM, e.g. Intel Xeon 2xCPU/8GB RAM
aws.instance_type = "m5.large"
# can change disk size independent of instance type. Free tier up to 30GB.
aws.block_device_mapping = [{ 'DeviceName' => '/dev/sda1', 'Ebs.VolumeSize' => 30 }]
# use dummy box
override.vm.box = "dummy"
# on AWS EC2 Ubuntu VMs the default username is 'ubuntu' and NOT vagrant
override.ssh.username = "ubuntu"
override.ssh.private_key_path = ENV['AWS_KEYPATH'] # full path (inc. filename) to key file
end
end