Skip to content

Commit 3542e82

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 fb59650 commit 3542e82

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
@@ -214,13 +214,6 @@ resources:
214214
password: ((docker.password))
215215

216216
# type: github-release
217-
- name: openssh-release
218-
type: github-release
219-
source:
220-
owner: PowerShell
221-
repository: Win32-OpenSSH
222-
access_token: ((github_public_repo_token))
223-
tag_filter: v([^v].*)
224217
- name: stemcell-builder-github-release
225218
type: github-release
226219
source:
@@ -793,8 +786,6 @@ jobs:
793786
tags: [*worker_tag]
794787
- get: bosh-windows-stemcell-builder-ci-image
795788
tags: [*worker_tag]
796-
- get: open-ssh
797-
resource: openssh-release
798789
- get: stemcell-builder
799790
passed: [build]
800791
tags: [*worker_tag]
@@ -922,8 +913,6 @@ jobs:
922913
tags: [*worker_tag]
923914
- get: bosh-windows-stemcell-builder-ci-image
924915
tags: [*worker_tag]
925-
- get: open-ssh
926-
resource: openssh-release
927916
- get: stemcell-builder
928917
passed: [build]
929918
tags: [*worker_tag]
@@ -1399,8 +1388,6 @@ jobs:
13991388
- get: main-version
14001389
passed: [build]
14011390
tags: [*worker_tag]
1402-
- get: sshd
1403-
resource: openssh-release
14041391
- get: bosh-agent-release
14051392
passed: [build]
14061393
- get: blobstore-dav-cli
@@ -1587,8 +1574,6 @@ jobs:
15871574
- get: main-version
15881575
passed: [wuts-aws]
15891576
tags: [*worker_tag]
1590-
- get: sshd
1591-
resource: openssh-release
15921577
- get: bosh-agent-release
15931578
passed: [wuts-aws]
15941579
- get: blobstore-dav-cli
@@ -1755,8 +1740,6 @@ jobs:
17551740
- get: main-version
17561741
passed: [build]
17571742
tags: [*worker_tag]
1758-
- get: sshd
1759-
resource: openssh-release
17601743
- get: bosh-agent-release
17611744
passed: [build]
17621745
- get: blobstore-dav-cli
@@ -1959,8 +1942,6 @@ jobs:
19591942
- get: main-version
19601943
passed: [build]
19611944
tags: [*worker_tag]
1962-
- get: sshd
1963-
resource: openssh-release
19641945
- get: bosh-agent-release
19651946
passed: [build]
19661947
- 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)