Hi,
Been tasked with cleaning up packer code to remove duplication of explicit
values in our working build .json files - and use a few general *var-files*
that will contain the relevant DEV, TEST and PROD instance types, vpc
details, disk sizes etc.
One of the builders sections we use are *tags *(and *run_tags*) of the
format:
"run_tags": {
"Environment": "DEV",
"Application": "Dave",
"Tier": "Web App",
"Function": "Dev Dave Web App",
"Version": "1.0",
"CostCentre": "0300 3246",
"BusinessUnit": "AppServices",
"Project": "DaveMigration to AWS",
"Product": "IIS Server for Dave",
"SupportEmail": "[email protected]",
"ComplianceDomain": "YES",
"DataClass": "5",
"ProvisionedBy": "Packer",
"ProvisionedWho": "[email protected]",
"ProjectName": "Dave",
"Name": "Dave Dev Web Box"
},
I'm not sure if or how I can include these arrays in a var-file. Ideally
the build file wants to refer to these as some kind of user variable e.g.
in line with the usual ones:
"builders": [{
"type": "amazon-ebs",
"region": "{{ user `DEV_server_region`}}",
"source_ami": "{{ user `DEV_server_source_ami`}}",
* "tags": "{{ user `DEV_dave_tags`}}", <== WHATEVER
FORMAT THIS SHOULD BE IN FOR A TAG BLOCK (Array?)*
"instance_type": "{{ user `DEV_server_instance_type`}}",
"winrm_use_ssl": true,
"winrm_insecure": true
}],
I've tried to capture these tag arrays in the var-file as so (snippet):
...
"PROD_server_user_data_file": "./USERDATA2.0.txt",
"CA_server_run_tags": [{
"Environment": "DEV",
"Application": "Dave",
"Tier": "Web App",
"Function": "Dev Dave Web App",
"Version": "1.0",
"CostCentre": "0300 3246",
"BusinessUnit": "AppServices",
"Project": "DaveMigration to AWS",
"Product": "IIS Server for Dave",
"SupportEmail": "[email protected]",
"ComplianceDomain": "YES",
"DataClass": "5",
"ProvisionedBy": "Packer",
"ProvisionedWho": "[email protected]",
"ProjectName": "Dave",
"Name": "Dave Dev Web Box"
}]
But I get:
packer validate -var-file .\dave_vars.json .\build_var_test_Dave.json
invalid value ".\\dave_vars.json" for flag -var-file: Error reading
variables in '.\dave_vars.json': json: cannot unmarshal array into Go value
of type string
Can someone please advise on how best to include (if possible) these tags
and run_tags arrays into the var-file *and* refer to the resulting user
array variable properly in the builder file?
Thanks,
Jimster
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/8975abcb-e431-4005-8e76-b40f6b048e8f%40googlegroups.com.