2021-01-24 08:26:53 +00:00
|
|
|
kind: pipeline
|
|
|
|
type: kubernetes
|
|
|
|
name: 'Packer Build'
|
2021-04-10 13:32:31 +00:00
|
|
|
|
|
|
|
volumes:
|
|
|
|
- name: output
|
|
|
|
claim:
|
|
|
|
name: flexvolsmb-drone-output
|
|
|
|
- name: scratch
|
|
|
|
claim:
|
|
|
|
name: flexvolsmb-drone-scratch
|
2021-01-24 08:26:53 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Windows 10
|
|
|
|
image: bv11-cr01.bessems.eu/library/packer-extended
|
2021-04-10 13:34:04 +00:00
|
|
|
pull: always
|
2021-01-24 08:26:53 +00:00
|
|
|
commands:
|
|
|
|
- sed -i -e "s/<<img-productkey>>/$${PRODUCTKEY}/" packer/preseed/Windows10/Autounattend.xml
|
|
|
|
- |
|
|
|
|
sed -i -e "s/<<img-password>>/$${WINRM_PASSWORD}/g" \
|
|
|
|
packer/preseed/Windows10/Autounattend.xml \
|
|
|
|
packer/preseed/Windows10/Sysprep_Unattend.xml
|
2021-04-10 13:32:31 +00:00
|
|
|
- |
|
|
|
|
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" scripts
|
2021-01-24 08:26:53 +00:00
|
|
|
- |
|
|
|
|
packer validate \
|
|
|
|
-var-file=packer/variables.vsphere.json \
|
2021-04-10 13:32:31 +00:00
|
|
|
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
2021-01-24 08:26:53 +00:00
|
|
|
-var vm_guestos=win10 \
|
|
|
|
-var repo_username=$${REPO_USERNAME} \
|
|
|
|
-var repo_password=$${REPO_PASSWORD} \
|
|
|
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
|
|
|
-var winrm_password=$${WINRM_PASSWORD} \
|
|
|
|
packer/windows10.json \
|
|
|
|
- |
|
|
|
|
packer build \
|
|
|
|
-on-error=cleanup \
|
|
|
|
-var-file=packer/variables.vsphere.json \
|
2021-04-10 13:32:31 +00:00
|
|
|
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
2021-01-24 08:26:53 +00:00
|
|
|
-var vm_guestos=win10 \
|
|
|
|
-var repo_username=$${REPO_USERNAME} \
|
|
|
|
-var repo_password=$${REPO_PASSWORD} \
|
|
|
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
|
|
|
-var winrm_password=$${WINRM_PASSWORD} \
|
|
|
|
packer/windows10.json \
|
|
|
|
environment:
|
|
|
|
VSPHERE_PASSWORD:
|
|
|
|
from_secret: vsphere_password
|
|
|
|
WINRM_PASSWORD:
|
|
|
|
from_secret: winrm_password
|
|
|
|
REPO_USERNAME:
|
|
|
|
from_secret: repo_username
|
|
|
|
REPO_PASSWORD:
|
|
|
|
from_secret: repo_password
|
|
|
|
PRODUCTKEY:
|
|
|
|
from_secret: prodkey_win10
|
|
|
|
# PACKER_LOG: 1
|
|
|
|
volumes:
|
|
|
|
- name: output
|
|
|
|
path: /output
|
2021-04-10 13:32:31 +00:00
|
|
|
- name: Remove temporary resources
|
|
|
|
image: bv11-cr01.bessems.eu/library/packer-extended
|
|
|
|
commands:
|
|
|
|
- |
|
|
|
|
pwsh -file scripts/Remove-Resources.ps1 \
|
|
|
|
-VMName $DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
|
|
|
-VSphereFQDN 'bv11-vc.bessems.lan' \
|
|
|
|
-VSphereUsername 'administrator@vsphere.local' \
|
|
|
|
-VSpherePassword $${VSPHERE_PASSWORD}
|
|
|
|
environment:
|
|
|
|
VSPHERE_PASSWORD:
|
|
|
|
from_secret: vsphere_password
|
|
|
|
volumes:
|
|
|
|
- name: scratch
|
|
|
|
path: /scratch
|
|
|
|
when:
|
|
|
|
status:
|
|
|
|
- success
|
|
|
|
- failure
|