Controlling with Ansible packer

I wanted to tell ansible with this script that the packer has to activate to generate a packer image file that then talks to proxmox via an API. Below is the ansible script I’m trying with:

  • name: Check and run Packer
    hosts: purple
    tasks:

  • name: Check if test.pkr.hcl exists
    stat:
    path: /home/oxana/packer/project/test.pkr.hcl
    register: file_status

  • name: Run Packer build if file exists
    command: packer build /home/oxana/packer/project/test.pkr.hcl
    when: file_status.stat.exists

Hi @willywortel-24 welcome to he bandwagon!

It is not very clear what you’re after with this. If you need help with packer I suggest you seek out for communities related to that tool.

As for the Ansible part, I would suggest you post this on the “Get Help” category, if that’s what you’re after. Depending on what you are trying to do, this code is good, or it could be improved upon. Have you run it? Have you tested? Is there anything going wrong? All those things are important when you trying to get some help from the community.

Cheers