No, currently this is not supported. Only single values and arrays work. On Wed, Oct 16, 2019, 10:31 Jimster <james.jenn...@gmail.com> wrote:
> 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": "d...@dave.com", > "ComplianceDomain": "YES", > "DataClass": "5", > "ProvisionedBy": "Packer", > "ProvisionedWho": "d...@dave.com", > "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": "d...@dave.com", > "ComplianceDomain": "YES", > "DataClass": "5", > "ProvisionedBy": "Packer", > "ProvisionedWho": "d...@dave.com", > "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 packer-tool+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/packer-tool/8975abcb-e431-4005-8e76-b40f6b048e8f%40googlegroups.com > <https://groups.google.com/d/msgid/packer-tool/8975abcb-e431-4005-8e76-b40f6b048e8f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 packer-tool+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt-5-EBD%2Bhjv4jZbN3EJHaUxUuGwsF6nZ2jErDJ07vqa4A%40mail.gmail.com.