Unable to use remote exec to customize VM on proxmox

I recently encountered some problems when writing a script for Terrafrom automation.

In my case VM is using proxmox platform, not cloud platform
So I use Telmate/proxmox as my mod for creating VMs

The VM builds smoothly, but when I want to customize the VM, there are some problems

There is an inline usage in terraform’s remote exec Provisioner
According to the official documentation, this usage applies to line-by-line instructions

I followed this step and used it on my Provision script, the script did execute normally, and it also spawned the VM and executed the installation script.

But the most important service is not up, but when I start the command in the script via SSH to the VM, the service is normal. That is, this cannot be achieved through terraform’s remote exec

So I want to ask if terraform is not suitable for customizing some services, such as web server, etc.? Only suitable for generating some resources such as VM?

And another custom script needs to be done using such as ansbile?

I would avoid using remove-exec unless you have no other option available.

Take a look at cloud-init
https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/resources/vm_qemu#provision-through-cloud-init

https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/guides/cloud_init

Normally you can use it to bootstrap another process like Ansible, Chef or Salt etc.

I found a way to understand this matter later, I am not sure if there is a problem with the program written by the developer or other reasons. Anyway, I can’t enable the service (process) via script. But it is possible to enable the service by rebooting and using the built-in system service (systemctl).

As for using ansible or cloud-init, although it is feasible, considering the current product version, I must use the original centos7 iso file to build to ensure that when the new version of the product is released, it can be deployed in the customer’s environment ( Considering customers who do not use cloud init and container)

Use packer to take the ISO and build a gold image with cloud-int installed to use with terraform.