diff --git a/vhdbuilder/packer/vhd-image-builder-arm64-gen2.json b/vhdbuilder/packer/vhd-image-builder-arm64-gen2.json index 5dec6d90490..f352264b62a 100644 --- a/vhdbuilder/packer/vhd-image-builder-arm64-gen2.json +++ b/vhdbuilder/packer/vhd-image-builder-arm64-gen2.json @@ -61,6 +61,44 @@ } ], "provisioners": [ + { + "type": "shell", + "inline": [ + "PACKER_HOSTNAME=$(hostname)", + "echo The value of PACKER_HOSTNAME is $PACKER_HOSTNAME", + "echo $PACKER_HOSTNAME > /tmp/hostname.txt" + ] + }, + { + "type": "file", + "source": "/tmp/hostname.txt", + "destination": "/tmp/hostname.txt", + "direction": "download" + }, + { + "type": "shell-local", + "inline": [ + "PACKER_HOSTNAME=$(cat /tmp/hostname.txt)", + + "nic=$(echo $PACKER_HOSTNAME | sed 's/vm/ni/')", + + "temp_pkr_rg_name=\"pkr-Resource-Group-$(echo $PACKER_HOSTNAME | awk '{gsub(\"pkrvm\",\"\"); print}')\"", + + "az network nic update -g ${temp_pkr_rg_name} -n ${nic} --accelerated-networking true" + ] + }, + { + "type": "shell-local", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, + { + "type": "shell", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, { "type": "shell", "inline": [ diff --git a/vhdbuilder/packer/vhd-image-builder-base.json b/vhdbuilder/packer/vhd-image-builder-base.json index 8849308e0aa..6cf7001962c 100644 --- a/vhdbuilder/packer/vhd-image-builder-base.json +++ b/vhdbuilder/packer/vhd-image-builder-base.json @@ -71,6 +71,44 @@ } ], "provisioners": [ + { + "type": "shell", + "inline": [ + "PACKER_HOSTNAME=$(hostname)", + "echo The value of PACKER_HOSTNAME is $PACKER_HOSTNAME", + "echo $PACKER_HOSTNAME > /tmp/hostname.txt" + ] + }, + { + "type": "file", + "source": "/tmp/hostname.txt", + "destination": "/tmp/hostname.txt", + "direction": "download" + }, + { + "type": "shell-local", + "inline": [ + "PACKER_HOSTNAME=$(cat /tmp/hostname.txt)", + + "nic=$(echo $PACKER_HOSTNAME | sed 's/vm/ni/')", + + "temp_pkr_rg_name=\"pkr-Resource-Group-$(echo $PACKER_HOSTNAME | awk '{gsub(\"pkrvm\",\"\"); print}')\"", + + "az network nic update -g ${temp_pkr_rg_name} -n ${nic} --accelerated-networking true" + ] + }, + { + "type": "shell-local", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, + { + "type": "shell", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, { "type": "shell", "inline": [ diff --git a/vhdbuilder/packer/vhd-image-builder-mariner-arm64.json b/vhdbuilder/packer/vhd-image-builder-mariner-arm64.json index f6a7f9e854f..0add6c0a214 100644 --- a/vhdbuilder/packer/vhd-image-builder-mariner-arm64.json +++ b/vhdbuilder/packer/vhd-image-builder-mariner-arm64.json @@ -64,6 +64,44 @@ } ], "provisioners": [ + { + "type": "shell", + "inline": [ + "PACKER_HOSTNAME=$(hostname)", + "echo The value of PACKER_HOSTNAME is $PACKER_HOSTNAME", + "echo $PACKER_HOSTNAME > /tmp/hostname.txt" + ] + }, + { + "type": "file", + "source": "/tmp/hostname.txt", + "destination": "/tmp/hostname.txt", + "direction": "download" + }, + { + "type": "shell-local", + "inline": [ + "PACKER_HOSTNAME=$(cat /tmp/hostname.txt)", + + "nic=$(echo $PACKER_HOSTNAME | sed 's/vm/ni/')", + + "temp_pkr_rg_name=\"pkr-Resource-Group-$(echo $PACKER_HOSTNAME | awk '{gsub(\"pkrvm\",\"\"); print}')\"", + + "az network nic update -g ${temp_pkr_rg_name} -n ${nic} --accelerated-networking true" + ] + }, + { + "type": "shell-local", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, + { + "type": "shell", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, { "type": "shell", "inline": [ diff --git a/vhdbuilder/packer/vhd-image-builder-mariner.json b/vhdbuilder/packer/vhd-image-builder-mariner.json index 21c3aab0a02..c9df6da76b4 100644 --- a/vhdbuilder/packer/vhd-image-builder-mariner.json +++ b/vhdbuilder/packer/vhd-image-builder-mariner.json @@ -71,6 +71,44 @@ } ], "provisioners": [ + { + "type": "shell", + "inline": [ + "PACKER_HOSTNAME=$(hostname)", + "echo The value of PACKER_HOSTNAME is $PACKER_HOSTNAME", + "echo $PACKER_HOSTNAME > /tmp/hostname.txt" + ] + }, + { + "type": "file", + "source": "/tmp/hostname.txt", + "destination": "/tmp/hostname.txt", + "direction": "download" + }, + { + "type": "shell-local", + "inline": [ + "PACKER_HOSTNAME=$(cat /tmp/hostname.txt)", + + "nic=$(echo $PACKER_HOSTNAME | sed 's/vm/ni/')", + + "temp_pkr_rg_name=\"pkr-Resource-Group-$(echo $PACKER_HOSTNAME | awk '{gsub(\"pkrvm\",\"\"); print}')\"", + + "az network nic update -g ${temp_pkr_rg_name} -n ${nic} --accelerated-networking true" + ] + }, + { + "type": "shell-local", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, + { + "type": "shell", + "inline": [ + "rm /tmp/hostname.txt" + ] + }, { "type": "shell", "inline": [