Automate your VM Images with Packer and Azure DevOps Pipeline

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ส.ค. 2024
  • EPISODE 14
    Build an Azure DevOps Pipeline that builds an Azure Virtual Machine Image using the Shared Image Gallery we provisioned last episode.
    Source Code:
    github.com/mar...
    Follow me on Twitter for quick code snippets and thoughts on Cloud, Automation and other things!
    / marktinderholt
    Keep the knowledge flowing!
    www.buymeacoff...

ความคิดเห็น • 26

  • @azdanov
    @azdanov ปีที่แล้ว +1

    Dynamic image versioning is very cool. I had to do it manually for common libraries at previous work, and there were times where you pushed a wrong version number... That wasn't fun.

  • @rajulros
    @rajulros 11 หลายเดือนก่อน +1

    Thank you Mark for this video. It was very helpful.
    However, I am facing issues with winrm connections. Pipeline fails with winrm timeout. Packer VM is not accepting winrm connections when we specify the vnet and subnet names

    • @azure-terraformer
      @azure-terraformer  11 หลายเดือนก่อน

      WinRM is always a bit weird isn’t it? Have you checked your NSGs on your existing VNet for the WinRM ports being opened?

  • @marsamuk
    @marsamuk ปีที่แล้ว +1

    Hi. I’m trying to follow and do the lab 😊. Where are you defining the variable values? Thanks

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว

      Sorry about that! I just posted the code for this episode. Hopefully that should help. Check out the video description for the link to my GitHub.
      Packer input variables are defined in a file called "variables.pkr.hcl". Terraform input variables are defined in a file called "variables.tf".

  • @0ccccccccc
    @0ccccccccc 4 หลายเดือนก่อน +1

    Hi thank you very much for uploading such a wonderful video serials, I learned a lot! I tried all the procedures in your video, but I got an error message from Azure DevOps, saying that "packer: command not found". I think this is because I used a self hosted agent, and on this agent packer is not installed. If I use a azure hosted agent, do I still need to install Packer? And I tried to run packer build through my local computer, got another error saying that the shared image is not found. I guess it is because I didn't deploy an image version through terraform before I call "packer build". But I noticed that you also didn't deploy any versions to the shared image before you call packer build (you only deployed shared image gallery and an empty shared image "Ubuntu-baseline"), but your code is working.... Do you have any idea how this happens? Thank you in advance!🙂

    • @azure-terraformer
      @azure-terraformer  4 หลายเดือนก่อน

      Thanks for the kind words. I’m glad you found it useful! It sounds like your Azure DevOps build agent doesn’t have Packer installed. You might want to install it yourself or use a marketplace task to do so.
      If you’re still having trouble hop on our discord server and Post in the channel dedicated to Packer.

    • @0ccccccccc
      @0ccccccccc 4 หลายเดือนก่อน +1

      @@azure-terraformer Thank you so much for the quick reply!!! By saying marketplace task, do you mean the extension and I should install packer extension? Sorry, I'm totally new to Azure DevOps. 😅
      And about the error I posted before about not finding correct image, I have already found out the reason. I used the SKU, publisher etc. which I made up, from the destination image. That's wrong, since I should use the identifiers from a real Azure VM Image. Now I understand why you said that packer doesn't build the image, but only build a new version😃

    • @azure-terraformer
      @azure-terraformer  4 หลายเดือนก่อน

      @0ccccccccc glad you got it sorted!

    • @0ccccccccc
      @0ccccccccc 4 หลายเดือนก่อน

      @@azure-terraformer Oh there's another question about your episodes in this video playlist. I want to see all the videos, so that I can follow the full instructions. But when I open the playlist, I can only see a few of them, for example the first video in the playlist is the episode 8, and second is 12... Do you know why is it like that? And how can I see the complete playlist? Thank you again for your patience!

  • @marsamuk
    @marsamuk ปีที่แล้ว +1

    Hi. Is it possible to use a single template packer file to build multiple OS images like Windows, Ubuntu, and RHEL? If so, what would be the recommended approach to achieve this? Thank you!

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว +1

      Good question. But I think that would not be a great idea. First windows and Linux vastly differ in how you script them to setup. Even Linux distributions differ between using apt or yum. You can use something like ansible to rationalize Linux distros to a certain extent but not for windows and Linux. You can use the same builder configuration. But the provisioners will differ so radically it wouldn't make sense.

  • @misterc3835
    @misterc3835 7 หลายเดือนก่อน +1

    Even I added variables created in the previous video (th-cam.com/video/dWV4APYdSAg/w-d-xo.html), add SP role on subscription and added azure required plugin , I still have an issues:
    Build 'azure-arm.vm' errored after 440 milliseconds 558 microseconds: the Shared Gallery Image 'VMimagesDev' to which to publish the managed image version to does not exist in the resource group 'test1' or does not contain managed image '2023.12.12'
    Any idea what is missing? (The gallery image name and resource group are fine)

    • @misterc3835
      @misterc3835 7 หลายเดือนก่อน +1

      I fixed the missing imageName var in the pipeline and everything is fine.

    • @azure-terraformer
      @azure-terraformer  7 หลายเดือนก่อน

      It looks like you solved this but from the error you received it sounds more like the Resource Group name was wrong or something. It can be frustrating when the error messages are pretty unhelpful!

    • @azure-terraformer
      @azure-terraformer  7 หลายเดือนก่อน

      Glad you got it figured out!

  • @marsamuk
    @marsamuk ปีที่แล้ว +1

    Hi. What do I need to change if I’m running your code in my ADO? Also what’s the need for declaring IP address? I thought packer will create an IP and other requirements? Thanks

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว +1

      You need to setup a variable group with the credentials for your service principal. Your SP has to have contributor access to your sub so that packer can create a resource group and all the things. The up address is YOUR IP address. You could make it public but not super great from a security stand point so I at least specify a whitelisted IP, this will tell packer to setup an NSG and block anybody but you.

  • @marsamuk
    @marsamuk ปีที่แล้ว +1

    Have you done any Ansible automation using AzDO? I’m working on a project to automate Ansible Linux patching using AzDO. Thanks

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว +1

      Yes. This is in the works.

    • @marsamuk
      @marsamuk ปีที่แล้ว +1

      @@azure-terraformer love your content. Looking forward for it.

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว

      Thank you!!!

  • @marsamuk
    @marsamuk ปีที่แล้ว +1

    Hi. Why do we need terraform? Can’t we just use packer and Azure DevOps automate packer builds? Thanks

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว +1

      Packer and Terraform have distinct separation of responsibility. Packer automates how an individual virtual machine is setup and produces a virtual machine image as its output. Terraform automates the provisioning of a virtual machine by taking as its input that virtual machine image that packer produced as its output.

    • @marsamuk
      @marsamuk ปีที่แล้ว +1

      @@azure-terraformer sorry maybe I got confused. Thought this video was going through the process of automating packer build using AzDO and adding the image to shared image gallery. I’ll rewatch the video. Thanks

    • @azure-terraformer
      @azure-terraformer  ปีที่แล้ว +1

      Oh I see what you mean now. The Terraform in this episode is used to provision an Azure shared compute gallery which packer can use as a target for creating the images.