· 7 years ago · Oct 08, 2018, 10:08 AM
1{
2 "variables": {
3 "id": "",
4 "aws_access_key_id": "{{env `AWS_ACCESS_KEY_ID`}}",
5 "aws_secret_access_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
6 "aws_region": "eu-west-1",
7 "aws_source_ami": "ami-0e0bcd012dca25079",
8 "ami_regions": "us-east-1,us-west-1,ap-southeast-1,ap-southeast-2",
9 "aws_instance_type": "c4.xlarge",
10 "aws_vpc_id": "vpc-54111936",
11 "aws_subnet_id": "subnet-11e1ee11",
12 "aws_cloud": "Cloud444",
13 "aws_cloud_tag": "C444",
14 "winrm_userid": "packer_user",
15 "winrm_password": "some_password",
16 "chef_omnibus_version" : "12.9.41",
17 "headless": "true"
18 },
19
20 "builders": [
21 {
22 "name": "WindowsAMI_Prod_Encrypted_HIPAA",
23 "type": "amazon-ebs",
24 "access_key": "{{user `aws_access_key_id`}}",
25 "secret_key": "{{user `aws_secret_access_key`}}",
26 "region": "{{user `aws_region`}}",
27 "source_ami": "{{user `aws_source_ami`}}",
28 "instance_type": "c4.large",
29 "communicator": "winrm",
30 "winrm_username": "{{user `winrm_userid`}}",
31 "winrm_password": "{{user `winrm_password`}}",
32 "winrm_timeout": "15m",
33 "winrm_port": "5985",
34 "subnet_id": "{{user `aws_subnet_id`}}",
35 "vpc_id": "{{user `aws_vpc_id`}}",
36 "encrypt_boot": "false",
37 "user_data_file": "script/setup-winrm-aws-prod.ps1",
38 "ami_name": "Windows_AMI_HIPAA_{{isotime \"2006-01-02\"}}",
39 "ami_regions": "{{user `ami_regions`}}",
40 "ami_users": [ "982347353514", "662182053957" ],
41 "ami_block_device_mappings": [ {
42 "device_name": "/dev/sda1",
43 "volume_type": "gp2",
44 "volume_size": 80,
45 "delete_on_termination": true
46 } ],
47 "launch_block_device_mappings": [ {
48 "device_name": "/dev/sda1",
49 "volume_type": "gp2",
50 "volume_size": 100,
51 "delete_on_termination": true
52 } ]
53 }
54 ],
55
56 "provisioners": [
57 {
58 "only": [
59 "WindowsAMI_Prod_Encrypted_HIPAA"
60 ],
61 "type": "powershell",
62 "elevated_user": "{{user `winrm_userid`}}",
63 "elevated_password": "{{user `winrm_password`}}",
64 "valid_exit_codes": [ 0, 1 ],
65 "scripts": [
66 "script/add_vagrant_to_logon_as_service.ps1"
67 ]
68 },
69 {
70 "only": [
71 "WindowsAMI_Prod_Encrypted_HIPAA"
72 ],
73 "type": "windows-shell",
74 "scripts": [
75 "script/install_chef_client.bat"
76 ],
77 "environment_vars": [
78 "CHEF_OMNIBUS_VERSION={{user `chef_omnibus_version`}}"
79 ]
80 },
81 {
82 "only": [
83 "WindowsAMI_Prod_Encrypted_HIPAA"
84 ],
85 "type": "file",
86 "source": "script/Windows8-RT-KB2842230-x64.msu",
87 "destination": "c:/Windows/Temp/Windows8-RT-KB2842230-x64.msu"
88 },
89 {
90 "only": [
91 "WindowsAMI_Prod_Encrypted_HIPAA"
92 ],
93 "type": "windows-shell",
94 "scripts": [
95 "script/hotfix-KB2842230.bat"
96 ]
97 },
98 {
99 "only": [
100 "WindowsAMI_Prod_Encrypted_HIPAA"
101 ],
102 "type": "chef-client",
103 "guest_os_type": "windows",
104 "node_name": "win2012_prod_packer_node_{{ uuid }}",
105 "validation_client_name": "nvm_dev-validator",
106 "validation_key_path": "./nvm_dev-validator.pem",
107 "server_url": "https://devchef.nvminternal.net/organizations/nvm_dev",
108 "prevent_sudo": true,
109 "skip_install": true,
110 "skip_clean_client": false,
111 "skip_clean_node": false,
112 "run_list": [
113 "recipe[nvm_powershell_modules]",
114 "recipe[nvm_interpreter::install_prereqs]",
115 "recipe[nvm_interpreter::install_wireshark]"
116 ]
117 },
118 {
119 "only": [
120 "WindowsAMI_Prod_Encrypted_HIPAA"
121 ],
122 "type": "powershell",
123 "elevated_user": "{{user `winrm_userid`}}",
124 "elevated_password": "{{user `winrm_password`}}",
125 "valid_exit_codes": [ 0, 1 ],
126 "inline": [
127 "import-module PSWindowsUpdate",
128 "Get-WUInstall -Acceptall -IgnoreReboot"
129 ]
130 },
131 {
132 "only": [
133 "WindowsAMI_Prod_Encrypted_HIPAA"
134 ],
135 "type": "windows-shell",
136 "scripts": [
137 "script/uninstall_chef_client.bat"
138 ]
139 },
140 {
141 "only": [
142 "WindowsAMI_Prod_Encrypted_HIPAA"
143 ],
144 "type": "windows-shell",
145 "inline": [
146 "rmdir /q /s c:\\windows\\temp\\*.*",
147 "del /s /q c:\\windows\\temp\\*.tmp"
148 ]
149 },
150 {
151 "only": [
152 "WindowsAMI_Prod_Encrypted_HIPAA"
153 ],
154 "type": "windows-restart",
155 "restart_timeout": "10m"
156 }
157 ]
158}