1. "execute_command": "{{.Vars}} sudo -E -S bash '{{.Path}' '{{user `arg1`}}' '{{user `arg2`}}' " Is this correct? I tried this but since i have lot of arguments to be passed it is less readable and error prone.
2.The problem i am facing is I have lot of variables to be passed as arguments and when I run as below: "execute_command": "{{.Vars}} sudo -E -S bash '{{.Path}' '{{user `arg1`}}' '{{user `arg2`}}' \n '{{user `arg3`}}' '{{user `arg4`}}' '{{user `arg5`}}' \n Failed to parse template: Error parsing JSON: invalid character '\n' in string literal. Could you please help how I can pass multiline arguments? " On Monday, March 5, 2018 at 9:43:16 PM UTC+8, Rickard von Essen wrote: > > arguments should be in the "execute_command" > > On 5 March 2018 at 14:38, Bubunia Patra <bubunia...@gmail.com > <javascript:>> wrote: > >> Packer version I am using 1.0.2. But the problem is that arguments are >> not ge >> >> tting passed to the provisioning script and all are null. I used the >> second method(hack ) that is described in below thread using "scripts" tag. >> >> https://groups.google.com/forum/#!topic/packer-tool/G2TKbBQOGcQ >> >> >> >> "provisioners": [ >> { >> "type": "shell", >> "execute_command": "{{.Vars}} sudo -E -S bash '{{.Path}} {{user >> `arg1`}} '", >> "inline": [ >> "{{user `provision_script`}} {{user `arg1`}} {{user >> `arg2`}}" >> >> >> ] >> } >> ] >> } >> >> >> >> >> >> On Monday, March 5, 2018 at 7:33:14 PM UTC+8, Bubunia Patra wrote: >> >>> Hi all, >>> >>> I want to pass some command arguments to the provisioning script in >>> packer for creating an AMI image. But I am getting "No such file or >>> directory". Can anyone help me in this regard? >>> I also having issue when I have multiline strings being passed to >>> packer. I checked the below thread and its somehow adding \n doesnt work. >>> >>> >>> https://stackoverflow.com/questions/16690101/can-a-json-value-contain-a-multiline-string >>> >>> Can anyone help me in this regard? >>> >>> Regards >>> Pradeep >>> >>> { >>> "variables": { >>> "aws_access_key": "{{env `PACKER_AWS_ACCESS_KEY`}}", >>> "aws_secret_key": "{{env `PACKER_AWS_SECRET_KEY`}}", >>> "aws_region": "{{env `PACKER_AWS_REGION`}}", >>> "prod_name": "abcd", >>> "image_name": "abc", >>> "version_number": "v1", >>> "ami_filter": "CentOS Linux 7 x86_64 HVM EBS >>> 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4", >>> "ssh_user_name": "centos", >>> "env_type": "test", >>> "provision_script": "/home/centos/packer/provision.sh", >>> "arg1" : "hello", >>> "arg2" : "world" >>> >>> "builders": [ >>> { >>> "name": "packer_eu_west_ebs", >>> "type": "amazon-ebs", >>> "access_key": "{{user `aws_access_key`}}", >>> "secret_key": "{{user `aws_secret_key`}}", >>> "region": "{{user `aws_region`}}", >>> "source_ami_filter": { >>> "filters": { >>> "name": "{{user `ami_filter`}}" >>> }, >>> "most_recent": true >>> }, >>> "instance_type": "t2.small" >>> } >>> ] >>> >>> >>> "provisioners": [ >>> { >>> "type": "shell", >>> "execute_command": "{{.Vars}} sudo -E -S bash '{{.Path}}'", >>> "inline": [ >>> "{{user `provision_script`}} {{user `arg1`}} >>> {{user `arg2`}}" >>> >>> >>> ] >>> } >>> ] >>> } >>> >>> >>> Error: >>> >>> >>> ==> packer_eu_west_ebs: Pausing after run of step >>> 'StepRunSourceInstance'. Press enter to continue. ==> packer_eu_west_ebs: >>> Pausing after run of step 'StepTagEBSVolumes'. Press enter to continue. ==> >>> packer_eu_west_ebs: Pausing after run of step 'StepGetPassword'. Press >>> enter to continue. >>> ==> packer_eu_west_ebs: Waiting for SSH to become available... >>> ==> packer_eu_west_ebs: Connected to SSH! >>> ==> packer_eu_west_ebs: Pausing after run of step 'StepConnect'. Press >>> enter to continue. >>> ==> packer_eu_west_ebs: Provisioning with shell script: >>> /tmp/packer-shell705621081 >>> packer_eu_west_ebs: /tmp/script_619.sh: line 2: >>> /home/centos/packer/provision.sh: No such file or directory >>> >> -- >> 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...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/packer-tool/c11d7166-8900-4b79-864d-1bcb3f254686%40googlegroups.com >> >> <https://groups.google.com/d/msgid/packer-tool/c11d7166-8900-4b79-864d-1bcb3f254686%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/6d306445-6b20-4177-95fd-1abade411e9e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.