Skip to content

Commit

Permalink
GEODE-7590 - Use GCESysprep as last-step in Windows Packer build. (ap…
Browse files Browse the repository at this point in the history
…ache#4522)

* Fix instance cleanup per zone.
* delete_instanch.sh deletes in all zones just in case.
* Ask for zones, don't assume.
* Use Packer release 1.4.5, not latest prerelease.
* Need reboot before running GCESysPrep in case of windows update.

(cherry picked from commit 2178ba8)
  • Loading branch information
robbadler committed Jan 6, 2020
1 parent 6ffabd4 commit 394b282
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 122 deletions.
4 changes: 2 additions & 2 deletions ci/images/alpine-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
FROM openjdk:8-jdk-alpine

COPY --from=google/cloud-sdk:alpine /google-cloud-sdk /google-cloud-sdk
COPY --from=hashicorp/packer:latest /bin/packer /usr/local/bin/packer
COPY --from=hashicorp/packer:1.3.5 /bin/packer /usr/local/bin/packer135
#COPY --from=hashicorp/packer:latest /bin/packer /usr/local/bin/packer
COPY --from=hashicorp/packer:1.4.5 /bin/packer /usr/local/bin/packer
ENV PATH /google-cloud-sdk/bin:$PATH
RUN apk --no-cache add \
bash \
Expand Down
54 changes: 35 additions & 19 deletions ci/images/google-windows-geode-builder/windows-packer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"project_id": "{{user `gcp_project`}}",
"network": "{{user `gcp_network`}}",
"subnetwork": "{{user `gcp_subnetwork`}}",
"source_image_family": "windows-2016",
"source_image_family": "{{ user `base_family`}}",
"disk_size": "100",
"machine_type": "n1-standard-4",
"communicator": "winrm",
Expand All @@ -40,23 +40,36 @@
"inline": [
"$ErrorActionPreference = \"Stop\"",
"Set-ExecutionPolicy Bypass -Scope Process -Force",
"Install-WindowsFeature Containers",
"Install-WindowsFeature Containers"
]
},
{
"type": "powershell",
"inline": [
"$ErrorActionPreference = \"Stop\"",
"Set-ExecutionPolicy Bypass -Scope Process -Force",
"Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force",
"Install-Module DockerMsftProvider -Force",
"Install-Package Docker -ProviderName DockerMsftProvider -Force",
"New-Item \"C:\\ProgramData\\Docker\\config\\daemon.json\" -Force",
"Set-Content \"C:\\ProgramData\\Docker\\config\\daemon.json\" '{\"registry-mirrors\": [\"https://mirror.gcr.io\"]}'",
"Set-Service wuauserv -StartupType Disabled",
"Stop-Service wuauserv"
]
]
},
{
"type": "windows-restart"
"type": "powershell",
"inline": [
"$ErrorActionPreference = \"Stop\"",
"Set-ExecutionPolicy Bypass -Scope Process -Force",
"Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression"
]
},
{
"type": "powershell",
"inline": [
"$ErrorActionPreference = \"Stop\"",
"Set-ExecutionPolicy Bypass -Scope Process -Force",
"Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression",
"choco install -y git cygwin cyg-get adoptopenjdk11",
"Move-Item \"C:\\Program Files\\AdoptOpenJDK\\jdk-11*\" c:\\java11",
"choco install -y jdk8 -params 'installdir=c:\\\\java8tmp;source=false'",
Expand All @@ -67,7 +80,12 @@
"$NewPath = $OldPath + ';' + 'c:\\Program Files\\Git\\bin' + ';' + 'c:\\tools\\cygwin\\bin'",
"Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment' -Name PATH -Value $NewPath",
"refreshenv",
"cyg-get rsync",
"cyg-get rsync"
]
},
{
"type": "powershell",
"inline": [
"winrm set winrm/config/service '@{AllowUnencrypted=\"true\"}'",
"New-NetFirewallRule -DisplayName sshd -Direction inbound -Action allow -Protocol tcp -LocalPort 22",
"New-NetFirewallRule -DisplayName \"Docker containers\" -LocalAddress 172.0.0.0/8 -Action allow -Direction inbound",
Expand All @@ -77,19 +95,7 @@
]
},
{
"type": "powershell",
"elevated_user": "geode",
"elevated_password": "{{.WinRMPassword}}",
"inline": [
"net start \"Docker Engine\"",
"write-output '>>>>>>>>>> Adding openjdk docker image <<<<<<<<<<'",
"docker pull openjdk:8",
"write-output '>>>>>>>>>> Removing unused docker images <<<<<<<<<<'",
"Set-Content -Path c:\\ProgramData\\docker\\config\\daemon.json -Value '{ \"hosts\": [\"tcp://0.0.0.0:2375\", \"npipe://\"] }'"
]
},
{
"type": "powershell",
"type": "powershell",
"inline": [

"write-output '>>>>>>>>>> Cloning geode repo <<<<<<<<<<'",
Expand All @@ -109,6 +115,16 @@
"write-output '>>>>>>>>>> Final cleanup <<<<<<<<<<'",
"rm -force -recurse geode"
]
},
{
"type": "windows-restart",
"restart_timeout": "30m"
},
{
"type": "powershell",
"inline": [
"GCESysprep -NoShutDown"
]
}
]
}
Loading

0 comments on commit 394b282

Please sign in to comment.