This commit is contained in:
8
packer/oci/oracle-linux-8.json
Normal file
8
packer/oci/oracle-linux-8.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"build_name": "oracle-linux-8",
|
||||
"distribution": "Oracle Linux",
|
||||
"operating_system": "Oracle Linux",
|
||||
"operating_system_version": "8",
|
||||
"redhat_epel_rpm": "oracle-epel-release-el8",
|
||||
"ssh_username": "opc"
|
||||
}
|
8
packer/oci/oracle-linux-9.json
Normal file
8
packer/oci/oracle-linux-9.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"build_name": "oracle-linux-9",
|
||||
"distribution": "Oracle Linux",
|
||||
"operating_system": "Oracle Linux",
|
||||
"operating_system_version": "9",
|
||||
"redhat_epel_rpm": "oracle-epel-release-el9",
|
||||
"ssh_username": "opc"
|
||||
}
|
148
packer/oci/packer-windows.json
Normal file
148
packer/oci/packer-windows.json
Normal file
@ -0,0 +1,148 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"availability_domain": "{{user `availability_domain`}}",
|
||||
"base_image_filter": {
|
||||
"operating_system": "{{user `operating_system`}}",
|
||||
"operating_system_version": "{{user `operating_system_version`}}"
|
||||
},
|
||||
"base_image_ocid": "{{user `base_image_ocid`}}",
|
||||
"communicator": "winrm",
|
||||
"compartment_ocid": "{{user `compartment_ocid`}}",
|
||||
"image_name": "cluster-api-{{user `build_name`}}-{{user `kubernetes_semver`}}-{{user `build_timestamp`}}",
|
||||
"shape": "{{user `shape`}}",
|
||||
"shape_config": {
|
||||
"ocpus": "{{user `ocpus`}}"
|
||||
},
|
||||
"subnet_ocid": "{{user `subnet_ocid`}}",
|
||||
"tenancy_ocid": "{{user `tenancy_ocid`}}",
|
||||
"type": "oracle-oci",
|
||||
"user_data_file": "packer/oci/scripts/winrm_bootstrap.txt",
|
||||
"user_ocid": "{{user `user_ocid`}}",
|
||||
"winrm_insecure": true,
|
||||
"winrm_password": "{{user `opc_user_password`}}",
|
||||
"winrm_port": 5986,
|
||||
"winrm_timeout": "10m",
|
||||
"winrm_use_ntlm": true,
|
||||
"winrm_use_ssl": true,
|
||||
"winrm_username": "opc"
|
||||
}
|
||||
],
|
||||
"post-processors": [
|
||||
{
|
||||
"custom_data": {
|
||||
"build_date": "{{isotime}}",
|
||||
"build_name": "{{user `build_name`}}",
|
||||
"build_timestamp": "{{user `build_timestamp`}}",
|
||||
"build_type": "node",
|
||||
"containerd_version": "{{user `containerd_version`}}",
|
||||
"kubernetes_cni_semver": "{{user `kubernetes_cni_semver`}}",
|
||||
"kubernetes_semver": "{{user `kubernetes_semver`}}",
|
||||
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
|
||||
"os_name": "{{user `distro_name`}}",
|
||||
"resource_group_name": "{{user `resource_group_name`}}",
|
||||
"storage_account_name": "{{user `storage_account_name`}}"
|
||||
},
|
||||
"output": "{{user `manifest_output`}}",
|
||||
"strip_path": true,
|
||||
"type": "manifest"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"elevated_password": "{{.WinRMPassword}}",
|
||||
"elevated_user": "opc",
|
||||
"script": "ansible/windows/ansible_winrm.ps1",
|
||||
"type": "powershell"
|
||||
},
|
||||
{
|
||||
"extra_arguments": [
|
||||
"-e",
|
||||
"ansible_winrm_server_cert_validation=ignore ansible_winrm_operation_timeout_sec=120 ansible_winrm_read_timeout_sec=150",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_common_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `azure_extra_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_extra_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_user_vars`}}"
|
||||
],
|
||||
"max_retries": 5,
|
||||
"pause_before": "15s",
|
||||
"playbook_file": "ansible/windows/node_windows.yml",
|
||||
"type": "ansible",
|
||||
"use_proxy": false,
|
||||
"user": "opc"
|
||||
},
|
||||
{
|
||||
"restart_timeout": "10m",
|
||||
"type": "windows-restart"
|
||||
},
|
||||
{
|
||||
"destination": "C:\\Users\\opc\\",
|
||||
"source": "./packer/oci/scripts/sysprep.ps1",
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"destination": "C:\\Users\\opc\\",
|
||||
"source": "./packer/oci/scripts/attach_secondary_vnic.ps1",
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"destination": "C:\\Windows\\Setup\\Scripts\\",
|
||||
"source": "./packer/oci/scripts/enable_second_nic.ps1",
|
||||
"type": "file"
|
||||
},
|
||||
{
|
||||
"inline": [
|
||||
"rm -Force -Recurse C:\\var\\log\\kubelet\\*"
|
||||
],
|
||||
"type": "powershell"
|
||||
},
|
||||
{
|
||||
"elevated_password": "{{.WinRMPassword}}",
|
||||
"elevated_user": "opc",
|
||||
"inline": [
|
||||
"C:\\Users\\opc\\sysprep.ps1"
|
||||
],
|
||||
"type": "powershell"
|
||||
}
|
||||
],
|
||||
"variables": {
|
||||
"additional_debug_files": null,
|
||||
"ansible_common_vars": "",
|
||||
"ansible_extra_vars": "",
|
||||
"ansible_user_vars": "",
|
||||
"azure_extra_vars": "wire_server_users={{user `wire_server_users`}}",
|
||||
"build_name": null,
|
||||
"build_timestamp": "{{timestamp}}",
|
||||
"cloudbase_init_url": "https://github.com/cloudbase/cloudbase-init/releases/download/{{user `cloudbase_init_version`}}/CloudbaseInitSetup_{{user `cloudbase_init_version` | replace_all `.` `_` }}_x64.msi",
|
||||
"cloudbase_logging_serial_port": "COM1,9600,N,8",
|
||||
"cloudbase_metadata_services": "cloudbaseinit.metadata.services.httpservice.HttpService",
|
||||
"cloudbase_metadata_services_unattend": "cloudbaseinit.metadata.services.httpservice.HttpService",
|
||||
"cloudbase_plugins": "cloudbaseinit.plugins.common.ephemeraldisk.EphemeralDiskPlugin, cloudbaseinit.plugins.common.mtu.MTUPlugin, cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin",
|
||||
"cloudbase_plugins_unattend": "cloudbaseinit.plugins.common.mtu.MTUPlugin",
|
||||
"containerd_url": "",
|
||||
"containerd_version": null,
|
||||
"ib_version": "{{env `IB_VERSION`}}",
|
||||
"image_version": "latest",
|
||||
"kubernetes_base_url": "https://kubernetesreleases.blob.core.windows.net/kubernetes/{{user `kubernetes_semver`}}/binaries/node/windows/{{user `kubernetes_goarch`}}",
|
||||
"manifest_output": "manifest.json",
|
||||
"nssm_url": null,
|
||||
"ocpus": "2",
|
||||
"opc_user_password": "{{env `OPC_USER_PASSWORD`}}",
|
||||
"prepull": null,
|
||||
"private_virtual_network_with_public_ip": "",
|
||||
"runtime": "containerd",
|
||||
"shape": "VM.Standard.E4.Flex",
|
||||
"virtual_network_name": "",
|
||||
"virtual_network_resource_group_name": "",
|
||||
"virtual_network_subnet_name": "",
|
||||
"vm_size": "",
|
||||
"windows_service_manager": null,
|
||||
"windows_updates_kbs": null,
|
||||
"wins_url": "",
|
||||
"wire_server_users": ""
|
||||
}
|
||||
}
|
150
packer/oci/packer.json
Normal file
150
packer/oci/packer.json
Normal file
@ -0,0 +1,150 @@
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"availability_domain": "{{user `availability_domain`}}",
|
||||
"base_image_filter": {
|
||||
"operating_system": "{{user `operating_system`}}",
|
||||
"operating_system_version": "{{user `operating_system_version`}}"
|
||||
},
|
||||
"base_image_ocid": "{{user `base_image_ocid`}}",
|
||||
"compartment_ocid": "{{user `compartment_ocid`}}",
|
||||
"fingerprint": "{{user `fingerprint`}}",
|
||||
"image_name": "cluster-api-{{user `build_name`}}-{{user `kubernetes_semver`}}-{{user `build_timestamp`}}",
|
||||
"key_file": "{{user `key_file`}}",
|
||||
"region": "{{user `region`}}",
|
||||
"shape": "{{user `shape`}}",
|
||||
"shape_config": {
|
||||
"ocpus": "{{user `ocpus`}}"
|
||||
},
|
||||
"ssh_private_key_file": "{{ user `ssh_private_key_file`}}",
|
||||
"ssh_username": "{{user `ssh_username`}}",
|
||||
"subnet_ocid": "{{user `subnet_ocid`}}",
|
||||
"tags": {
|
||||
"build_date": "{{isotime}}",
|
||||
"build_timestamp": "{{user `build_timestamp`}}",
|
||||
"containerd_version": "{{user `containerd_version`}}",
|
||||
"distribution": "{{user `operating_system`}}",
|
||||
"distribution_version": "{{user `operating_system_version`}}",
|
||||
"image_builder_version": "{{user `ib_version`}}",
|
||||
"kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
|
||||
"kubernetes_version": "{{user `kubernetes_semver`}}"
|
||||
},
|
||||
"tenancy_ocid": "{{user `tenancy_ocid`}}",
|
||||
"type": "oracle-oci",
|
||||
"use_private_ip": "{{user `use_private_ip`}}",
|
||||
"user_data": "{{user `user_data`}}",
|
||||
"user_ocid": "{{user `user_ocid`}}"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"environment_vars": [
|
||||
"BUILD_NAME={{user `build_name`}}"
|
||||
],
|
||||
"inline": [
|
||||
"if [ $BUILD_NAME != \"ubuntu-1804\" ] || [ $BUILD_NAME != \"ubuntu-2004\" ]; then exit 0; fi",
|
||||
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
|
||||
"sudo apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install python python-pip"
|
||||
],
|
||||
"type": "shell"
|
||||
},
|
||||
{
|
||||
"ansible_env_vars": [
|
||||
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
|
||||
],
|
||||
"extra_arguments": [
|
||||
"--extra-vars",
|
||||
"{{user `ansible_common_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_extra_vars`}}",
|
||||
"--extra-vars",
|
||||
"{{user `ansible_user_vars`}}"
|
||||
],
|
||||
"playbook_file": "./ansible/node.yml",
|
||||
"type": "ansible"
|
||||
},
|
||||
{
|
||||
"arch": "{{user `goss_arch`}}",
|
||||
"download_path": "{{user `goss_download_path`}}",
|
||||
"format": "{{user `goss_format`}}",
|
||||
"format_options": "{{user `goss_format_options`}}",
|
||||
"goss_file": "{{user `goss_entry_file`}}",
|
||||
"inspect": "{{user `goss_inspect_mode`}}",
|
||||
"remote_folder": "{{user `goss_remote_folder`}}",
|
||||
"remote_path": "{{user `goss_remote_path`}}",
|
||||
"skip_install": "{{user `goss_skip_install`}}",
|
||||
"tests": [
|
||||
"{{user `goss_tests_dir`}}"
|
||||
],
|
||||
"type": "goss",
|
||||
"url": "{{user `goss_url`}}",
|
||||
"use_sudo": true,
|
||||
"vars_file": "{{user `goss_vars_file`}}",
|
||||
"vars_inline": {
|
||||
"ARCH": "amd64",
|
||||
"OS": "{{user `distribution` | lower }}",
|
||||
"PROVIDER": "oci",
|
||||
"containerd_version": "{{user `containerd_version`}}",
|
||||
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
|
||||
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
|
||||
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
|
||||
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
|
||||
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
|
||||
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
|
||||
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
|
||||
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
|
||||
},
|
||||
"version": "{{user `goss_version`}}"
|
||||
}
|
||||
],
|
||||
"variables": {
|
||||
"ansible_common_vars": "",
|
||||
"ansible_extra_vars": "",
|
||||
"ansible_user_vars": "",
|
||||
"availability_domain": "{{env `OCI_AVAILABILITY_DOMAIN`}}",
|
||||
"base_image_ocid": "",
|
||||
"build_timestamp": "{{timestamp}}",
|
||||
"compartment_ocid": "",
|
||||
"containerd_sha256": null,
|
||||
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
|
||||
"containerd_version": null,
|
||||
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
|
||||
"crictl_version": null,
|
||||
"disable_default_service_account": "",
|
||||
"encrypted": "false",
|
||||
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
|
||||
"fingerprint": "{{env `OCI_USER_FINGERPRINT`}}",
|
||||
"ib_version": "{{env `IB_VERSION`}}",
|
||||
"key_file": "{{env `OCI_USER_KEY_FILE`}}",
|
||||
"kubernetes_cni_deb_version": null,
|
||||
"kubernetes_cni_http_source": null,
|
||||
"kubernetes_cni_rpm_version": null,
|
||||
"kubernetes_cni_semver": null,
|
||||
"kubernetes_cni_source_type": null,
|
||||
"kubernetes_container_registry": null,
|
||||
"kubernetes_deb_gpg_key": null,
|
||||
"kubernetes_deb_repo": null,
|
||||
"kubernetes_deb_version": null,
|
||||
"kubernetes_http_source": null,
|
||||
"kubernetes_load_additional_imgs": null,
|
||||
"kubernetes_rpm_gpg_check": null,
|
||||
"kubernetes_rpm_gpg_key": null,
|
||||
"kubernetes_rpm_repo": null,
|
||||
"kubernetes_rpm_version": null,
|
||||
"kubernetes_semver": null,
|
||||
"kubernetes_series": null,
|
||||
"kubernetes_source_type": null,
|
||||
"ocpus": "1",
|
||||
"operating_system": null,
|
||||
"operating_system_version": null,
|
||||
"region": "us-ashburn-1",
|
||||
"shape": "VM.Standard.E4.Flex",
|
||||
"ssh_private_key_file": "",
|
||||
"ssh_username": null,
|
||||
"subnet_ocid": "{{env `OCI_SUBNET_OCID`}}",
|
||||
"tenancy_ocid": "{{env `OCI_TENANCY_OCID`}}",
|
||||
"use_private_ip": "false",
|
||||
"user_data": "",
|
||||
"user_ocid": "{{env `OCI_USER_OCID`}}"
|
||||
}
|
||||
}
|
39
packer/oci/scripts/attach_secondary_vnic.ps1
Normal file
39
packer/oci/scripts/attach_secondary_vnic.ps1
Normal file
@ -0,0 +1,39 @@
|
||||
function Get-Second-Vnic-Ocid() {
|
||||
$ocid = ""
|
||||
$vnics = Invoke-RestMethod -Uri "http://169.254.169.254/opc/v1/vnics/"
|
||||
if ($vnics.Count -eq 2) {
|
||||
$ocid = $vnics[1].vnicId
|
||||
} else {
|
||||
Write-Host "vnics count not equal 2"
|
||||
}
|
||||
return $ocid
|
||||
}
|
||||
|
||||
$vnicId = Get-Second-Vnic-Ocid
|
||||
Write-Host "found vnic id: ${vnicId}"
|
||||
|
||||
|
||||
$retryDelaySeconds = 30
|
||||
# We should continue to retry indefinitely until the vnic is
|
||||
# detected by IMDS
|
||||
# https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm
|
||||
while($vnicId -eq "") {
|
||||
$vnicId = Get-Second-Vnic-Ocid
|
||||
Write-Host("Getting second vnic failed. Waiting " + $retryDelaySeconds + " seconds before next attempt.")
|
||||
Start-Sleep -Seconds $retryDelaySeconds
|
||||
}
|
||||
|
||||
if ($vnicId -ne "") {
|
||||
Write-Host "Pulling down the secondary_vnic_windows_configure.ps1"
|
||||
Invoke-WebRequest -Uri "https://docs.oracle.com/en-us/iaas/Content/Resources/Assets/secondary_vnic_windows_configure.ps1" -OutFile "C:\Users\opc\secondary_vnic_windows_configure.ps1"
|
||||
|
||||
Write-Host "calling script using ${vnicId}"
|
||||
|
||||
, 'Y', 'A' | powershell "C:\Users\opc\secondary_vnic_windows_configure.ps1 ${vnicId}"
|
||||
Write-Error "secondary_vnic_windows_configure.ps1 - done"
|
||||
|
||||
$ipconfig = ipconfig
|
||||
Write-Error "${ipconfig}"
|
||||
}else{
|
||||
Write-Error "VNIC OCID is empty. Can't configure."
|
||||
}
|
47
packer/oci/scripts/enable_second_nic.ps1
Normal file
47
packer/oci/scripts/enable_second_nic.ps1
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
$newNetAdapterName = "Ethernet 2"
|
||||
|
||||
# check for two nics
|
||||
$netAdapters = Get-NetAdapter
|
||||
if ($netAdapters.Length -le 1) {
|
||||
Write-Output "Could not find multiple Network Adapters."
|
||||
Exit 1
|
||||
}
|
||||
|
||||
$secondNic = $netAdapters[1]
|
||||
|
||||
# make sure the network adapter is known
|
||||
if ($secondNic.Name -ne "") {
|
||||
Write-Output "Changing ${secondNic.Name} to ${newNetAdapterName} ..."
|
||||
try
|
||||
{
|
||||
Rename-NetAdapter -Name $secondNic.Name -NewName "${newNetAdapterName}"
|
||||
$secondNic.Name = $newNetAdapterName
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Output "Could not rename net adapter"
|
||||
Write-Output $_
|
||||
}
|
||||
} else {
|
||||
Write-Output "Can not change network adapter named: ${secondNic.Name}"
|
||||
}
|
||||
|
||||
# check that second is disabled
|
||||
if ($secondNic.Status -ne "up") {
|
||||
|
||||
try
|
||||
{
|
||||
Enable-NetAdapter -Name $secondNic.Name
|
||||
Write-Output "${secondNic.Name} enabled ..."
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Output "Could not enable net adapter"
|
||||
Write-Output $_
|
||||
}
|
||||
} else {
|
||||
Write-Output "${secondNic.Name} already enabled ..."
|
||||
}
|
||||
|
||||
Remove-Item -Path .\enable_second_nic.ps1
|
27
packer/oci/scripts/set_bootstrap.sh
Executable file
27
packer/oci/scripts/set_bootstrap.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script overrides the 'opc' password set in the winrm_bootstrap.txt file
|
||||
# This script is assumed to be run from the make file hence the pathing to the winrm_bootstrap.txt
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
echo "Changing Password in winrm_bootstrap.txt"
|
||||
|
||||
cp packer/oci/scripts/winrm_bootstrap_template.txt packer/oci/scripts/winrm_bootstrap.txt
|
||||
|
||||
sed "s/(\[adsi\].*/([adsi](\"WinNT:\/\/\"+\$opcUser.caption).replace(\"\\\\\",\"\/\")).SetPassword(\"$OPC_USER_PASSWORD\")/g" packer/oci/scripts/winrm_bootstrap.txt | tee packer/oci/scripts/winrm_bootstrap.txt >/dev/null
|
37
packer/oci/scripts/sysprep.ps1
Normal file
37
packer/oci/scripts/sysprep.ps1
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright 2020 The Kubernetes Authors.
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if( Test-Path $Env:SystemRoot\system32\Sysprep\unattend.xml ) {
|
||||
Remove-Item $Env:SystemRoot\system32\Sysprep\unattend.xml -Force
|
||||
}
|
||||
|
||||
$unattendedXml = "$ENV:ProgramFiles\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml"
|
||||
$FileExists = Test-Path $unattendedXml
|
||||
If ($FileExists -eq $True) {
|
||||
# Use the Cloudbase-init provided unattend file during install
|
||||
Write-Output "Using cloudbase-init unattend file for sysprep: $unattendedXml"
|
||||
& $Env:SystemRoot\System32\Sysprep\Sysprep.exe /oobe /generalize /mode:vm /quit /quiet /unattend:$unattendedXml
|
||||
}else {
|
||||
& $Env:SystemRoot\System32\Sysprep\Sysprep.exe /oobe /generalize /mode:vm /quit /quiet
|
||||
}
|
||||
|
||||
# Wait for the image to be reset
|
||||
while($true) {
|
||||
$imageState = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State).ImageState
|
||||
Write-Output $imageState
|
||||
if ($imageState -eq 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { break }
|
||||
Start-Sleep -s 5
|
||||
}
|
||||
|
||||
Write-Output '>>> Sysprep complete ...'
|
25
packer/oci/scripts/unset_bootstrap.sh
Executable file
25
packer/oci/scripts/unset_bootstrap.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2021 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script overrides the 'opc' password set in the winrm_bootstrap.txt file
|
||||
# This script is assumed to be run from the make file hence the pathing to the winrm_bootstrap.txt
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
echo "resetting Password in winrm_bootstrap.txt"
|
||||
|
||||
rm packer/oci/scripts/winrm_bootstrap.txt
|
50
packer/oci/scripts/winrm_bootstrap_template.txt
Normal file
50
packer/oci/scripts/winrm_bootstrap_template.txt
Normal file
@ -0,0 +1,50 @@
|
||||
<powershell>
|
||||
|
||||
# MAKE SURE IN YOUR PACKER CONFIG TO SET:
|
||||
#
|
||||
#
|
||||
# "winrm_username": "Administrator",
|
||||
# "winrm_insecure": true,
|
||||
# "winrm_use_ssl": true,
|
||||
#
|
||||
#
|
||||
#ps1_sysnative
|
||||
cmd /C 'wmic UserAccount where Name="opc" set PasswordExpires=False'
|
||||
$opcUser = get-wmiobject win32_useraccount | Where-Object { $_.Name -match 'opc' }
|
||||
([adsi]("WinNT://"+$opcUser.caption).replace("\","/")).SetPassword("myTemp#Pa55_Word")
|
||||
|
||||
write-output "Running User Data Script"
|
||||
write-host "(host) Running User Data Script"
|
||||
|
||||
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore
|
||||
|
||||
# Don't set this before Set-ExecutionPolicy as it throws an error
|
||||
$ErrorActionPreference = "stop"
|
||||
|
||||
# Remove HTTP listener
|
||||
Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse
|
||||
|
||||
# Create a self-signed certificate to let ssl work
|
||||
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "packer"
|
||||
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force
|
||||
|
||||
# WinRM
|
||||
write-output "Setting up WinRM"
|
||||
write-host "(host) setting up WinRM"
|
||||
|
||||
cmd.exe /c winrm quickconfig -q
|
||||
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
|
||||
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
|
||||
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
|
||||
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
|
||||
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
|
||||
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
|
||||
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
|
||||
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTPS" "@{Port=`"5986`";Hostname=`"packer`";CertificateThumbprint=`"$($Cert.Thumbprint)`"}"
|
||||
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
|
||||
cmd.exe /c netsh firewall add portopening TCP 5986 "Port 5986"
|
||||
cmd.exe /c net stop winrm
|
||||
cmd.exe /c sc config winrm start= auto
|
||||
cmd.exe /c net start winrm
|
||||
|
||||
</powershell>
|
7
packer/oci/ubuntu-1804.json
Normal file
7
packer/oci/ubuntu-1804.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"build_name": "ubuntu-1804",
|
||||
"distribution": "ubuntu",
|
||||
"operating_system": "Canonical Ubuntu",
|
||||
"operating_system_version": "18.04",
|
||||
"ssh_username": "ubuntu"
|
||||
}
|
7
packer/oci/ubuntu-2004.json
Normal file
7
packer/oci/ubuntu-2004.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"build_name": "ubuntu-2004",
|
||||
"distribution": "ubuntu",
|
||||
"operating_system": "Canonical Ubuntu",
|
||||
"operating_system_version": "20.04",
|
||||
"ssh_username": "ubuntu"
|
||||
}
|
7
packer/oci/ubuntu-2204.json
Normal file
7
packer/oci/ubuntu-2204.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"build_name": "ubuntu-2204",
|
||||
"distribution": "ubuntu",
|
||||
"operating_system": "Canonical Ubuntu",
|
||||
"operating_system_version": "22.04",
|
||||
"ssh_username": "ubuntu"
|
||||
}
|
7
packer/oci/windows-2019.json
Normal file
7
packer/oci/windows-2019.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"build_name": "windows-2019",
|
||||
"operating_system": "Windows",
|
||||
"operating_system_version": "Server 2019 Standard",
|
||||
"runtime": "containerd",
|
||||
"ssh_username": "opc"
|
||||
}
|
7
packer/oci/windows-2022.json
Normal file
7
packer/oci/windows-2022.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"build_name": "windows-2022",
|
||||
"operating_system": "Windows",
|
||||
"operating_system_version": "Server 2022 Standard",
|
||||
"runtime": "containerd",
|
||||
"ssh_username": "opc"
|
||||
}
|
Reference in New Issue
Block a user