Skip to content

Commit 47cf3f2

Browse files
committed
packer: Install and use Microsoft provide OpenSSH
For the packer-built stemcells install OpenSSH as part of VM setup, not WinRM because executing `Add-WindowsCapability` via WinRM does not appear to be allowed. So instead move the installation of OpenSSH.Server to the various IaaS pre-boot scrips which are not executed via WinRM. The installations of OpenSSSH.Server happens as follows: - Azure: add a `custom_script` parameter to packer config - AWS: added to `setup_winrm.txt` - GCP: add to `setup-winrm.ps1` and use `sysprep-specialize-script-ps1` - vSphere: TODO [1] https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
1 parent 614bdc0 commit 47cf3f2

File tree

24 files changed

+1215
-1629
lines changed

24 files changed

+1215
-1629
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,6 @@ resources:
204204
password: ((docker.password))
205205

206206
# type: github-release
207-
- name: openssh-release
208-
type: github-release
209-
source:
210-
owner: PowerShell
211-
repository: Win32-OpenSSH
212-
access_token: ((github_public_repo_token))
213-
tag_filter: v([^v].*)
214207
- name: stemcell-builder-github-release
215208
type: github-release
216209
source:
@@ -774,8 +767,6 @@ jobs:
774767
tags: [*worker_tag]
775768
- get: bosh-windows-stemcell-builder-ci-image
776769
tags: [*worker_tag]
777-
- get: open-ssh
778-
resource: openssh-release
779770
- get: stemcell-builder
780771
passed: [build]
781772
tags: [*worker_tag]
@@ -901,8 +892,6 @@ jobs:
901892
tags: [*worker_tag]
902893
- get: bosh-windows-stemcell-builder-ci-image
903894
tags: [*worker_tag]
904-
- get: open-ssh
905-
resource: openssh-release
906895
- get: stemcell-builder
907896
passed: [build]
908897
tags: [*worker_tag]
@@ -1372,8 +1361,6 @@ jobs:
13721361
- get: main-version
13731362
passed: [build]
13741363
tags: [*worker_tag]
1375-
- get: sshd
1376-
resource: openssh-release
13771364
- get: bosh-agent-release
13781365
passed: [build]
13791366
- get: blobstore-dav-cli
@@ -1552,8 +1539,6 @@ jobs:
15521539
- get: main-version
15531540
passed: [wuts-aws]
15541541
tags: [*worker_tag]
1555-
- get: sshd
1556-
resource: openssh-release
15571542
- get: bosh-agent-release
15581543
passed: [wuts-aws]
15591544
- get: blobstore-dav-cli
@@ -1712,8 +1697,6 @@ jobs:
17121697
- get: main-version
17131698
passed: [build]
17141699
tags: [*worker_tag]
1715-
- get: sshd
1716-
resource: openssh-release
17171700
- get: bosh-agent-release
17181701
passed: [build]
17191702
- get: blobstore-dav-cli
@@ -1908,8 +1891,6 @@ jobs:
19081891
- get: main-version
19091892
passed: [build]
19101893
tags: [*worker_tag]
1911-
- get: sshd
1912-
resource: openssh-release
19131894
- get: bosh-agent-release
19141895
passed: [build]
19151896
- get: blobstore-dav-cli

ci/tasks/create-aws-stemcell/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ inputs:
77
- name: base-amis
88
- name: version
99
- name: lgpo-binary
10-
- name: sshd
1110
- name: bosh-agent-release
1211
- name: blobstore-dav-cli
1312
- name: blobstore-s3-cli

ci/tasks/create-azure-stemcell/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ inputs:
66
- name: version
77
- name: stemcell-builder
88
- name: lgpo-binary
9-
- name: sshd
109
- name: bosh-agent-release
1110
- name: blobstore-dav-cli
1211
- name: blobstore-s3-cli

ci/tasks/create-gcp-stemcell/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ inputs:
77
- name: base-gcp-image
88
- name: version
99
- name: lgpo-binary
10-
- name: sshd
1110
- name: bosh-agent-release
1211
- name: blobstore-dav-cli
1312
- name: blobstore-s3-cli

ci/tasks/generate-deps-file/run.bash

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
openssh_win64_sha256="$(shasum -a 256 open-ssh/OpenSSH-Win64.zip | cut -d " " -f 1)"
5-
openssh_win64_version="$(cat open-ssh/version)"
6-
74
psmodules_sha256="$(shasum -a 256 psmodules-zip-output/bosh-psmodules.zip | cut -d " " -f 1)"
85
psmodules_version="$(cat version/version)"
96

@@ -15,10 +12,6 @@ lgpo_version="3"
1512

1613
cat <<EOF > deps-file/deps.json
1714
{
18-
"OpenSSH-Win64.zip": {
19-
"sha": "${openssh_win64_sha256}",
20-
"version": "${openssh_win64_version}"
21-
},
2215
"bosh-psmodules.zip": {
2316
"sha": "${psmodules_sha256}",
2417
"version": "${psmodules_version}"

ci/tasks/generate-deps-file/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ platform: linux
44
inputs:
55
- name: bosh-windows-stemcell-builder-ci
66
- name: stemcell-builder
7-
- name: open-ssh
87
- name: lgpo-binary
98
- name: version
109
- name: bosh-agent

ci/tasks/zip-files/run.bash

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ROOT_DIR=$(pwd)
66
REPO_ROOT="${REPO_ROOT:-"$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"}"
77
ZIP_FILE_DESTINATION="${ZIP_FILE_DESTINATION:-"${ROOT_DIR}/zip-file/StemcellAutomation-$(date +"%s").zip"}"
88

9-
OPENSSH_ZIP="${OPENSSH_ZIP:-"${ROOT_DIR}/open-ssh/OpenSSH-Win64.zip"}"
109
BOSH_PSMODULES_ZIP="${BOSH_PSMODULES_ZIP:-"${ROOT_DIR}/psmodules-zip-output/bosh-psmodules.zip"}"
1110
AGENT_ZIP="${AGENT_ZIP:-"${ROOT_DIR}/bosh-agent/agent.zip"}"
1211
DEPS_JSON="${DEPS_JSON:-"${ROOT_DIR}/deps-file/deps.json"}"
@@ -20,7 +19,7 @@ mkdir -p "${stemcell_automation_dir}"
2019

2120
declare -a files_to_zip
2221
mapfile -t files_to_zip < <(find "${REPO_ROOT}/stembuild/stemcell-automation" -type f -not -name "*Test*" -name "*.ps*1")
23-
files_to_zip+=("${OPENSSH_ZIP}" "${BOSH_PSMODULES_ZIP}" "${AGENT_ZIP}" "${DEPS_JSON}")
22+
files_to_zip+=("${BOSH_PSMODULES_ZIP}" "${AGENT_ZIP}" "${DEPS_JSON}")
2423

2524
cp "${files_to_zip[@]}" "${stemcell_automation_dir}"
2625

ci/tasks/zip-files/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ platform: linux
44
inputs:
55
- name: bosh-windows-stemcell-builder-ci
66
- name: stemcell-builder
7-
- name: open-ssh
87
- name: deps-file
98
- name: bosh-agent
109
- name: psmodules-zip-output

lib/packer/config/azure.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def builders
4545
'winrm_use_ssl' => 'true',
4646
'winrm_insecure' => 'true',
4747
'winrm_timeout' => '1h',
48-
'winrm_username' => 'packer'
48+
'winrm_username' => 'packer',
49+
'custom_script' => 'powershell -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -Command "Add-WindowsCapability -Online -Name (Get-WindowsCapability -Online -Name OpenSSH.Server* | ForEach-Object Name)"'
4950
}
5051
]
5152
end

lib/packer/config/gcp.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def initialize(
3939
end
4040

4141
def builders
42+
stemcell_builder_dir = File.expand_path('../../../../', __FILE__)
4243
[
4344
{
4445
'type' => 'googlecompute',
@@ -62,7 +63,7 @@ def builders
6263
'winrm_timeout' => '1h',
6364
'state_timeout' => '10m',
6465
'metadata' => {
65-
'sysprep-specialize-script-url' => 'https://raw.githubusercontent.com/cloudfoundry/bosh-windows-stemcell-builder/master/scripts/gcp/setup-winrm.ps1',
66+
'sysprep-specialize-script-ps1' => File.read(File.join(stemcell_builder_dir, 'scripts', 'gcp', 'setup-winrm.ps1')),
6667
'name' => "#{@vm_prefix}-#{Time.now.to_i}",
6768
}.compact_blank!
6869
}

0 commit comments

Comments
 (0)