Reputation: 11
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
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,
Upvotes: 1
Views: 5744
Reputation: 1267
It is as you have surmised a path thing.
You do not say from what folder you are calling packer and what the calling command is, or when you have it working with "source": "api-clients/database.yml", if you have moved the api-clients folder or it works with packer in that location.
If your folder structure will always look that way then to avoid confusions if you use a full path for the source it will always work no matter where you run packer from
eg /api_v1/app/packer/api-clients/database.yml
if you must use relative paths then make sure that the source path is always relative from the folder in which packer is run.
Upvotes: 0
Reputation: 4278
Since the path doesn't start with a /
it's a relative path. The are relative to the current working directory when executing packer build
.
With source packer/api-clients/database.yml
you have to run packer from the app
directory, i.e.
packer build ../template.json
With source api-clients/database.yml
you have to run packer from the packer
directory, i.e.
packer build ../../template.json
For more info see Packer documentation - File provisioner: source.
Upvotes: 1