Packer file provisioner error on Amazon AWS: Bad Source not a directory

851 views
Skip to first unread message

an...@vnda.com.br

unread,
Mar 9, 2018, 12:02:51 PM3/9/18
to Packer

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

Alvaro Miranda Aguilera

unread,
Mar 9, 2018, 12:09:03 PM3/9/18
to packe...@googlegroups.com
Hello

whats your current directory ?

from where you run packer?


are you running this like

packer build template.json
packer build ../template.son



--
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+unsubscribe@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.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

an...@vnda.com.br

unread,
Mar 9, 2018, 12:20:03 PM3/9/18
to Packer
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. 



To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

an...@vnda.com.br

unread,
Mar 9, 2018, 12:21:20 PM3/9/18
to Packer
Sorry I meant to say: I'm running packer build this way: ./packer build template.json

Alvaro Miranda Aguilera

unread,
Mar 10, 2018, 12:19:46 PM3/10/18
to packe...@googlegroups.com
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


To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/aa42ae4e-9069-4611-8e48-7f2e8b422af6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Gabo Kete

unread,
Mar 10, 2018, 5:32:15 PM3/10/18
to Packer
on top of what Alvaro said, which I agree with him, bear in mind the following as per the packer documentation

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.


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 ;)





--
Alvaro

Reply all
Reply to author
Forward
0 new messages