Allow files/subdirectories to be excluded when uploading a directory with the file provisioner #1811
Labels
enhancement
good first issue
provisioner/file
wontfix
Out of scope/alignment with the project, or issue is expected, intended behavior
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/
, andpublic/uploads/
from the source. Ideally, the Packer template would look something like this:I haven't learned Go yet, but from browsing the source code it seems like these two lines would be good starting points:
https://github.com/mitchellh/packer/blob/b6ae00fc370ac2c48c9187c6d341eb5e5e6c8d14/provisioner/file/provisioner.go#L42
https://github.com/mitchellh/packer/blob/b6ae00fc370ac2c48c9187c6d341eb5e5e6c8d14/provisioner/file/provisioner.go#L82
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. 👍
The text was updated successfully, but these errors were encountered: