This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
69 lines (57 loc) · 2.63 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
$VAGRANT_CONFIG_VERSON = 2
Vagrant.require_plugin "vagrant-aws"
Vagrant.require_plugin "vagrant-winrm-syncedfolders"
Vagrant.configure($VAGRANT_CONFIG_VERSION) do |config|
config.vm.box = "dummy"
config.vm.box_url = "https://github.com/mitchellh/vagrant-aws/blob/master/dummy.box?raw=true"
config.vm.communicator = "winrm"
config.vm.guest = :windows
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-fa05b392"
aws.tags = {
'Name' => ENV["ASSET_NAME"],
'net.matrix.orgunit' => "Matrix NOC",
'net.matrix.organization' => "Private Ops",
'net.matrix.commonname' => "cloud",
'net.matrix.locality' => "Dallas",
'net.matrix.state' => "Texas",
'net.matrix.country' => "USA",
'net.matrix.environment' => "production",
'net.matrix.application' => "infrastructure",
'net.matrix.role' => "application services",
'net.matrix.owner' => "[email protected]",
'net.matrix.customer' => "PVT-01",
'net.matrix.costcenter' => "INT-01"
}
aws.instance_type = "t2.micro"
aws.region = ENV["AWS_DEFAULT_REGION"]
#aws.subnet_id = ENV["AWS_SUBNET"]
#aws.security_groups = ENV["AWS_SECURITY_GROUPS"]
override.nfs.functional = false # workaround for upstream issue #340
override.winrm.username = "Administrator"
override.winrm.password = Base64.decode(ENV["WIN32_ACCESS_TOKEN"])
override.vm.communicator = :winrm
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
config.vm.provision :shell, inline: <<-EOL
# set administrator password
net user Administrator ${Base64.decode(ENV["WIN32_ACCESS_TOKEN"])}
wmic useraccount where "name='Administrator'" set PasswordExpires=FALSE
# configure WinRM
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'
winrm set winrm/config '@{MaxTimeoutms="7200000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
net stop winrm
sc config winrm start=auto
net start winrm
# turn off PowerShell execution policy restrictions
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
EOL
end
end