You’re probably in the install image which hasn’t been chrooted into.
You see, when AlmaLinux 9 does it’s install from ISO, it formats the disk and mounts it to /mnt/sysroot and then copies files to it. Once it’s done, the rest of the packer scripts can be run… but commands are run in the install environment, not the chroot container, so, to transfer files in, or to execute commands that will have actions in the target environment, format them like this:
provisioner "file" {
source = "my_command"
destination = "/mnt/sysroot/tmp/my_command"
}
provisioner "shell" {
inline = [
"chmod +x /mnt/sysroot/tmp/my_command",
"chroot /mnt/sysroot /tmp/my_command",
"chroot /mnt/sysroot systemctl enable some.service"
]
}
In this example, we copy a file called “my_command” to the /tmp directory, mark it as executable and run it from inside the chroot environment.
Next we run systemctl
to enable a service that is already present on the system (perhaps it was something that my_command did?)
I hope this helps you!
Featured image is “Repository Road” by “David” on Flickr and is released under a CC-BY-SA license.
You are missing the closing double quote on the source line…
Good spot Stuart! Sorted!!