Skip to content

Commit

Permalink
Merge pull request #9 from Ontotext-AD/fix_create_image_definition_sc…
Browse files Browse the repository at this point in the history
…ript

Removed features preventing build with Standard_B1ls VM
  • Loading branch information
viktor-ribchev authored Dec 13, 2023
2 parents 49b5f01 + c55eb79 commit 800221d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to the Packer template for creating GraphDB Azure VM images will be documented in this file.

## 1.2.0

- Removed features preventing build with Standard_B1ls VM
- Fixed create_image_definition.sh

## 1.1.0

- Installed Azure CLI
Expand Down
45 changes: 23 additions & 22 deletions create_image_definition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ variables_file="variables.pkrvars.hcl"

# Check if the file exists
if [ -f "$variables_file" ]; then
# Use grep to extract the variable values

image_definition_name=$(grep 'image_definition_name' "$variables_file" | cut -d '"' -f 2)
gdb_version=$(grep 'gdb_version' "$variables_file" | cut -d '"' -f 2)
gallery_resource_group=$(grep 'gallery_resource_group' "$variables_file" | cut -d '"' -f 2)
gallery_name=$(grep 'gallery_name' "$variables_file" | cut -d '"' -f 2)

# Check if any of the required variables is empty
if [ -z "$image_definition_name" ] || [ -z "$gdb_version" ] || [ -z "$gallery_resource_group" ] || [ -z "$gallery_name" ]; then
echo "One or more required variables are not defined in $variables_file."
exit 1
fi
# Construct the az sig image-definition create command
az_command="az sig image-definition create \
# Use grep to extract the variable values

image_definition_name=$(grep 'image_definition_name' "$variables_file" | cut -d '"' -f 2)
gdb_version=$(grep 'gdb_version' "$variables_file" | cut -d '"' -f 2)
gallery_resource_group=$(grep 'gallery_resource_group' "$variables_file" | cut -d '"' -f 2)
gallery_name=$(grep 'gallery_name' "$variables_file" | cut -d '"' -f 2)

# Check if any of the required variables is empty
if [ -z "$image_definition_name" ] || [ -z "$gdb_version" ] || [ -z "$gallery_resource_group" ] || [ -z "$gallery_name" ]; then
echo "One or more required variables are not defined in $variables_file."
exit 1
fi
# Construct the az sig image-definition create command

# TODO extend command with --features 'IsAcceleratedNetworkSupported=true DiskControllerTypes=SCSI,NVMe' when we have quota for Standard_B2pts_v2
az_command="az sig image-definition create \
-g $gallery_resource_group \
--gallery-name $gallery_name \
--gallery-image-definition "$image_definition_name" \
Expand All @@ -35,14 +37,13 @@ if [ -f "$variables_file" ]; then
--minimum-cpu-core 4 \
--maximum-cpu-core 64 \
--minimum-memory 4 \
--features 'IsAcceleratedNetworkSupported=true DiskControllerTypes=SCSI,NVMe' \
--maximum-memory 128 "
echo "Extracted variables and constructed Azure CLI command:"
eval "$az_command"
az sig image-definition wait -i "$image_name_x86_64" -r "$gallery_name" -g "$gallery_resource_group" --created
packer build -var-file="variables.pkrvars.hcl" .

echo "Extracted variables and constructed Azure CLI command:"
eval "$az_command"
az sig image-definition wait -i "$image_definition_name" -r "$gallery_name" -g "$gallery_resource_group" --created
packer build -var-file="variables.pkrvars.hcl" .
else
echo "The variables file $variables_file does not exist."
exit 1
echo "The variables file $variables_file does not exist."
exit 1
fi
24 changes: 20 additions & 4 deletions variables.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,68 +1,84 @@
variable subscription_id {
type = string
}

variable tenant_id {
type = string
}

variable client_id {
type = string
}

variable client_secret {
type = string
}

variable primary_location {
type = string
}

variable image_definition_name {
type = string
}
# Not supported yet
#variable image_name_arm64 {
# type = string
#}

variable gdb_version {
type = string
}

variable gallery_resource_group {
type = string
}

variable gallery_name {
type = string
}

variable my_ip_address {
type = string
}

variable replication_regions {
type = list(string)
}

variable os_type {
type = string
default = "Linux"
}

variable image_offer {
type = string
default = "0001-com-ubuntu-server-jammy"
}

variable image_publisher {
type = string
default = "canonical"
}

variable image_sku {
type = string
default = "22_04-lts-gen2"
}

variable vm_size {
type = string
default = "Standard_B1ls"
# TODO replace with B2pts_v2 when quota is available in order to build with IsAcceleratedNetworkSupported=true DiskControllerTypes=SCSI,NVMe features
# default = "Standard_B2pts_v2"
}

variable image_replica_count {
type = number
default = 1
}

variable shared_gallery_image_version_exclude_from_latest {
type = bool
default = false
}

variable os_disk_size_gb {
type = number
default = 30
Expand Down

0 comments on commit 800221d

Please sign in to comment.