Skip to content

Commit 13dcaa2

Browse files
author
Rajath Agasthya
committed
Remove static IPs for Windows 2019 on vSphere
Pipeline uses DHCP for vSphere VMs created during stembuild.
1 parent 958ce3f commit 13dcaa2

File tree

12 files changed

+152
-58
lines changed

12 files changed

+152
-58
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,6 @@ resources:
298298
file: main
299299
initial_version: "((BASE_OS_VERSION)).1.0"
300300

301-
# type: pool
302-
- name: nimbus-ips
303-
type: pool
304-
tags: [*internal_worker_tag]
305-
source:
306-
branch: master
307-
pool: nimbus-ips
308-
private_key: ((github_deploy_key_Bosh-Windows-Locks.private_key))
309-
uri: [email protected]:TNZ/Bosh-Windows-Locks.git
310-
311301
# type: s3
312302
- name: blobstore-s3-cli
313303
type: s3
@@ -810,10 +800,6 @@ jobs:
810800
- get: bosh-agent-release
811801
passed: [build]
812802
- get: ovftool
813-
- put: nimbus-ips
814-
inputs: detect
815-
params: { acquire: true }
816-
tags: [*internal_worker_tag]
817803
- get: blobstore-dav-cli
818804
- get: blobstore-s3-cli
819805
- get: blobstore-gcs-cli
@@ -856,6 +842,23 @@ jobs:
856842
- task: zip-files
857843
file: bosh-windows-stemcell-builder-ci/ci/tasks/zip-files/task.yml
858844
image: bosh-windows-stemcell-builder-ci-image
845+
- load_var: integration-vm-name
846+
file: integration-vm-name/name
847+
format: trim
848+
reveal: true
849+
- task: fetch-integration-vm-ip
850+
file: bosh-windows-stemcell-builder-ci/ci/tasks/fetch-vm-ip/task.yml
851+
image: bosh-windows-stemcell-builder-ci-image
852+
tags: [ windows-nimbus ]
853+
params:
854+
GOVC_URL: ((nimbus_windows-demo_auth_url))
855+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
856+
VCENTER_VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
857+
VM_NAME: ((.:integration-vm-name))
858+
- load_var: integration-vm-ip
859+
file: vm-ip/ip
860+
format: trim
861+
reveal: true
859862
- task: integration
860863
tags: [windows-nimbus]
861864
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-integration-stembuild-windows/task.yml
@@ -879,6 +882,7 @@ jobs:
879882
VM_PASSWORD: ((stembuild_vm_user.password))
880883
PACKAGE_TEST_VM_NAME: stembuild-package-integration-tests-base-vm
881884
OS_LINE: *windows_os_line
885+
TARGET_VM_IP: ((.:integration-vm-ip))
882886
- task: build
883887
tags: [windows-nimbus]
884888
file: bosh-windows-stemcell-builder-ci/ci/tasks/build-stembuild-windows/task.yml
@@ -896,11 +900,6 @@ jobs:
896900
params:
897901
CLONE_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
898902
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
899-
ensure:
900-
put: nimbus-ips
901-
inputs: detect
902-
params: { release: nimbus-ips }
903-
tags: [*internal_worker_tag]
904903

905904
- name: stembuild-linux
906905
serial: true
@@ -929,10 +928,6 @@ jobs:
929928
- get: bosh-agent-release
930929
passed: [build]
931930
- get: ovftool
932-
- put: nimbus-ips
933-
inputs: detect
934-
params: { acquire: true }
935-
tags: [*internal_worker_tag]
936931
- get: blobstore-dav-cli
937932
- get: blobstore-s3-cli
938933
- get: blobstore-gcs-cli
@@ -975,6 +970,23 @@ jobs:
975970
- task: zip-files
976971
file: bosh-windows-stemcell-builder-ci/ci/tasks/zip-files/task.yml
977972
image: bosh-windows-stemcell-builder-ci-image
973+
- load_var: integration-vm-name
974+
file: integration-vm-name/name
975+
format: trim
976+
reveal: true
977+
- task: fetch-integration-vm-ip
978+
file: bosh-windows-stemcell-builder-ci/ci/tasks/fetch-vm-ip/task.yml
979+
image: bosh-windows-stemcell-builder-ci-image
980+
tags: [ windows-nimbus ]
981+
params:
982+
GOVC_URL: ((nimbus_windows-demo_auth_url))
983+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
984+
VCENTER_VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
985+
VM_NAME: ((.:integration-vm-name))
986+
- load_var: integration-vm-ip
987+
file: vm-ip/ip
988+
format: trim
989+
reveal: true
978990
- task: integration
979991
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-integration-stembuild-linux/task.yml
980992
image: bosh-windows-stemcell-builder-ci-image
@@ -999,6 +1011,7 @@ jobs:
9991011
VM_PASSWORD: ((stembuild_vm_user.password))
10001012
PACKAGE_TEST_VM_NAME: stembuild-package-integration-tests-base-vm
10011013
OS_LINE: *windows_os_line
1014+
TARGET_VM_IP: ((.:integration-vm-ip))
10021015
- task: build
10031016
file: bosh-windows-stemcell-builder-ci/ci/tasks/build-stembuild-linux/task.yml
10041017
image: bosh-windows-stemcell-builder-ci-image
@@ -1016,11 +1029,6 @@ jobs:
10161029
params:
10171030
CLONE_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
10181031
VCENTER_ADMIN_CREDENTIAL_URL: ((nimbus_windows-demo_auth_url))
1019-
ensure:
1020-
put: nimbus-ips
1021-
inputs: detect
1022-
params: { release: nimbus-ips }
1023-
tags: [*internal_worker_tag]
10241032

10251033
- name: create-stembuild-linux-stemcell
10261034
serial: true
@@ -1074,12 +1082,12 @@ jobs:
10741082
image: bosh-windows-stemcell-builder-ci-image
10751083
tags: [windows-nimbus]
10761084
params:
1085+
GOVC_URL: ((nimbus_windows-demo_auth_url))
10771086
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
10781087
VCENTER_USERNAME: ((nimbus_windows-demo_user.username))
10791088
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
10801089
VCENTER_VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
10811090
STEMBUILD_BASE_VM_NAME: windows-server-2019-base-vm-linux
1082-
STEMBUILD_BASE_VM_IP: 192.168.111.31
10831091
STEMBUILD_BASE_VM_USERNAME: ((stembuild_vm_user.username))
10841092
STEMBUILD_BASE_VM_PASSWORD: ((stembuild_vm_user.password))
10851093
- task: run-stembuild-package
@@ -1232,6 +1240,19 @@ jobs:
12321240
DATACENTER: dc0
12331241
VM_TO_SNAPSHOT: /dc0/vm/bosh-windows-ci-vms-and-templates/windows-server-2019-base-vm-windows
12341242
SNAPSHOT_NAME: "stembuild-ready-power-on"
1243+
- task: fetch-vm-ip
1244+
file: bosh-windows-stemcell-builder-ci/ci/tasks/fetch-vm-ip/task.yml
1245+
image: bosh-windows-stemcell-builder-ci-image
1246+
tags: [ windows-nimbus ]
1247+
params:
1248+
GOVC_URL: ((nimbus_windows-demo_auth_url))
1249+
VCENTER_BASE_URL: ((nimbus_windows-demo_base_url))
1250+
VCENTER_VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
1251+
VM_NAME: windows-server-2019-base-vm-windows
1252+
- load_var: ip
1253+
file: vm-ip/ip
1254+
format: trim
1255+
reveal: true
12351256
- task: run-stembuild-construct
12361257
file: bosh-windows-stemcell-builder-ci/ci/tasks/run-construct-stembuild-windows/task.yml
12371258
tags: [windows-nimbus]
@@ -1241,7 +1262,7 @@ jobs:
12411262
VCENTER_PASSWORD: ((nimbus_windows-demo_user.password))
12421263
VCENTER_VM_FOLDER: /dc0/vm/bosh-windows-ci-vms-and-templates
12431264
STEMBUILD_BASE_VM_NAME: windows-server-2019-base-vm-windows
1244-
STEMBUILD_BASE_VM_IP: 192.168.111.32
1265+
STEMBUILD_BASE_VM_IP: ((.:ip))
12451266
STEMBUILD_BASE_VM_USERNAME: ((stembuild_vm_user.username))
12461267
STEMBUILD_BASE_VM_PASSWORD: ((stembuild_vm_user.password))
12471268
- task: run-stembuild-package

ci/tasks/fetch-vm-ip/run.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
5+
6+
source ${SCRIPT_DIR}/../../common-scripts/update_nimbus_urls_and_cert.sh
7+
8+
cat > ca.crt <<END_OF_CERT
9+
$VCENTER_CA_CERT
10+
END_OF_CERT
11+
12+
VM_NAME="${VCENTER_VM_FOLDER}/${VM_NAME}"
13+
14+
echo "Fetching IP for VM: $VM_NAME..."
15+
16+
SECONDS=0
17+
VM_IP=
18+
19+
while [ -z "$VM_IP" ] || [ "$VM_IP" == "null" ]; do
20+
VM_IP=$(govc vm.info -json "$VM_NAME" | jq -r '.virtualMachines[0].guest.ipAddress')
21+
22+
if [ ${SECONDS} -gt ${TIMEOUT} ] ; then
23+
echo "Error: could not retrieve IP address for VM '$VM_NAME' in '$TIMEOUT' seconds."
24+
exit 1
25+
fi
26+
27+
sleep 10
28+
done
29+
30+
echo -n "${VM_IP}" > vm-ip/ip

ci/tasks/fetch-vm-ip/task.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
platform: linux
3+
4+
inputs:
5+
- name: bosh-windows-stemcell-builder-ci
6+
7+
outputs:
8+
- name: vm-ip
9+
10+
run:
11+
path: bosh-windows-stemcell-builder-ci/ci/tasks/fetch-vm-ip/run.sh
12+
13+
params:
14+
GOVC_URL:
15+
VCENTER_BASE_URL:
16+
VM_NAME:
17+
VCENTER_VM_FOLDER:
18+
TIMEOUT: 300

ci/tasks/run-construct-stembuild-linux/run.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,27 @@ cp lgpo-binary/LGPO*.zip "${ROOT_DIR}/LGPO.zip"
1212
ca_cert_file="${ROOT_DIR}/vcenter_ca.crt"
1313
echo "${VCENTER_CA_CERT}" > "${ca_cert_file}"
1414

15+
VM_NAME="${VCENTER_VM_FOLDER}/${STEMBUILD_BASE_VM_NAME}"
16+
17+
echo "Fetching IP for VM: $VM_NAME..."
18+
19+
VM_IP=$(govc vm.info -json "$VM_NAME" | jq -r '.virtualMachines[0].guest.ipAddress')
20+
21+
if [ -z "$VM_IP" ]; then
22+
echo "Error: could not retrieve IP address for VM '$VM_NAME'."
23+
exit 1
24+
fi
25+
1526
cp stembuild-untested-linux/stembuild* "${ROOT_DIR}/stembuild"
1627
chmod 500 "${ROOT_DIR}/stembuild"
1728

1829
./stembuild -debug construct \
1930
-vcenter-url "${VCENTER_BASE_URL}" \
20-
-vcenter-username "${VCENTER_USERNAME}" \
21-
-vcenter-password "${VCENTER_PASSWORD}" \
31+
-vcenter-username "${VCENTER_USERNAME}" \
32+
-vcenter-password "${VCENTER_PASSWORD}" \
2233
-vcenter-ca-certs "${ca_cert_file}" \
23-
-vm-inventory-path "${VCENTER_VM_FOLDER}/${STEMBUILD_BASE_VM_NAME}" \
24-
-vm-ip "${STEMBUILD_BASE_VM_IP}" \
25-
-vm-username "${STEMBUILD_BASE_VM_USERNAME}" \
26-
-vm-password "${STEMBUILD_BASE_VM_PASSWORD}" \
34+
-vm-inventory-path "${VM_NAME}" \
35+
-vm-ip "${VM_IP}" \
36+
-vm-username "${STEMBUILD_BASE_VM_USERNAME}" \
37+
-vm-password "${STEMBUILD_BASE_VM_PASSWORD}" \
2738
-setup-arg FailOnInstallWUCerts

ci/tasks/run-construct-stembuild-linux/task.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ run:
1010
path: bosh-windows-stemcell-builder-ci/ci/tasks/run-construct-stembuild-linux/run.sh
1111

1212
params:
13+
GOVC_URL:
1314
VCENTER_BASE_URL:
1415
VCENTER_USERNAME:
1516
VCENTER_PASSWORD:
1617
VCENTER_VM_FOLDER:
1718
STEMBUILD_BASE_VM_NAME:
18-
STEMBUILD_BASE_VM_IP:
1919
STEMBUILD_BASE_VM_USERNAME:
2020
STEMBUILD_BASE_VM_PASSWORD:

ci/tasks/setup-integration-test-vm/run.sh

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ export GOVC_URL="${VCENTER_ADMIN_CREDENTIAL_URL}"
66
ROOT_DIR=$(pwd)
77
export OUTPUT_DIR=${ROOT_DIR}/output
88

9-
VM_IP=$(cat nimbus-ips/name)
9+
CLONE_NAME_PREFIX="construct-${JOB_OS_NAME}-integration-ci-${OS_LINE}"
10+
CLONE_NAME_SUFFIX=$(mktemp -u XXXXXX)
11+
CLONE_NAME="${CLONE_NAME_PREFIX}-${CLONE_NAME_SUFFIX}"
12+
13+
export CLONE_NAME_PREFIX
14+
export CLONE_NAME_SUFFIX
15+
export CLONE_NAME
1016

11-
CLONE_NAME="stembuild-${JOB_OS_NAME}-${OS_LINE}-${VM_IP}"
1217
echo "${CLONE_NAME}" > integration-vm-name/name
18+
echo "Creating VM ${CLONE_NAME}"
1319

14-
echo "Cloning ${BASE_VM_IPATH} to ${CLONE_NAME}"
1520
govc vm.clone \
1621
-vm "${BASE_VM_IPATH}" \
1722
-ds "${CLONE_DATASTORE}" \
@@ -22,29 +27,41 @@ govc vm.clone \
2227
echo "Customizing ${CLONE_NAME}"
2328
govc vm.customize \
2429
-vm.ipath "${CLONE_FOLDER}"/"${CLONE_NAME}" \
25-
-ip "${VM_IP}" \
2630
-org "${VM_ORG_NAME}" \
2731
-username "${VM_USERNAME}" \
2832
"${VM_CUSTOMIZATION_NAME}"
2933

3034
govc vm.power -on \
3135
-vm.ipath "${CLONE_FOLDER}"/"${CLONE_NAME}"
3236

33-
echo "Waiting 10 min for ${CLONE_NAME} to be configured with ${VM_IP}"
37+
echo "Waiting for VM to be configured with IP address..."
3438
SECONDS=0
3539
FOUND_IP_ADDRESS=
3640

37-
while [ "${VM_IP}" != "${FOUND_IP_ADDRESS}" ]; do
38-
sleep 10
39-
VM_INFO=$(govc vm.info -json "${CLONE_FOLDER}"/"${CLONE_NAME}")
40-
41-
FOUND_IP_ADDRESS=$(echo "${VM_INFO}" |
42-
jq -r ".virtualMachines[0].guest.net[0].ipAddress | .[]? |select(. == \"${VM_IP}\")")
41+
while [ -z "$FOUND_IP_ADDRESS" ] || [ "$FOUND_IP_ADDRESS" == "null" ]; do
42+
VM_INFO=$(govc vm.info -json "${CLONE_FOLDER}"/"${CLONE_NAME}")
43+
FOUND_IP_ADDRESS=$(echo "${VM_INFO}" | jq -r '.virtualMachines[0].guest.ipAddress')
4344

4445
echo "Current IP Addresses:"
45-
echo "${VM_INFO}" | jq -r ".virtualMachines[0].guest.net[0].ipAddress | .[]?"
46+
echo "${VM_INFO}" | jq -r ".virtualMachines[0].guest.net[0].ipAddress | .[]?"
47+
48+
if [ ${SECONDS} -gt 600 ] ; then
49+
exit 1
50+
fi
51+
sleep 10
52+
done
4653

47-
if [ ${SECONDS} -gt 600 ] ; then
48-
exit 1
49-
fi
54+
echo "Waiting for VM guest customization to complete..."
55+
SECONDS=0
56+
GUEST_CUSTOMIZATION_STATUS=
57+
58+
while [ "$GUEST_CUSTOMIZATION_STATUS" != "TOOLSDEPLOYPKG_SUCCEEDED" ]; do
59+
GUEST_CUSTOMIZATION_STATUS=$(govc vm.info -json "${CLONE_FOLDER}"/"${CLONE_NAME}" | jq -r '.virtualMachines[0].guest.customizationInfo.customizationStatus')
60+
61+
if [ ${SECONDS} -gt 600 ] ; then
62+
exit 1
63+
fi
64+
sleep 30
5065
done
66+
67+
echo "Integration VM setup complete"

ci/tasks/setup-integration-test-vm/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ platform: linux
33

44
inputs:
55
- name: bosh-windows-stemcell-builder-ci
6-
- name: nimbus-ips
76

87
outputs:
98
- name: integration-vm-name

ci/tasks/test-integration-stembuild-linux/run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ chmod +x "${ROOT_DIR}/ovftool/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle"
1616
"${ROOT_DIR}/ovftool/VMware-ovftool-4.2.0-5965791-lin.x86_64.bundle" --eulas-agreed --required
1717

1818
export TARGET_VM_IP
19-
TARGET_VM_IP=$(cat nimbus-ips/name)
2019
export VM_NAME
2120
VM_NAME=$(cat integration-vm-name/name)
2221
echo "Using VM @ IPAddr: ${VM_NAME}@${TARGET_VM_IP}"

ci/tasks/test-integration-stembuild-linux/task.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ inputs:
66
- name: stemcell-builder
77
- name: version
88
- name: ovftool
9-
- name: nimbus-ips
109
- name: integration-vm-name
1110

1211
run:
@@ -26,3 +25,4 @@ params:
2625
PACKAGE_TEST_BASE_VM_NAME:
2726
OS_LINE:
2827
SKIP_CLEANUP: false
28+
TARGET_VM_IP:

ci/tasks/test-integration-stembuild-windows/run.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ $env:TEMP=$TMP_DIR
2222
$env:SystemTemp=$TMP_DIR
2323

2424
$env:VM_NAME= cat $ROOT_DIR/integration-vm-name/name
25-
$env:TARGET_VM_IP = cat $ROOT_DIR/nimbus-ips/name
2625
$env:STEMBUILD_VERSION = cat $ROOT_DIR/version/version
2726

2827
$vcenterCertPath="$TMP_DIR\vcenter_ca.crt"

0 commit comments

Comments
 (0)