Created
September 21, 2021 07:28
-
-
Save codingarchitect/88a45b777497bf03cbe57e64368511b8 to your computer and use it in GitHub Desktop.
packer template for windows server 2019 oci packer builder
This file contains 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": { | |
"user_ocid":"{{env `user_ocid`}}", | |
"tenancy_ocid": "{{env `tenancy_ocid`}}", | |
"fingerprint":"{{env `fingerprint`}}", | |
"private_key_path":"{{env `private_key_path`}}", | |
"private_key_password":"{{env `TF_VAR_private_key_password`}}", | |
"availability_domain": "uwhB:EU-FRANKFURT-1-AD-1", | |
"region": "eu-frankfurt-1", | |
"base_image_ocid": "ocid1.image.oc1.eu-frankfurt-1.redacted", | |
"image_shape": "VM.Standard.E4.Flex", | |
"compartment_ocid": "{{env `compartment_ocid`}}", | |
"subnet_ocid": "ocid1.subnet.oc1.eu-frankfurt-1.redacted", | |
"winrm_username": "opc", | |
"winrm_password": "<redacted>" | |
}, | |
"builders": [ | |
{ | |
"user_ocid":"{{user `user_ocid`}}", | |
"tenancy_ocid": "{{user `tenancy_ocid`}}", | |
"fingerprint":"{{user `fingerprint`}}", | |
"key_file":"{{user `private_key_path`}}", | |
"pass_phrase":"{{user `private_key_password`}}", | |
"availability_domain": "{{user `availability_domain`}}", | |
"region": "{{user `region`}}", | |
"base_image_ocid": "{{user `base_image_ocid`}}", | |
"compartment_ocid": "{{user `compartment_ocid`}}", | |
"shape_config": { | |
"ocpus": 2, | |
"memory_in_gbs": 16 | |
}, | |
"image_name": "windows-custom", | |
"shape": "{{user `image_shape`}}", | |
"communicator": "winrm", | |
"winrm_username": "{{user `winrm_username`}}", | |
"winrm_password": "{{user `winrm_password`}}", | |
"winrm_use_ssl": true, | |
"winrm_insecure": true, | |
"winrm_no_proxy": true, | |
"use_private_ip": false, | |
"subnet_ocid": "{{user `subnet_ocid`}}", | |
"user_data_file": "./cloudinit.ps1", | |
"type": "oracle-oci" | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "ansible", | |
"playbook_file": "./playbook.yml", | |
"user": "opc", | |
"use_proxy": false, | |
"extra_arguments": ["-e", "ansible_winrm_server_cert_validation=ignore", "-vvvv"] | |
}, | |
{ | |
"type": "powershell", | |
"inline": [ | |
"& C:\\Windows\\Panther\\Generalize.cmd", | |
"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