Skip to content

Commit

Permalink
get VM_NAME from hcl instead of json in builder/build-image.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-luna-valero committed Aug 28, 2024
1 parent 6f1bb24 commit cb68e45
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions builder/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ packer plugins install github.com/hashicorp/ansible
# do the build
if tools/build.sh "$IMAGE" >/var/log/image-build.log 2>&1; then
# compress the resulting image
VM_NAME="$(jq -r ".builders[].vm_name" < "$IMAGE")"
QEMU_SOURCE_ID=$(hcl2tojson "$IMAGE" | jq -r '.source[0].qemu | keys[]')
VM_NAME=$(hcl2tojson "$IMAGE" | jq -r '.source[0].qemu.'"$QEMU_SOURCE_ID"'.vm_name')
QCOW_FILE="$VM_NAME.qcow2"
builder/refresh.sh vo.access.egi.eu "$(cat /var/tmp/egi/.refresh_token)" images
OS_TOKEN="$(yq -r '.clouds.images.auth.token' /etc/openstack/clouds.yaml)"
OUTPUT_DIR=$(hcl2tojson "$IMAGE" | jq -r '.source[0].qemu | keys[]')
OUTPUT_DIR="$(dirname "$IMAGE")/output-$OUTPUT_DIR"
OUTPUT_DIR="$(dirname "$IMAGE")/output-$QEMU_SOURCE_ID"
cd "$OUTPUT_DIR"
qemu-img convert -O qcow2 -c "$VM_NAME" "$QCOW_FILE"
openstack --os-cloud images --os-token "$OS_TOKEN" \
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/datahub-jupyter-ubuntu-22.04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "SSH_PUB_KEY" {
default = ""
}

source "qemu" "datahub-jupyter-ubuntu-22-04" {
source "qemu" "datahub_jupyter_ubuntu_22_04" {
boot_command = [
"c<wait>",
"linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\"",
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/docker-ubuntu-22.04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "SSH_PUB_KEY" {
default = ""
}

source "qemu" "docker-ubuntu-22-04" {
source "qemu" "docker_ubuntu_22_04" {
boot_command = [
"c<wait>",
"linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\"",
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/small-ubuntu-20.04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "SSH_PUB_KEY" {
default = ""
}

source "qemu" "small-ubuntu-20-04" {
source "qemu" "small_ubuntu_20_04" {
boot_command = [
"<enter><enter><f6><esc><wait>",
"<bs><bs><bs><bs><bs><bs><bs><bs>",
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/ubuntu-20.04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "SSH_PUB_KEY" {
default = ""
}

source "qemu" "ubuntu-20-04" {
source "qemu" "ubuntu_20_04" {
boot_command = [
"<enter><enter><f6><esc><wait>",
"<bs><bs><bs><bs><bs><bs><bs><bs>",
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/ubuntu-22.04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "SSH_PUB_KEY" {
default = ""
}

source "qemu" "ubuntu-22-04" {
source "qemu" "ubuntu_22_04" {
boot_command = [
"c<wait>",
"linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\"",
Expand Down
2 changes: 1 addition & 1 deletion ubuntu/ubuntu-24.04.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "SSH_PUB_KEY" {
default = ""
}

source "qemu" "ubuntu-24-04" {
source "qemu" "ubuntu_24_4" {
boot_command = [
"c<wait>",
"linux /casper/vmlinuz --- autoinstall ds=\"nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\"",
Expand Down

0 comments on commit cb68e45

Please sign in to comment.