2021-01-24 08:26:53 +00:00
|
|
|
kind: pipeline
|
|
|
|
type: kubernetes
|
|
|
|
name: 'Packer Build'
|
2023-01-18 14:09:32 +00:00
|
|
|
|
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:
|
2021-06-05 17:34:31 +00:00
|
|
|
- name: Debugging information
|
|
|
|
image: bv11-cr01.bessems.eu/library/packer-extended
|
|
|
|
commands:
|
2021-06-07 11:19:00 +00:00
|
|
|
- ansible --version
|
2021-06-05 17:34:31 +00:00
|
|
|
- ovftool --version
|
2022-06-27 07:54:57 +00:00
|
|
|
- packer --version
|
|
|
|
- yamllint --version
|
2022-06-24 21:55:54 +00:00
|
|
|
- name: Kubernetes Bootstrap Appliance
|
2021-01-24 08:26:53 +00:00
|
|
|
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:
|
|
|
|
- |
|
2021-06-07 11:19:00 +00:00
|
|
|
sed -i -e "s/<<img-password>>/$${SSH_PASSWORD}/g" \
|
2022-06-22 09:40:25 +00:00
|
|
|
packer/preseed/UbuntuServer22.04/user-data
|
2021-04-10 13:32:31 +00:00
|
|
|
- |
|
2021-06-08 19:56:06 +00:00
|
|
|
yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \
|
|
|
|
ansible \
|
2022-06-22 09:40:25 +00:00
|
|
|
packer/preseed/UbuntuServer22.04/user-data \
|
2021-06-08 19:56:06 +00:00
|
|
|
scripts
|
2022-06-24 23:08:11 +00:00
|
|
|
- |
|
|
|
|
ansible-galaxy install \
|
|
|
|
-r ansible/requirements.yml
|
2021-06-05 17:34:31 +00:00
|
|
|
- |
|
|
|
|
packer init -upgrade \
|
|
|
|
./packer
|
2021-01-24 08:26:53 +00:00
|
|
|
- |
|
|
|
|
packer validate \
|
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 repo_username=$${REPO_USERNAME} \
|
|
|
|
-var repo_password=$${REPO_PASSWORD} \
|
|
|
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
2021-06-07 11:29:22 +00:00
|
|
|
-var ssh_password=$${SSH_PASSWORD} \
|
2021-06-05 17:34:31 +00:00
|
|
|
./packer
|
2021-01-24 08:26:53 +00:00
|
|
|
- |
|
|
|
|
packer build \
|
2021-06-07 13:31:46 +00:00
|
|
|
-on-error=cleanup -timestamp-ui \
|
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 repo_username=$${REPO_USERNAME} \
|
|
|
|
-var repo_password=$${REPO_PASSWORD} \
|
|
|
|
-var vsphere_password=$${VSPHERE_PASSWORD} \
|
2021-06-07 11:29:22 +00:00
|
|
|
-var ssh_password=$${SSH_PASSWORD} \
|
2021-06-05 17:34:31 +00:00
|
|
|
./packer
|
2021-01-24 08:26:53 +00:00
|
|
|
environment:
|
|
|
|
VSPHERE_PASSWORD:
|
|
|
|
from_secret: vsphere_password
|
2021-06-07 11:19:00 +00:00
|
|
|
SSH_PASSWORD:
|
|
|
|
from_secret: ssh_password
|
2021-01-24 08:26:53 +00:00
|
|
|
REPO_USERNAME:
|
|
|
|
from_secret: repo_username
|
|
|
|
REPO_PASSWORD:
|
|
|
|
from_secret: repo_password
|
|
|
|
# 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
|