You reference a script in "inline" that is on your host, of course the guest don't have that script. When you use "scripts" packer automatically upload the script from the host to the guest before it executes it. That why it works. Usually you use inline to specify the command you want to run, not to run another script that you have on the host. If you would like to do that for some special reason you should first use the "file" provisioner to upload the script to the guest.
On 5 March 2018 at 14:24, Bubunia Patra <[email protected]> wrote: > I fixed the issue myself. For some reason the inline thing doesnt work. So > used scripts with arguments and the "No such file or directory" problem is > gone. > > > On Monday, March 5, 2018 at 8:41:28 PM UTC+8, Bubunia Patra wrote: >> >> Please note that the file exists (ls -la </home/centos/packer/provision.sh>) >> and it has execute permission as well. >> >> 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-valu >>> e-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 [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/packer-tool/58a71ce8-a7b7-4c7f-a05f-9d188d13418f%40googlegroups.com > <https://groups.google.com/d/msgid/packer-tool/58a71ce8-a7b7-4c7f-a05f-9d188d13418f%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt9QwowvCGQ7GGKxLp37x3hJhqNooTfvZrRtDZeNTEsJEw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
