I'm uploading a Rails app to the machine built by Packer. I'd like to use the file provisioner to upload my directory, but exclude certain files or subdirectories like tmp/
, log/
, and public/uploads/
from the source. Ideally, the Packer template would look something like this:
{
"variables": {},
"builders": [],
"provisioners": [{
"type": "file",
"source": ".",
"destination": "/var/www/myapp",
"exclude": ["tmp/", "log/", "public/uploads/"]
}]
}
I haven't learned Go yet, but from browsing the source code it seems like these two lines would be good starting points:
For anyone else with this issue, the first workaround is to upload the entire directory to a temporary destination, then use a shell provisioner afterwards to copy the desired files/dirs to the final destination. The second workaround is to use multiple file provisioners in your Packer template to upload each of the desired files/directories one-by-one.
Both of these workarounds currently work for my use case, but an "exclude" option built into the file provisioner would be more simple, clean, and awesome. :+1:
:+1:
:+1:
for case when packer config dir is stored with its provisioner role and you don't want to upload iso or previous box :)
This would be perfect. NodeJS projects with lots of dependencies cause the file upload step to hang for a long time due how large the node_modules/
directory is.
May be i can do that after some time if nobody wants.
This seems like it could be handy. to quote @cbednarski in #2872
We do have include / exclude filtering in some other packer features but this turns out to be very confusing for people to use because you cannot inspect the list of files in advance.
Will be happy to look at any PRs that come in for this, but this is not something we're targeting for 1.0, so I'm going to close this. Please see the mailing list for more details on 1.0.