add version to packer output image

This commit is contained in:
Antoine 2021-01-13 00:38:15 +01:00
parent 0145797359
commit 3be44f6de9
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
4 changed files with 14 additions and 7 deletions

View File

@ -25,12 +25,13 @@ services:
- SOURCE_NAME=qemu.debian
- SSH_LIVE_USERNAME=debian
- SSH_LIVE_PASSWORD=debian
- ANSIBLE_EXTRA_VARS=generated_user=antoine generated_group=users debian_version=10.7.0
- IMAGE_VERSION=10.7.0
- ANSIBLE_EXTRA_VARS=generated_user=antoine generated_group=users
- ANSIBLE_PLAYBOOK=/packer/ansible/playbook-debian.yml
#- ISO_CHECKSUM=file:https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA512SUMS
- ISO_CHECKSUM=file:https://cdimage.debian.org/mirror/cdimage/archive/10.7.0/amd64/iso-cd/SHA512SUMS
#- ISO_URL=https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso
- ISO_URL=https://cdimage.debian.org/mirror/cdimage/archive/10.7.0/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso
- ISO_CHECKSUM=file:https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA512SUMS
#- ISO_CHECKSUM=file:https://cdimage.debian.org/mirror/cdimage/archive/10.7.0/amd64/iso-cd/SHA512SUMS
- ISO_URL=https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso
#- ISO_URL=https://cdimage.debian.org/mirror/cdimage/archive/10.7.0/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso
volumes:
- "./image/assets:/packer"
- "./image/cache:/packer-cache"

View File

@ -44,5 +44,5 @@ source "qemu" "debian" {
ssh_password = "${var.ssh_password}"
ssh_username = "${var.ssh_username}"
ssh_wait_timeout = "900m"
vm_name = "debian_packer.qcow2"
vm_name = "debian-${var.image_version}_packer.qcow2"
}

View File

@ -27,3 +27,8 @@ variable "ssh_username" {
type = string
default = ""
}
variable "image_version" {
type = string
default = "latest"
}

View File

@ -10,10 +10,11 @@ SSH_PUB=$(cat ./id_rsa_qemu.pub)
export PACKER_LOG=1; packer build --only="$SOURCE_NAME" \
-var ssh_username="$SSH_LIVE_USERNAME" \
-var ssh_password="$SSH_LIVE_PASSWORD" \
-var ansible_extra_vars="$ANSIBLE_EXTRA_VARS ssh_pub='$SSH_PUB'" \
-var ansible_extra_vars="$ANSIBLE_EXTRA_VARS ssh_pub='$SSH_PUB' image_version='$IMAGE_VERSION'" \
-var ansible_provisioning_playbook="$ANSIBLE_PLAYBOOK" \
-var iso_checksum="$ISO_CHECKSUM" \
-var iso_url="$ISO_URL" \
-var image_version="$IMAGE_VERSION" \
-on-error="ask" \
-force \
/packer/hcl/