This module is intended to be used in a Packer template to move all files that template
copies into /tmp/packer-files/XXX/YYY into /XXX/YYY. For example, if you used the file provisioner to upload a
file to /tmp/packer-files/foo/bar, it will be moved to /foo/bar.
Why not just upload these files directly with Packer? Because:
If the destination folder doesn't exist, the file provisioner won't create it. Instead, you just get an error.
The file provisioner may not have permissions to write to certain folders (e.g. /opt/my-app) and it can't use
sudo.
As a result, using the file provisioner is often a multi-step process where you first copy the files to a temporary
folder, then run scripts to create the real destination folder, move your files there, and update permissions. This
packer-file-copy module automates all these steps.
{"treedata":{"name":"root","toggled":true,"children":[{"name":".circleci","children":[{"name":"config.yml","path":".circleci/config.yml","sha":"d4e97d763c7e8822797436e93c3f7c39ee0e7af8"}]},{"name":".gitignore","path":".gitignore","sha":"29b636a4866f303161e94a784957220f7338daac"},{"name":"CODEOWNERS","path":"CODEOWNERS","sha":"6bddb3ff6e1b3dfaba7cf180e56bca12c245be56"},{"name":"LICENSE.txt","path":"LICENSE.txt","sha":"04270f7b3f33bef39ed0db8cb6140423f971b478"},{"name":"README.md","path":"README.md","sha":"f430d805c31b9392abf14b968479ec89fc2fa57e"},{"name":"_ci","children":[{"name":"run-tests.sh","path":"_ci/run-tests.sh","sha":"e4ba0ede2fbe21a48909e9672db63433a27ce41c"}]},{"name":"bootstrap-gruntwork-installer.sh","path":"bootstrap-gruntwork-installer.sh","sha":"83dfb6469cc6b23b3af583447cbe231d5a8b5782"},{"name":"examples","children":[{"name":"packer-file-copy","children":[{"name":"files","children":[{"name":"foo","children":[{"name":"bar","children":[{"name":"test.txt","path":"examples/packer-file-copy/files/foo/bar/test.txt","sha":"34e44ea528c5214d459fcc11c2eba62835eba406"}]}]}]},{"name":"packer-example.json","path":"examples/packer-file-copy/packer-example.json","sha":"1bab5a6219502d824a11d5f89a4da3618b8197d5"}]}]},{"name":"gruntwork-install","path":"gruntwork-install","sha":"00c924ac0516a30f6e656fb3a3823dca320423dc"},{"name":"modules","children":[{"name":"README.md","path":"modules/README.md","sha":"9992a03ddcf2f6d73c5add68befa8d2edf03bca6"},{"name":"args-test","children":[{"name":"README.md","path":"modules/args-test/README.md","sha":"efa6e4900b6bcfe3c913cf6ada4387b03ffd6184"},{"name":"install.sh","path":"modules/args-test/install.sh","sha":"ac122586bf7d6950e3db1cbe8746524955afca8b"}]},{"name":"dummy-module","children":[{"name":"README.md","path":"modules/dummy-module/README.md","sha":"efa6e4900b6bcfe3c913cf6ada4387b03ffd6184"},{"name":"install.sh","path":"modules/dummy-module/install.sh","sha":"16da69a15f2e15754b9f57ffe21b57d1c1d5e997"}]},{"name":"packer-file-copy","children":[{"name":"README.md","path":"modules/packer-file-copy/README.md","sha":"af5cf09034b2ec96afa32527aca9496504ff9c55","toggled":true},{"name":"install-scripts","children":[{"name":"copy-packer-files.sh","path":"modules/packer-file-copy/install-scripts/copy-packer-files.sh","sha":"7ce6715b8279dd7e8805ed71bab61f9f98052120"}]},{"name":"install.sh","path":"modules/packer-file-copy/install.sh","sha":"832b165f1235d5844a4ef8f0e82fef518c6c1ce0"}],"toggled":true}],"toggled":true},{"name":"test","children":[{"name":"amazonlinux","children":[{"name":"Dockerfile","path":"test/amazonlinux/Dockerfile","sha":"a1dffe0fdbec6222f89cc4b983f41ec84f686653"},{"name":"docker-compose.yml","path":"test/amazonlinux/docker-compose.yml","sha":"28b44a5a1028b58a70fd37c5a6158de4310f1b42"}]},{"name":"centos","children":[{"name":"Dockerfile","path":"test/centos/Dockerfile","sha":"c69cdd1078a2fa9db8a3f359a02a1fca53cc9339"},{"name":"docker-compose.yml","path":"test/centos/docker-compose.yml","sha":"6a9da7ae9fc5e1558508da60dbde058e4daa5aef"}]},{"name":"integration-test.sh","path":"test/integration-test.sh","sha":"cfd7fabbc9445c842ba304f585a4b8b2519c34c3"},{"name":"no-sudo-test.sh","path":"test/no-sudo-test.sh","sha":"be4febf2d78bcef7d9b0c90d6e136b2a208ac8d4"},{"name":"no_sudo","children":[{"name":"Dockerfile","path":"test/no_sudo/Dockerfile","sha":"f5e024795dfb43d91596d7c00985fc30aa61e130"},{"name":"docker-compose.yml","path":"test/no_sudo/docker-compose.yml","sha":"bf93a3f6a2685f60d1aee2be4152e16726782f47"}]},{"name":"ubuntu","children":[{"name":"Dockerfile","path":"test/ubuntu/Dockerfile","sha":"0bc2b8a15dba68ce8db799aec24791ea4cc8238c"},{"name":"docker-compose.yml","path":"test/ubuntu/docker-compose.yml","sha":"0cfd1f518f0e978a6f94b87b468c5da119aeacde"}]},{"name":"ubuntu18","children":[{"name":"Dockerfile","path":"test/ubuntu18/Dockerfile","sha":"be7eec558be39d4bb2df18a186d09b934735e819"},{"name":"docker-compose.yml","path":"test/ubuntu18/docker-compose.yml","sha":"943e56820497761434cd6fdf9d0566037b9f1f10"}]}]}]},"detailsContent":"<h1 class=\"preview__body--title\" id=\"packer-file-copy\">Packer File Copy</h1><div class=\"preview__body--border\"></div><p>This module is intended to be used in a <a href=\"https://www.packer.io/\" class=\"preview__body--description--blue\" target=\"_blank\">Packer template</a> to move all files that template\ncopies into <code>/tmp/packer-files/XXX/YYY</code> into <code>/XXX/YYY</code>. For example, if you used the <code>file</code> provisioner to upload a\nfile to <code>/tmp/packer-files/foo/bar</code>, it will be moved to <code>/foo/bar</code>.</p>\n<p>Why not just upload these files directly with Packer? Because:</p>\n<ol>\n<li>If the destination folder doesn't exist, the <code>file</code> provisioner won't create it. Instead, you just get an error.</li>\n<li>The <code>file</code> provisioner may not have permissions to write to certain folders (e.g. <code>/opt/my-app</code>) and it can't use\n<code>sudo</code>.</li>\n</ol>\n<p>As a result, using the <code>file</code> provisioner is often a multi-step process where you first copy the files to a temporary\nfolder, then run scripts to create the real destination folder, move your files there, and update permissions. This\npacker-file-copy module automates all these steps.</p>\n<p>For an example of this module in action, see <a href=\"/repos/v0.0.37/gruntwork-installer/examples/packer-file-copy\" class=\"preview__body--description--blue\">examples/packer-file-copy</a>.</p>\n<p>IMPORTANT: The packer file provisioner should look like the following:</p>\n<pre>{\n <span class=\"hljs-attr\">\"type\"</span>: <span class=\"hljs-string\">\"file\"</span>,\n <span class=\"hljs-attr\">\"source\"</span>: <span class=\"hljs-string\">\"{{template_dir}}/files\"</span>,\n <span class=\"hljs-attr\">\"destination\"</span>: <span class=\"hljs-string\">\"/tmp/packer-files\"</span>\n}\n</pre>\n<p>Note how both the source and destination have no trailing slash. Adding a trailing slash will mean Packer will upload\nfiles differently than intended.</p>\n","repoName":"gruntwork-installer","repoRef":"v0.0.38","serviceDescriptor":{"serviceName":"Gruntwork Installer","serviceRepoName":"gruntwork-installer","serviceRepoOrg":"gruntwork-io","cloudProviders":["aws","gcp","azure"],"description":"A script for easy installation of Gruntwork Modules.","imageUrl":"grunt.png","licenseType":"open-source","technologies":["Bash"],"compliance":[],"tags":[""],"noDisplayInUI":true},"serviceCategoryName":"Reference Architecture","fileName":"README.md","filePath":"/modules/packer-file-copy/README.md","title":"Repo Browser: Gruntwork Installer","description":"Browse the repos in the Gruntwork Infrastructure as Code Library."}