Packer-Ansible Shuts down machine every time

Hi there,

currently I try to understand packer in combination with ansible a little bit better.
My goal is to create an automatically installed and configured homelab with the standard infrastructure (dc, subordinate pki, azure integration and so on).

I am making good progress. NNow I am standing in front of one of those design decisions, which are hard for me.

I am using ansible playbooks to prepare the basic packer vm images. They prepare some scripts, updates and systprep the machine. Then I shelf them and use terraform to prepare the real infra. Later ansible runs over the machines again and does the configuration / import tasks paired with final and regular updates rounds.
(Please do not overrate the tasks. All literally runs like garbage atm. A lot of optimization needs to be done).

From Terraform I learned that Terraform decides when create the ressources. I would like to have a serialized approach to packer provisioners for ensuring that I can have very modular ansible scripts.

I want to make sure that the machine would never be sysprepped before doing the other tasks.
I do not want to handle that in ansible, because I want to keep small and easy to understand scripts in my repos. Many of my tasks may run in a home lab, but I want to optimize towards enterprise networks to sharpen my brain-ish tool.

Question: How das packer handle provisioners?

Did I miss something the the docs, because it feels like it serializes. Maybe learning packer and Terraform at the same time explodes my brain. I think many of you faced such challenges already.

Thanks for your advice

Just an update - the shutdown itself could be solved by the on-error=ask parameter

I am still not sure about the execution order of provisioners in packer, thats why I chain things together in ansible and organize them in blocks and tasks.

This seems to work great. I did not trust the provisioners fully, thats why I feel better the sequential approach of ansible and I think its the correct tool to manage the order of configs.

Packer does a great job in building images and preparing infrastructure aspects of the configs.
Its an interesting journey and fun to learn. The direct feedback of the tools is great.