Hello,
I think i’ve hit the wall with a Packer error.
I’ve tried to google and figure it out by my self, but in the end I cannot find any answers.
I have a folder: Templates where I store the following files:
- win2025.pkr.hcl
- variables.pkr.hcl
- variables.pkrvars.hcl
Outside this folder I have a bash-script where I run:
packer build -force \
-var-file=$TEMPLATES_DIR/variables.pkrvars.hcl \
$PACKER_TEMPLATE
Note: The variable: PACKER_TEMPLATE is defined earlier depending on what OS im choosing. So if I choose Windows Server 2025, the PACKER_TEMPLATE = win2025.pkr.hcl (if that makes sense)
But the thing is, I get this annoying error that the template wont use the variables written in the variables.pkrvars.hcl when im running packer build outside the template folder.
I’ve tried to run packer build in the commandline without the script, but I only get the following error:
This object does not have an attribute named "datastore".
Error: Unsupported
attribute
on /home/<username>/Packer-windows-test/template/win2025.pkr.hcl line 38:
(source code not avilable)
I get this on a few variables.
But if I run packer build INSIDE the template folder where all the variables and templates are saved, it works perfectly, and there is nothing wrong with the variables.
So im not sure what to do