Created
August 6, 2019 17:34
-
-
Save gjyoung1974/c89f10ea3a707d6d52c531dfa5554397 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"admin_user": "{{env `ADMIN_USER`}}", | |
"admin_password": "{{env `ADMIN_PASSWORD`}}", | |
"source_image": "{{env `SOURCE_IMAGE`}}", | |
"image_family": "{{env `IMAGE_FAMILY`}}", | |
"project_id": "{{env `PROJECT_ID`}}", | |
"network_id": "{{env `NETWORK_ID`}}" | |
}, | |
"_comment": "Packs an image of Windows Server for GCP", | |
"builders": [ | |
{ | |
"type": "googlecompute", | |
"project_id": "{{user `project_id`}}", | |
"network": "{{user `network_id`}}", | |
"source_image": "{{user `source_image`}}", | |
"disk_size": "120", | |
"machine_type": "n1-standard-4", | |
"communicator": "winrm", | |
"winrm_username": "{{user `admin_user`}}", | |
"winrm_insecure": true, | |
"winrm_use_ssl": true, | |
"state_timeout" : "15m", | |
"metadata": { | |
"windows-startup-script-cmd": "winrm quickconfig -quiet & net user /add {{user `admin_user`}} & net localgroup administrators {{user `admin_user`}} /add & winrm set winrm/config/service/auth @{Basic=\"true\"}" | |
}, | |
"zone": "us-west1-a", | |
"image_name": "pmi-{{user `source_image`}}-{{timestamp}}", | |
"image_family": "pmi-{{user `image_family`}}", | |
"image_description":"ACME Custom {{user `source_image`}} Image {{timestamp}}" | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "file", | |
"source": "builder", | |
"destination": "C:\\Windows", | |
"direction": "upload" | |
}, | |
{ | |
"type": "windows-shell", | |
"inline": [ | |
"powershell -ExecutionPolicy bypass -File C:/Windows/setup-scripts/builder.ps1" | |
] | |
}, | |
{ | |
"type": "windows-shell", | |
"inline": [ | |
"powershell -ExecutionPolicy bypass -File C:/Windows/benchmark-gpos/Local_Script/BaselineLocalInstall.ps1 -WS2019DomainController" | |
] | |
}, | |
{ | |
"type": "powershell", | |
"inline": [ | |
"C:/Windows/System32/Sysprep/Sysprep.exe /generalize /quit /quiet", | |
"while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment