85 lines
2.3 KiB
YAML
85 lines
2.3 KiB
YAML
kind: pipeline
|
|
type: kubernetes
|
|
name: 'Packer Build'
|
|
|
|
volumes:
|
|
- name: output
|
|
claim:
|
|
name: flexvolsmb-drone-output
|
|
- name: scratch
|
|
claim:
|
|
name: flexvolsmb-drone-scratch
|
|
|
|
steps:
|
|
- name: Debugging information
|
|
image: bv11-cr01.bessems.eu/library/packer-extended
|
|
commands:
|
|
- yamllint --version
|
|
- packer --version
|
|
- ansible --version
|
|
- ovftool --version
|
|
- name: Ubuntu Server 20.04
|
|
image: bv11-cr01.bessems.eu/library/packer-extended
|
|
pull: always
|
|
commands:
|
|
- |
|
|
sed -i -e "s/<<img-password>>/$${SSH_PASSWORD}/g" \
|
|
packer/preseed/UbuntuServer20.04/user-data
|
|
- |
|
|
# yamllint -d "{extends: relaxed, rules: {line-length: disable}}" ansible packer/preseed/UbuntuServer20.04/user-data
|
|
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" packer/preseed/UbuntuServer20.04/user-data
|
|
- |
|
|
packer init -upgrade \
|
|
./packer
|
|
- |
|
|
packer validate \
|
|
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
|
-var vm_guestos=ubuntuserver20.04 \
|
|
-var repo_username=$${REPO_USERNAME} \
|
|
-var repo_password=$${REPO_PASSWORD} \
|
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
|
-var ssh_password=$${SSH_PASSWORD} \
|
|
./packer
|
|
- |
|
|
packer build \
|
|
-on-error=abort \
|
|
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
|
|
-var vm_guestos=ubuntuserver20.04 \
|
|
-var repo_username=$${REPO_USERNAME} \
|
|
-var repo_password=$${REPO_PASSWORD} \
|
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
|
-var ssh_password=$${SSH_PASSWORD} \
|
|
./packer
|
|
environment:
|
|
VSPHERE_PASSWORD:
|
|
from_secret: vsphere_password
|
|
SSH_PASSWORD:
|
|
from_secret: ssh_password
|
|
REPO_USERNAME:
|
|
from_secret: repo_username
|
|
REPO_PASSWORD:
|
|
from_secret: repo_password
|
|
# PACKER_LOG: 1
|
|
volumes:
|
|
- name: output
|
|
path: /output
|
|
- 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
|