Packer.Images/.drone.yml

101 lines
2.7 KiB
YAML
Raw Normal View History

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
steps:
- name: Debugging information
image: bv11-cr01.bessems.eu/library/packer-extended
commands:
2021-06-07 11:19:00 +00:00
- ansible --version
- ovftool --version
2022-06-27 07:54:57 +00:00
- packer --version
- yamllint --version
- name: Kubernetes Bootstrap Appliance
image: bv11-cr01.bessems.eu/library/packer-extended
2021-04-10 13:34:04 +00:00
pull: always
commands:
- |
2021-06-07 11:19:00 +00:00
sed -i -e "s/<<img-password>>/$${SSH_PASSWORD}/g" \
packer/preseed/UbuntuServer22.04/user-data
- |
export K8S_VERSION=$(yq '.components.clusterapi.workload.version.k8s' < ./ansible/vars/metacluster.yml)
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 \
packer/preseed/UbuntuServer22.04/user-data \
2021-06-08 19:56:06 +00:00
scripts
- |
ansible-galaxy install \
-r ansible/requirements.yml
- |
packer init -upgrade \
./packer
- |
packer validate \
2021-04-10 13:32:31 +00:00
-var vm_name=$DRONE_BUILD_NUMBER-${DRONE_COMMIT_SHA:0:10} \
2023-03-09 11:45:51 +00:00
-var docker_username=$${DOCKER_USERNAME} \
-var docker_password=$${DOCKER_PASSWORD} \
-var repo_username=$${REPO_USERNAME} \
-var repo_password=$${REPO_PASSWORD} \
2021-06-07 11:29:22 +00:00
-var ssh_password=$${SSH_PASSWORD} \
2023-03-09 11:45:51 +00:00
-var vsphere_password=$${VSPHERE_PASSWORD} \
-var k8s_version=$K8S_VERSION
./packer
- |
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} \
2023-03-09 11:45:51 +00:00
-var docker_username=$${DOCKER_USERNAME} \
-var docker_password=$${DOCKER_PASSWORD} \
-var repo_username=$${REPO_USERNAME} \
-var repo_password=$${REPO_PASSWORD} \
2021-06-07 11:29:22 +00:00
-var ssh_password=$${SSH_PASSWORD} \
2023-03-09 11:45:51 +00:00
-var vsphere_password=$${VSPHERE_PASSWORD} \
./packer
environment:
2023-03-09 11:45:51 +00:00
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
# PACKER_LOG: 1
REPO_USERNAME:
from_secret: repo_username
REPO_PASSWORD:
from_secret: repo_password
2023-03-09 11:45:51 +00:00
SSH_PASSWORD:
from_secret: ssh_password
VSPHERE_PASSWORD:
from_secret: vsphere_password
volumes:
- name: output
path: /output
- name: scratch
path: /scratch
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