Issues with provisioning Azure Golden Image using Packer

Dear Team,

Good Day!

I’m also facing the below attached error while provisioning a Linux (CentOS) VM using Packer from a custom built image in Azure.

Please advise if you have any suggestions on my below query.

How I built the custom image?

  1. Created a Linux VM using CentOS7.7 Image chosen from Azure Marketplace.
  2. Deprovision it using the below command.
    waagent -deprovision+user
  3. Deallocated and Generalized it.
    Link referred for step2 & 3: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/capture-image
  4. Created a Image using that VM (Ex: Name - Centos-Custom-Image-v1)

I’m able to launch a new VM without any errors with that image from Azure Portal.

Now, I tried to create a Golden image (Ex: New-Centos-Golden-Image-v1) by installing necessary packages, dependencies, perform CIS benchmark standard practices in it by using “Packer” on “Centos-Custom-Image-v1”.

I created it without any errors by packer. While launching a new VM from that new golden image (built using packer), it is taking longer time for deploying (more than 30 min) before session timeout . And when I refresh the page after session timeout, it is showing the below attached error message though the VM created successfully.

Could you please guide me to correct my errors in the script if it needs modification to overcome this issue?

It would be much helpful. Attached the packer build script also for your [reference.](### url)

packer-image-build-azure.txt (1.9 KB)

Regards,
Guru Mohan

And I tried to take ssh connection to the VM created using our Packer thereby supplying the credentials provided while VM creation.
It is not at all accepting it and I even tried to break the root password, it didn’t work.
So, I suspect that the provisioning failure causes the VMs (created using the golden image) unusable.
Can someone please go through my Packer build script and let me know if any corrections to be made from my side?

Appreciate the quick response!

Regards,
Guru Mohan

We had some issues concerning CentOS the last days. Could you check the following threads and solutions/ workarounds?

The problem was that the sshd was not started and the configuration of sshd didn’t allow to connect using the root account.

Let’s give it a try.

Thank you Wolfsrudel!

I tried with including “ssh communicator” in the packer and included ansible roles to update “sshd_config” file with necessary parameters during provision.

Even still, the deployment is getting failed after progressing for around 30 to 35 mins. VM is created and unable to connect to it via ssh.

I’m here attaching the packer logs and updated packer build script also for your reference. Kindly review and share your suggestion.

Regards,
Guru Mohan azure-image-build-packer.txt (2.1 KB) packer3-latest.txt (367.2 KB)

Dear Wolfsrudel,

Please confirm if the below deprovision itself enough for creating azure image from packer.

Because, as per the steps (azure-cli) mentioned at microsoft site, we need to follow deprovision, deallocate, generalize and then proceed with image creation.

I tried with executing “waagent deprovision” inside the VM by including it in ansible role and thereby added the other steps like deallocate, generalize in packer main script (.json) file.
But still it ended up with az authentication errors. Could someone please help on this?

Regards,
Guru Mohan G

Unfortunately, I cannot help with a special image creation for Azure. I am currently only building images for vsphere.

Thanks Wolfsrudel!

Could someone have an experience in building custom Azure image using packer can guide me please?

Regards,
Guru Mohan