on top of what Alvaro said, which I agree with him, bear in mind the following as per the packer documentation
source <https://www.packer.io/docs/provisioners/file.html#source> (string) - The path to a local file or directory to upload to the machine. The path can be absolute or relative. *If it is relative, it is relative to the working directory when Packer is executed*. If this is a directory, the existence of a trailing slash is important. Read below on uploading directories. Source: https://www.packer.io/docs/provisioners/file.html Probably to avoid this confusions ( trust me I've ran in the same issue in the past you have now ) in source , use Absolute paths which will avoid this behaviour... just bear in mind the user which executes packer has enough privileges to go all the way down the path to the file ;) On Sunday, March 11, 2018 at 6:19:46 AM UTC+13, Alvaro Miranda Aguilera wrote: > > If this fails: > > if you can do ls packer/api-clients/database.yml > > is because the file is not there > > > seems the path should be > > app/packer/api-clients/database.yml > > > > On Fri, Mar 9, 2018 at 6:20 PM, <an...@vnda.com.br <javascript:>> wrote: > >> Hi Alvaro, >> >> My current directory is like this: >> >> api_v1 >> ├── template.json >> ├── app >> │ ├── bin >> │ ├── config >> │ ├── packer >> │ │ ├── api-clients >> │ │ │ └── database.yml >> │ ├── lib >> │ ├── log >> │ ├── ... >> >> >> Notice that the template.json (Packer template) is OUTSIDE of my packer >> folder. >> >> I'm running packer build this way: ./packer build ami.json >> >> from within API_V1 folder. >> >> >> >> On Friday, March 9, 2018 at 2:09:03 PM UTC-3, Alvaro Miranda Aguilera >> wrote: >>> >>> Hello >>> >>> whats your current directory ? >>> >>> from where you run packer? >>> >>> >>> are you running this like >>> >>> packer build template.json >>> packer build ../template.son >>> >>> >>> >>> On Fri, Mar 9, 2018 at 6:02 PM, <an...@vnda.com.br> wrote: >>> >>>> I have a File Provisioner configured on my packer template json: >>>> >>>> "provisioners": [{ >>>> "type": "file", >>>> "source": "packer/api-clients/database.yml", >>>> "destination": "/tmp/api-clients-database.yml" >>>> }, >>>> >>>> >>>> The code below doesn't work when I'm trying to build an AMI on Amazon >>>> AWS, it always says: >>>> >>>> >>>> Bad source 'packer/api-clients/database.yml': stat >>>> packer/api-clients/database.yml: no such file or directory >>>> >>>> >>>> * Bad source '/codebuild/output/src257534780/src/ >>>> github.com/vnda/api_v2/packer/api-clients/database.yml': stat >>>> /codebuild/output/src257534780/src/ >>>> github.com/vnda/api_v2/packer/api-clients/database.yml: not a directory >>>> >>>> >>>> If I do this: >>>> >>>> >>>> "source": "api-clients/database.yml", >>>> >>>> >>>> It works like a charm. But I must have all my Packer files inside of a >>>> packer folder within my app folder for organization purposes. >>>> >>>> What am I doing wrong? >>>> >>>> >>>> My app folder is like this: >>>> >>>> >>>> api_v1 >>>> ├── template.json >>>> ├── app >>>> │ ├── bin >>>> │ ├── config >>>> │ ├── packer >>>> │ │ ├── api-clients >>>> │ │ │ └── database.yml >>>> │ ├── lib >>>> │ ├── log >>>> │ ├── ... >>>> >>>> >>>> It seems that it has something to do with Relative Paths / Absolute >>>> Paths on Packer but I couldn't figure out what is wrong... >>>> >>>> >>>> Thanks in advance, >>>> >>>> >>>> Andre >>>> >>>> -- >>>> 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. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/packer-tool/7b4a8839-daff-46e0-a26d-154171bf6acb%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/packer-tool/7b4a8839-daff-46e0-a26d-154171bf6acb%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Alvaro >>> >>> -- >> 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/aa42ae4e-9069-4611-8e48-7f2e8b422af6%40googlegroups.com >> >> <https://groups.google.com/d/msgid/packer-tool/aa42ae4e-9069-4611-8e48-7f2e8b422af6%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Alvaro > > -- 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/18e99df3-e4b9-4946-8065-651b2a13d48f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.