Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow files/subdirectories to be excluded when uploading a directory with the file provisioner #1811

Closed
sergiopantoja opened this issue Jan 5, 2015 · 5 comments
Labels
enhancement good first issue provisioner/file wontfix Out of scope/alignment with the project, or issue is expected, intended behavior

Comments

@sergiopantoja
Copy link
Contributor

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:

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. 👍

@davidvasandani
Copy link

👍

@juju4
Copy link

juju4 commented Aug 11, 2016

👍
for case when packer config dir is stored with its provisioner role and you don't want to upload iso or previous box :)

@davidvuong
Copy link

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.

@vtolstov
Copy link
Contributor

vtolstov commented Jan 16, 2017

May be i can do that after some time if nobody wants.

@mwhooker
Copy link
Contributor

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.

@mwhooker mwhooker added good first issue post-1.0 pre-1.0 wontfix Out of scope/alignment with the project, or issue is expected, intended behavior and removed pre-1.0 labels Jan 30, 2017
@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement good first issue provisioner/file wontfix Out of scope/alignment with the project, or issue is expected, intended behavior
Projects
None yet
Development

No branches or pull requests

8 participants