Commit Graph

631 Commits

Author SHA1 Message Date
Adrien Delorme 20a152d4aa add comments to common/iso_config.go from docs 2019-06-12 16:02:02 +02:00
Adrien Delorme ca33f8bc5c Revert "Backoff.Linear: panic when InitialBackoff > MaxBackoff"
This reverts commit 39cfacd5fa.
2019-06-11 12:53:06 +02:00
Adrien Delorme 39cfacd5fa Backoff.Linear: panic when InitialBackoff > MaxBackoff
this probably means there's a configuration issue.

Since this struct is mainly set manually from code, I think it is okay to panic here.
2019-06-11 12:41:21 +02:00
Adrien Delorme 36e4eaff99 document retry.Backoff better 2019-06-11 12:20:00 +02:00
Radek Simko 8519da6ce9
common/net: Cleanup cache of used port after closing 2019-05-06 22:11:52 +01:00
Adrien Delorme b329073e54 remove trying port log as retry code will show errors
less logs !
2019-05-01 13:04:51 +02:00
Adrien Delorme 38f789eedc add error types to test for 2019-05-01 13:01:25 +02:00
Adrien Delorme 14f2d1c132 ListenRangeConfig:Listen: use the retry pkg to wait a bit in between opens 2019-05-01 12:27:32 +02:00
Adrien Delorme e14d1b8b0b add a timeout trying to open a random port 2019-05-01 12:01:34 +02:00
Adrien Delorme 2fd7adffc4 add tests for ListenRangeConfig.Listen 2019-05-01 11:46:48 +02:00
Adrien Delorme d9e5145de9 Shadow the flock pkg & add a noop filelock so that at least the solaris binary can be built
Without this the following error occurs:

$ GOOS=solaris go build .
# github.com/hashicorp/packer/vendor/github.com/gofrs/flock
vendor/github.com/gofrs/flock/flock_unix.go:28:22: undefined: syscall.LOCK_EX
vendor/github.com/gofrs/flock/flock_unix.go:39:22: undefined: syscall.LOCK_SH
vendor/github.com/gofrs/flock/flock_unix.go:56:12: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:66:12: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:96:12: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:96:42: undefined: syscall.LOCK_UN
vendor/github.com/gofrs/flock/flock_unix.go:118:21: undefined: syscall.LOCK_EX
vendor/github.com/gofrs/flock/flock_unix.go:130:21: undefined: syscall.LOCK_SH
vendor/github.com/gofrs/flock/flock_unix.go:149:9: undefined: syscall.Flock
vendor/github.com/gofrs/flock/flock_unix.go:149:44: undefined: syscall.LOCK_NB
vendor/github.com/gofrs/flock/flock_unix.go:149:44: too many errors
2019-04-30 16:01:23 +02:00
Adrien Delorme 5d9d43c01d add tests for ListenRangeConfig.Listen 2019-04-30 15:42:59 +02:00
Adrien Delorme fd63ec9a6c ListenRangeConfig.Listen: move trying port log after fslock trylock for less logs 2019-04-30 15:35:22 +02:00
Adrien Delorme 79ae62801f ListenRangeConfig: default network ( protocol ) to tcp 2019-04-30 14:55:38 +02:00
Adrien Delorme 65be2be38b step_download: force copy of local files only on windows 2019-04-29 09:39:21 +02:00
Adrien Delorme 200e26ea85 Step download: always copy local files
instead of symlinking to fix #7534. The longer term fix for this would be to change the go-getter so that it can leave the source file where it is & tell us where it is.

We will do this when the right time comes.
2019-04-26 10:35:18 +02:00
Adrien Delorme 9f1136db77 retry: encapsulate & return the last seen error in a RetryExhaustedError 2019-04-24 14:19:23 +02:00
Megan Marsh e69d95eb37 when retries were exhausted in the retry Run, we were returning nil instead of an error. 2019-04-23 13:48:30 -07:00
Adrien Delorme 5f0259fe89 step download: don't fail when checksum_type is not set 2019-04-16 18:09:54 +02:00
Adrien Delorme 4dc12701d3 step_download: display clearer error messages, also when the checksum is not set
Usually the builder validation should error when the checksum is empty, but for the virtualbox-ovf builder this is not validated. Which is something I didn't see when refactoring for go-getter incorporation/refactor.
2019-04-15 14:34:09 +02:00
Megan Marsh 78cf1405ab
Merge pull request #7480 from BobSilent/fix-hyperv-multiple-hostadapter-same-switch
Fixes "Host IP for the HyperV machine: False" if more than one VMNetworkAdapter is found
2019-04-12 14:06:46 -07:00
Adrien Delorme 9ac8d8aed8 step download: ovf files usually point to a file in the same directory, using them in place is the only way 2019-04-12 16:51:57 +02:00
Adrien Delorme 63f5bbbc73 use our own copy of iochan.LineReader 2019-04-11 14:25:24 +02:00
Adrien Delorme d72040f4fa move retry code into the common/retry pkg and make retry context aware 2019-04-09 17:46:38 +02:00
BobSilent 5b289f67fe Update hyperv.go
maybe also a fix for issue #5023
at least I got same error like there, incl. VM response
==> hyperv-iso: Host IP for the HyperV machine: False

although #4947 is marked as duplicate but shows different error output
==> hyperv-iso: Error getting host adapter ip address: PowerShell error: Get-VMNetworkAdapter : No network adapter is found with the given input.
2019-04-09 07:36:52 +02:00
Adrien Delorme f555e7a9f2 allow a provisioner to timeout
* I had to contextualise Communicator.Start and RemoteCmd.StartWithUi
NOTE: Communicator.Start starts a RemoteCmd but RemoteCmd.StartWithUi will run the cmd and wait for a return, so I renamed StartWithUi to RunWithUi so that the intent is clearer.
Ideally in the future RunWithUi will be named back to StartWithUi and the exit status or wait funcs of the command will allow to wait for a return. If you do so please read carrefully https://golang.org/pkg/os/exec/#Cmd.Stdout to avoid a deadlock
* cmd.ExitStatus to cmd.ExitStatus() is now blocking to avoid race conditions
* also had to simplify StartWithUi
2019-04-08 20:09:21 +02:00
Adrien Delorme a81abd297b Merge remote-tracking branch 'origin/master' into context_provisioner 2019-04-08 20:09:01 +02:00
Megan Marsh 3e72e65a6c
Merge pull request #7456 from hashicorp/do_5770
introduce the clean_resource_name to clean image/var names
2019-04-05 09:12:20 -07:00
Megan Marsh 217a93fc30 fix build_test.go on windows. This code needs to not be run in parallel, or else there can be race conditions with the post-processors all trying to access the same file at once. Additionally, I changed the test template itself so that it is valid code on either bash or cmd. Finally, I found and fixed a small bug in naming the file extensions in shell local inline scripts. 2019-04-04 14:57:56 -07:00
Adrien Delorme c4f3dccc14 rename interpolation context from ctx to ictx and contexts to ctx to avoid conflicts 2019-04-03 15:56:15 +02:00
Adrien Delorme 82c4b76639 [Builder|Build|PostProcessor|Provisioner|Hook]Server: context cancel using a RPC cancel method 2019-04-03 15:55:55 +02:00
Adrien Delorme 14048b1e11 Revert "WIP: go towards context cancelled rpc pkg"
This reverts commit e4609b4a6a4ba2ec76a45ad67d50d180f1a914f9.
2019-04-03 15:55:55 +02:00
Adrien Delorme 9e3a179c0d WIP: go towards context cancelled rpc pkg 2019-04-03 15:55:55 +02:00
Adrien Delorme 829851fc8a change hooks to be passed a context for cancellation
we have to as it is what calls our provisioners
2019-04-03 15:55:54 +02:00
Adrien Delorme 9836dad0c9 introduce the clean_resource_name to clean image names and deprecate the old ones 2019-04-03 11:25:51 +02:00
Adrien Delorme 91cc7e1091 net.ListenRangeConfig.Listen: don't swap ports if max < min 2019-03-26 10:53:52 +01:00
Adrien Delorme a4a83be2b9 net.ListenRangeConfig.Listen: allow to have a port rage of zero 2019-03-26 10:52:07 +01:00
Adrien Delorme cd39aa9988 net.ListenRangeConfig.Listen: log tried ports a bit earlier in the process
so we know tried ports every time
2019-03-26 10:45:32 +01:00
Adrien Delorme 5a6dffde9a use port as ints 2019-03-19 15:01:12 +01:00
Adrien Delorme c214f6735b make everything a uint 2019-03-19 12:54:15 +01:00
Adrien Delorme 51294287fa StepHTTPServer: display error if we could not connect 2019-03-19 12:54:15 +01:00
Adrien Delorme 6df4128517 StepHTTPServer: use the common/net pkg 2019-03-19 12:54:12 +01:00
Adrien Delorme 1685a1c4c0 add common/net package that can listen on a random port in a range 2019-03-19 12:53:56 +01:00
Adrien Delorme 6ab28ba89c
Update common/shell/shell.go
be more descriptive
2019-03-15 12:21:27 +01:00
Adrien Delorme b4ec6e2ed2 Create exit_code_test.go 2019-03-14 13:32:46 +01:00
Adrien Delorme eedf5e4387 Update shell.go
remove typo
2019-03-14 12:50:19 +01:00
Adrien Delorme f0a23bb81d common shell provisioner: define a ValidExitCode func 2019-03-14 12:46:32 +01:00
Adrien Delorme 30a65c858a regroup shell provisioner params into a common struct 2019-03-14 11:57:54 +01:00
Adrien Delorme 9f82b75e57 Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 12:11:58 +01:00
Vadym Haidamaka f736e2aba5 Print VerifyChecksum log for the download as ui.Message output 2019-03-11 22:33:46 +02:00
Megan Marsh 3dc1dafe58
Merge pull request #7287 from stephen-fox/ephemeral-ssh-key-pair-issue-7225
virtualbox: create ephemeral SSH key pair for build process
2019-03-04 14:25:04 -08:00
Stephen Fox 56c17941fe Added comment to authorized_keys 'sed' calls per review. 2019-02-28 10:54:14 -05:00
Megan Marsh 2a9f49a5c6 make sure we don't try to load an iso into memory because of a user mistake 2019-02-13 16:21:55 -08:00
xinau 36c1e8d838 moved adapter to common package 2019-02-12 07:10:57 +00:00
Stephen Fox 354fcc5cc6 Merge branch 'master' into 'ephemeral-ssh-key-pair-issue-7225'. 2019-02-05 16:16:51 -05:00
Stephen Fox e40aa515f2 Added TODO about public key removal logic. 2019-02-05 12:00:01 -05:00
Megan Marsh 2d3f84abf0
Merge pull request #7271 from hashicorp/make_generate
make generate
2019-02-04 13:11:24 -08:00
Stephen Fox 4c2851013e Fixed 'sed' regex to remove public key by magic string. 2019-02-04 12:10:17 -05:00
Adrien Delorme 8621949e01 make generate 2019-02-04 15:16:38 +01:00
Megan Marsh 482ba644a8 quote variables in powershell script to account for spaces 2019-02-01 13:23:17 -08:00
Megan Marsh 3602180b45 re-add missing import 2019-01-25 12:33:25 -08:00
Megan Marsh c63b54a1e7 move http with proxy call into a helper function 2019-01-25 12:32:52 -08:00
Tom Parker-Shemilt d72fb9bcb3 If checksums for a download don't match, display the checksum that was found 2019-01-17 20:26:16 +00:00
Megan Marsh 97a791389a deduplicate step_output_dir and move to common folder 2019-01-11 15:06:36 -08:00
Adrien Delorme 9f2a3bdfbc
Merge pull request #7181 from hashicorp/python_shell_docs
add python example to shell-local docs
2019-01-10 10:43:55 +01:00
Megan Marsh a2c3de9396 remove outdated logline 2019-01-09 11:16:48 -08:00
Adrien Delorme 9f7b4ffc17
Merge branch 'master' into pr/6950 2019-01-09 10:11:18 +01:00
Adrien Delorme 19cbb9cb24
Merge pull request #7136 from hashicorp/fix_5984
Add "version" option to hyperv calls
2019-01-09 10:06:49 +01:00
Megan Marsh 93053e0488 update comments 2019-01-08 15:15:00 -08:00
Megan Marsh 9557f3eea7 use script options struct rather than passing all the variables around an extra time 2019-01-08 11:29:38 -08:00
Megan Marsh a1b3b63cb9 use golang templating logic 2019-01-08 11:17:19 -08:00
Ladar Levison e6de727c25
Fix the Hyper-V gen 1 guest boot order. 2018-12-25 16:54:26 -06:00
Megan Marsh f26051a7da code comments yo 2018-12-20 13:09:32 -08:00
Megan Marsh 24d2cc34e5 tests 2018-12-20 12:03:14 -08:00
Megan Marsh 427a35fc7e tests 2018-12-20 12:03:00 -08:00
Megan Marsh d4de89e057 move powershell templating into separate script so we can test it 2018-12-19 16:35:02 -08:00
Megan Marsh 006682a09c add version option and also refactor powershell script to use golang templates for ease of testing and variable passing. 2018-12-19 16:30:57 -08:00
Ladar Levison 348c267054 Updated support for legacy network adapters on Hyper-V. 2018-12-18 04:59:00 -06:00
Megan Marsh b95123f457 add new copy_in_compare flag so users can set the copy var to whatever they need in order to get the compatibility report to work. 2018-12-13 09:12:23 -08:00
Adrien Delorme b7222d1f56 Add tmp package that offers Dir & File funcs
this regroups the calls of tmp func calls into one package.
the tmp pkg allows to store tmp files under a common directory for easier managment

Squashed commit of the following:
commit 74b674c01560c6b547e9cab5e8afb486f0fe7d6c
Merge: fc94b5714 66001525d
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Fri Nov 2 02:02:38 2018 -0400

    Merge branch 'remove_TMPDIR_docs' of github.com:tb3088/packer into remove_TMPDIR_docs

commit fc94b571428447aaf2e5171967c95cdf9e5c73ff
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Fri Nov 2 01:42:38 2018 -0400

    update tests to honor configured temporary directory

commit 5a562359f4937af506607dd96ed1c46426093f52
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 18:52:38 2018 -0400

    sync straggler to refactor. implement tests at packer/configfile instead of buried in docker.

commit 9d5a4a0935bfd049e2f8f50ad73e4455b42c9410
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 15:39:46 2018 -0400

    insert URL to GoLang API for os.TempDir()

commit fbae4c2e051898aecd8705e9d8a20353430ede23
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:41:29 2018 -0400

    revise documentation to match code

commit 3590fae8bd0afa92a161a49ed794ee32e357d583
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:21:59 2018 -0400

    refacter config_file. replace all hard-coded os.TempDir with wrapper

commit d5c5306a97b648ded06a8eb76ce728f07c9924f0
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 20:11:36 2018 -0400

    close massive file overwrite hole with TempDir

commit 0a72297da86089fbd07e4f7d9472a92fa4d1c733
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 01:06:00 2018 -0400

    adjust var declaration scope

commit 20f68228b6c372d984ea5b055cfc8bda9b110ac5
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 00:54:35 2018 -0400

    use mktemp() equivalent to create temporary directory

commit c73ebe3d8321664a2685a0baa8e441dd895b0db4
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 20:40:58 2018 -0400

    remove extraneous variable declaration, fix FOR loop

commit 63549b8bd745a0090b15ed0b0ebf644162db27db
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:30:44 2018 -0400

    match styistic convension with rest of docs

commit 976101074942db36f10d3a686d6d29ddb7c01926
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:08:39 2018 -0400

    revert dangling config file change

commit 95159afbc05eac96ed11c3183af5fb0abe2f2d5c
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Fri Dec 29 23:53:43 2017 -0500

    replace invalid TMPDIR variable wth PACKER_TMP_DIR.
    update ConfigTmpDir() to try common temporary paths first and
    only write to configDir() as a last resort.

commit 66001525d72de56a4cf9339b900c46f59bc6e91a
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Fri Nov 2 01:42:38 2018 -0400

    update tests to honor configured temporary directory

commit e9b6adefeae8c65eb8aa47fef38cbf0aa424338c
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 18:52:38 2018 -0400

    sync straggler to refactor. implement tests at packer/configfile instead of buried in docker.

commit 852113ed076e2d14e5dca6815ea680da1e2896bb
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 15:39:46 2018 -0400

    insert URL to GoLang API for os.TempDir()

commit 54add38d1d1c6e283cd444b367ed8bd49a5f3699
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:41:29 2018 -0400

    revise documentation to match code

commit 6b5b8f6d4edad0e187ca13d64ac4118f34eee643
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Thu Nov 1 07:21:59 2018 -0400

    refacter config_file. replace all hard-coded os.TempDir with wrapper

commit c22092c601c33484327674f322c7379fa41506d7
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 20:11:36 2018 -0400

    close massive file overwrite hole with TempDir

commit 7a730450916bf8e5dbc2a741ec233a49466ab7cc
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 01:06:00 2018 -0400

    adjust var declaration scope

commit 0f2933adb6f6922dfeab78a95371a444ec8918ab
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Wed Oct 31 00:54:35 2018 -0400

    use mktemp() equivalent to create temporary directory

commit d74839ede05dacf712b55a7bb48aec19fe6b007f
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 20:40:58 2018 -0400

    remove extraneous variable declaration, fix FOR loop

commit eb65416619437e4a3dec90277770803dd5b2281c
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:30:44 2018 -0400

    match styistic convension with rest of docs

commit acaa2b31ed463219c4ef099f351eec72406e2989
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 19:08:39 2018 -0400

    revert dangling config file change

commit e573fde668dcb418561e61535c1d68b2888f5b0f
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Fri Dec 29 23:53:43 2017 -0500

    replace invalid TMPDIR variable wth PACKER_TMP_DIR.
    update ConfigTmpDir() to try common temporary paths first and
    only write to configDir() as a last resort.

commit 39a9874afc9dea71b36753375fb7feb61ffecf69
Merge: 8a413cfe8 3315812c2
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Oct 30 18:19:26 2018 -0400

    Merge branch 'master' of https://github.com/hashicorp/packer into prestine

commit 8a413cfe83b0a70dbd99c32d936334ca5788ca9b
Merge: e07491de5 4e14710a6
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Mon Oct 1 20:18:10 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit e07491de59cead0b337a7f57f4a6c625e1f560ab
Merge: 42610a35d a1fa35dff
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Tue Aug 21 13:26:19 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 42610a35d5ef65af8844a58ad70e2ec75262da6a
Merge: 5298142da 0d63cf7bc
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Tue Jun 19 22:45:05 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 5298142da6da95354844f201deeeef3c599e48b2
Merge: 7bb110bc7 9d9736552
Author: Matthew Patton <mpatton@enquizit.com>
Date:   Mon Jun 11 15:10:09 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 7bb110bc744c9797fcaec25a265d9b85a22d6d6b
Merge: a61c869ca 6189d66e7
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Wed May 9 23:41:22 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit a61c869ca7268acf0e3b1e1fa7a8ee7feea65984
Merge: 098101dd9 4be5f072c
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Fri May 4 10:13:04 2018 -0400

    Merge remote-tracking branch 'upstream/master' into prestine

commit 098101dd99f08b0ca110d33eff6904537c6d21de
Merge: fefaf0fa6 554b2b4a5
Author: Matthew Patton <matthew.patton@itgfirm.com>
Date:   Tue May 1 20:52:30 2018 -0400

    Merge branch 'EOL-handling' into prestine

Co-Authored-By: Matthew Patton <pattonme@yahoo.com>
2018-12-12 16:35:57 +01:00
Anish Bhatt d5f88b154f
Better fix for #7095 2018-12-11 10:34:07 -08:00
Anish Bhatt 916375183b
Don't run StepCleanupTempKeys when communicator is set to none 2018-12-10 15:33:19 -08:00
Megan Marsh e69391f28b save users some bash scripting by exposing IP and port separately as well as together 2018-12-06 09:29:07 -08:00
pgrmega 2d1e3efadb
Fix a problem when calling Hyper-V\Compare-VM PowerShell cmdlet (#6726) 2018-11-20 22:10:03 +01:00
Megan Marsh f9ceaee4f1 fix variable casing convention 2018-10-22 14:34:50 -07:00
Joel Vasallo 5d17b3de84 fix: config validator output 2018-10-19 19:52:11 -05:00
Joel Vasallo 23ad90f2c4 fix: condensed and simplified os check logic and added validate output 2018-10-19 13:48:30 -05:00
Joel Vasallo d408c9e69c fix: moved os check to entry of func 2018-10-19 01:38:51 -05:00
Joel Vasallo 0912adea34 fix: converted onlyon param to only_on and added validation step 2018-10-19 00:51:25 -05:00
Joel Vasallo 25c0b98363 feat: ability to specify runtime OSs where shell-local should run 2018-10-18 15:10:04 -05:00
Adrien Delorme 02ba6ccfab make common/iso_config_test.go invisible to windows 2018-10-16 18:41:27 +02:00
Megan Marsh 847a3b0061 provide useful powershell error 2018-10-09 12:13:07 -07:00
Megan Marsh 3f8407d95f Revert "Merge pull request #6700 from hashicorp/multi_progressbar"
This reverts commit 5470c08345, reversing
changes made to c427486bca.
2018-09-20 13:14:17 -07:00
Megan Marsh 5470c08345
Merge pull request #6700 from hashicorp/multi_progressbar
Split progressbars per object
2018-09-19 15:22:14 -07:00
Megan Marsh 38cc525ec7 new option allowing user to clean up the ephemeral ssh key from the authorized_keys file 2018-09-14 11:06:38 -07:00
Adrien Delorme dfeca9f0df split progressbars per object 2018-09-12 16:21:58 -07:00
Megan Marsh a0edaf6c46 Going to revert this change for now, becuase of potential issues that arise from calling Prepare() twice
Revert "use statebag instead of SetSharedState for winRM password"

This reverts commit b35acbd879.
2018-09-10 16:48:42 -07:00
Adrien Delorme 32cacad273 remove comment that is not true anymore 2018-09-06 16:50:47 +02:00
Adrien Delorme bb59a70e8f progressbar: use int64 instead of uint64
* it's what's used for file sizes and used lib
2018-09-06 16:49:15 +02:00
Adrien Delorme f9c58e2b1f download: defer progress bar Finish 2018-09-06 16:38:28 +02:00
Adrien Delorme 3842f85eb4 download: remove close calls that are already defered 2018-09-06 16:30:35 +02:00
Adrien Delorme 23762a1810 fix tests for common/download_test.go 2018-09-06 15:53:59 +02:00
Adrien Delorme 7f50228080 remove old/unused progress code 2018-09-06 15:53:59 +02:00
Adrien Delorme 059e14fe42 put back usefull debug 2018-09-06 15:53:59 +02:00
Adrien Delorme a11f985e3c revert unecessary check 2018-09-06 15:53:59 +02:00
Adrien Delorme a9d302def8 removed debug logs 2018-09-06 15:53:59 +02:00
Adrien Delorme 541c68aed5 add StackableProgressBar struct that will refresh/show dl status for multiple files
* simplified the downloader interface, and removed the total/current values from them
* downloaders use a proxy reader that will add all read bytes to progress
* removed unused const mtu
* DownloadClient doesn't need a downloader, so I removed it too
2018-09-06 15:53:59 +02:00
Adrien Delorme fd7cb47adc use proxy reader for download progress & stop storing total/current in downloaders 2018-09-06 15:53:59 +02:00
Adrien Delorme ddd96c513b first draft at self refreshing loading bar centralized/controlled by Ui 2018-09-06 15:53:59 +02:00
Adrien Delorme 5a8af5500b random: optimize allocation & simplify loop 2018-09-05 10:27:02 +02:00
Adrien Delorme 4682b3a9d2 refactor possible random strings into common/random 2018-09-05 10:26:52 +02:00
Adrien Delorme 170b2f3383 builder/azure/common.RandomString-> common/random.String
* to share them
* also removed unused PassworString func & arm.TempPasswordAlphabet package const
2018-09-05 10:24:28 +02:00
Adrien Delorme 9cefd69f0d
change progress bar display rate to 5s to reduce 'spamminess' (#6640)
#6625
2018-08-30 16:00:30 +02:00
Megan Marsh 8309f36176
Merge pull request #6626 from hashicorp/fix_6620
make reasonable tempfile default on windows
2018-08-27 09:43:04 -07:00
Matthew Hooker 7519037562
Merge pull request #6629 from hashicorp/travisbuild
travis builds go 1.11. remove 1.9
2018-08-24 20:51:31 -07:00
Matthew Hooker 8a604114ef
remove unused code 2018-08-24 20:43:51 -07:00
Matthew Hooker 3f1a9766f4
formatting verb fixes for go 1.11 2018-08-24 16:18:21 -07:00
Megan Marsh c5b346b07b
Merge pull request #6393 from DanHam/fix-hyperv-export
Various improvements to Hyper-V ISO and VMCX builders
2018-08-24 15:52:49 -07:00
Megan Marsh b35acbd879 use statebag instead of SetSharedState for winRM password 2018-08-24 13:51:16 -07:00
Megan Marsh f5355a0693 make reasonable tempfile default on windows 2018-08-24 09:44:50 -07:00
Megan Marsh 340363a649
Merge pull request #6613 from hashicorp/merge_ssh_config_funcs
Merge ssh config funcs from builders
2018-08-23 16:03:36 -07:00
Megan Marsh 1f79b430ee
Merge pull request #6610 from hashicorp/filter_logs
Filter logs
2018-08-23 13:30:21 -07:00
Megan Marsh 31d4f8af45 use a time.Duration instead of a hardcoded ms 2018-08-23 13:16:01 -07:00
Megan Marsh 918db58604 added new template variables to replace PACKER_KEY_INTERVAL with tunable key and keygroup intervals depending on driver used 2018-08-22 11:37:56 -07:00
Adrien Delorme 41f6e0334d refactor all copy pasted sshConfig with into communicator.Config.SSHConfigFunc
* still need to append the auth methods into an array for gracefullness
2018-08-22 17:02:23 +02:00
Ali Rizvi-Santiago cf9bbe3ecf Incorporated the hack demonstrated by @SwampDragons in order to deal with packer.rpc.Ui not exporting any information about what it's doing to anybody. 2018-08-20 21:55:18 -05:00
Ali Rizvi-Santiago 5726927cba Moved the progress bar out of packer.Ui and unlinked it out of all the packer.Ui implementations. Split up the terminal-related functions into a separate terminal.go and calculate the progress bar width by traversing through packer.Ui to avoid the issue with github.com/ugorji/go/codec serializing private members (or unsafe pointers) of structs. Shuffled some arguments around in getConsoleScreenBufferInfo in common/terminal_windows.go so that the interface forces the user to correctly declare a _CONSOLE_SCREEN_BUFFER_INFO type. 2018-08-20 21:55:18 -05:00
Ali Rizvi-Santiago 0f10032b3d Moved the progress bar from common to the packer.UI interface and refactored it so that the terminal width is calculated based on each interface which returns a custom progressbar specific to its ui. 2018-08-20 21:55:18 -05:00
Ali Rizvi-Santiago fd2fef8738 Added support for the progress bar to automatically determine its width using the minimum length from a packer.UI and the terminal dimensions via kernel32.GetConsoleScreenBufferInfo or an ioctl (TIOCGWINSZ) to "/dev/tty". 2018-08-20 21:55:18 -05:00
Ali Rizvi-Santiago 16ecb3ad9a Reverted removal of progress-bar that was done by commit 5d97b105a8 and added some missing arguments that were missed during the rebase. Modified the default progress bar's width to 80 as a result of the conversation on PR #5851. 2018-08-20 21:55:18 -05:00
Megan Marsh ff6a039d5b replace scrubconfig with packer.LogSecretFilter.Set
filter winrm password from logs
Add new root-level packer template option, sensitive-variables, to tell us what user variables to mark sensitive.
2018-08-20 15:35:55 -07:00
Adrien Delorme a5587e30ec log wether the file was transfered or is just being inplace referenced 2018-08-20 11:45:57 +02:00
Adrien Delorme 6b3844a64f
Revert "allow to use ISO images in-place v.s. copying them" 2018-08-20 10:48:06 +02:00
Adrien Delorme c744e8b2bb make download messages less redudant and more simple 2018-08-17 09:29:39 +02:00
Adrien Delorme d7d4aed51c be even more precise 2018-08-16 18:56:28 +02:00
Adrien Delorme 2b3ea29970 show more precise error download/copy/referencing messages 2018-08-16 18:41:44 +02:00
Adrien Delorme fae3db4e58 test inplace linking 2018-08-15 17:09:39 +02:00
Adrien Delorme 17f2949e36 remove stuttering; ISOConfig.InplaceISO -> Inplace 2018-08-15 15:51:25 +02:00
Adrien Delorme 863222b1e2 Also use the terminology Inplace in DownloadConfig for clarity/consistency
* swapped boolean checks
* swapped in tests too
2018-08-15 15:26:31 +02:00
Adrien Delorme 82e480a285 allow to use ISO images inplace v.s. copying them 2018-08-15 14:37:38 +02:00
Ali Rizvi-Santiago 71e43d0b7f Updated common/download.go to handle when a connection error happens (response is nil), and reformatted the error that's returned when an HTTP error occurs. 2018-07-28 19:09:29 -05:00
Megan Marsh 5ef8b55559 need log import 2018-07-23 10:34:05 -07:00
Megan Marsh a2f5fbadf6 don't fail if you can't find abs or relative path. 2018-07-23 09:54:25 -07:00
DanHam da21c25791
Convert incorrect 'vmxc' -> 'vmcx' in codebase, docs and template opts
grep -rli --exclude-dir={vendor,bin\*,\*vmware\*,\*pkg\*} vmxc . | \
xargs sed -i 's/\(vm\)\(x\)\(c\)/\1\3\2/ig'
2018-07-20 02:12:47 +01:00
DanHam 674bad0ab4
Break very long lines for readability 2018-07-20 02:12:47 +01:00
DanHam d2390f464d
Actually implement the function for the driver 2018-07-20 02:12:45 +01:00
DanHam c2437ba592
Remove the option to place the VHD files in a separate directory
The export process now exports the VM directly from the build directory
into the output directory. There are no intermediate steps or copying of
files involved. This means that there is no longer any benefit in having
a separate directory to house the VHD files - see #5206 for the
reasoning behind the introduction of this feature.

If a user wishes to house the build files on a separate disk from the
output directory (perhaps for performance reasons or due to disk space
limitations) they can still do so through the use of `temp_path`.
2018-07-20 02:12:43 +01:00
DanHam c6b9d9ce90
Add checks/error reporting to compaction process
* Report compaction results
* Failure to find any disks under the supplied path is treated as a
  'soft' error and a warning message will be printed in place of the
  compaction result. Any other failure will cause the build to fail.
2018-07-20 02:12:42 +01:00
DanHam 534fc4a473
Ensure the export directory structure matches that of previous versions
Commit 3fc2defb6 altered the directory structure associated with an
exported VM. The changes mean that the export process now stores the
exported machine files and folders under a folder with name 'vm_name' in
the output directory.
This commit restores the previous behaviour whereby the exported machine
files and folders were stored directly in the output directory. This
allows us to keep the efficiency improvements introduced with 3fc2defb6
while maintaining backward compatibility.

By default the Export-VM command creates three folders in the specified
export directory - 'Virtual Hard Disks', 'Virtual Machines' and
'Snapshots'. When a machine with no associated snapshots is exported the
'Snapshots' directory is empty.
Prior to 3fc2defb6 the Snapshots folder was not copied/incorporated into
the output directory at all. This was a bug.
This commit preserves the legacy behaviour by not including an empty
Snapshots directory in the export. However, if there *are* Snapshots
associated with the VM, they are now moved into the output directory
along with the usual directories containing disks and VM metadata. This
prevents warnings/errors on import due to missing snapshots.
2018-07-20 02:09:57 +01:00
DanHam dc46848f89
Remove now redundant function to copy exported VM files 2018-07-20 02:09:57 +01:00
DanHam 3fc2defb6d
Refactor the export step for Hyper-V ISO and VMCX builders
* Fixes a bug that caused the build to error if users did not
  explicitly set `skip_compaction:true` when setting `skip_export:
  true`. See #6392.
* Improves the efficiency of the compaction and export process by
  reordering the compaction and export steps.
* Further improves the efficiency of the compacting step through
  compacting the vmd* file directly rather than creating and then
  operating on a copy.
* The changes mean the export process now stores the exported machine
  files and folders under a folder with name 'vm_name' in the output
  directory. Previously the exported machine files and folders were
  stored directly in the output directory.
2018-07-20 02:09:54 +01:00
Mathieu Tarral edcc0b3853 shell-local: expose PACKER_HTTP_ADDR env var 2018-07-17 18:49:36 +03:00
Megan Marsh 0df33cd032 fix relative pathing versus iso checksum dir to work even if user has provided a relative path for the iso_url which is relative to the directory where Packer is run. 2018-07-13 09:21:04 -07:00
Megan Marsh d0f0da6626 allow absolute paths to isos in checksum files 2018-07-13 09:14:59 -07:00
M. Marsh e5a63a674e
Merge pull request #6422 from DanHam/fix-gh-vmsecureboot
Hyper-V: Use Get-Command over Get-Help to check for SecureBootTemplate parameter
2018-06-25 16:48:16 -07:00
M. Marsh baaca808e8
Merge pull request #6412 from hashicorp/fix_config_validation_bug_windows_shell_local
found a config validation bug where packer crashes instead of throwin…
2018-06-25 16:47:23 -07:00
DanHam 297f6b85ec
Use Get-Command over Get-Help to check for SecureBootTemplate parameter 2018-06-25 23:52:01 +01:00
Simon Hulme 475e79a251 Fixed SecureBootTemplate not being passed through to PS cmdlet
Added check for SecureBootTemplate parameter for Server 2012 and below
Corrected enableSecureBootString usage
2018-06-25 14:13:43 +01:00
Megan Marsh 4a7953f93a found a config validation bug where packer crashes instead of throwing a validation error if a windows-style path is provided to a provisioner on linux 2018-06-22 13:49:39 -07:00
Jordan Borean efa9021974
Check if hyper-v addresses is an array before slicing it 2018-06-18 14:45:33 +10:00
Giovanni Tirloni 28095cf027 Do not return error on initial HEAD request 2018-06-13 20:30:19 -03:00
Giovanni Tirloni b7ea0b44fc HTTPDownloader - Fix invalid error handling 2018-06-13 17:42:27 -03:00
M. Marsh a012f70e71
Merge pull request #6251 from hashicorp/do_winrm_shell_local
access automatically generated winrm password from shell-local
2018-05-29 12:09:40 -07:00
Megan Marsh 3afca6905b remove duplicate assignmnet 2018-05-29 11:47:27 -07:00
Matthew Hooker 6a769f08d8
regenerate boot command code 2018-05-29 11:17:51 -07:00
Matthew Hooker 788418cff2
Add unit test to show that we handle tars safely 2018-05-25 12:13:59 -07:00
Megan Marsh 846f94c964 implement template variable for accessing WinRM password in either environemnt variables or directly in execute_command or inline commands. 2018-05-23 16:00:43 -07:00
M. Marsh 62e1323577
Merge pull request #5956 from hashicorp/dedupe_shell_local
Deduplicate the code for the shell-local post-processor and shell-local provisioner
2018-05-23 15:54:27 -07:00
Megan Marsh d1e31c0f23 use if/else to clarify code 2018-05-21 15:19:27 -07:00
Megan Marsh 969201a2d4 handle minor shell-local PR suggestions and corrections 2018-05-21 14:56:44 -07:00
Megan Marsh 1fdf763d0f fancier logging 2018-05-21 11:25:51 -07:00
M. Marsh edb5c1f50d
Merge pull request #6243 from camjjack/hyper-v-gui
Using vmconnect to display gui for hyper-v
2018-05-18 11:24:24 -07:00
WaaZaa666 b747877222
Fixing #6267, multiple hyper-v disks 2018-05-17 14:50:18 +02:00
Unknown 29c4b4436d Changes requested in PR #6243
- Logging error if vmconnect.exe fails.
- Using StepRun struct rather than StateBag for command Cancel function
- Better handling in Disconnect when headless is true or vmconnect failed in Start
2018-05-14 20:52:10 +10:00
Unknown fc734b6bd9 Using vmconnect to display gui for hyper-v
vmconnect.exe comes as part of Hyper-V and is the tool used by Hyper-V Manager to connect with a virtual machine. This commits sets behaviour the same as virtualbox and vmware to display the virtual machine connection unless headless is set in the template.
2018-05-14 20:52:10 +10:00
M. Marsh 5871b8242b
Merge pull request #6101 from adarobin/azurecompatible
Add use_fixed_vhd_format Hyper-V ISO option
2018-05-10 17:02:44 -07:00
Stefan Henseler 6f00596053 Adds config option to specify hyper-v secure boot template 2018-05-10 19:00:35 +02:00
DanHam d9d8b93c14
Remove tmp file created by common/ test. Avoid possible race condition. 2018-05-09 22:09:05 +01:00
M. Marsh 7c46e3d89c
Merge pull request #6207 from gtirloni/issue-6203
[WIP] Handle HTTP download errors
2018-05-08 15:56:06 -07:00
Matthew Hooker 5e6e12cacd
Use fmt to convert whatever's in error to a string.
This way we don't crash if someone sticks something else in the error
key in the state bag (which a quick glance at the code tells me we're
already doing.

Perhaps in the future we can add an error attribute to the state bag
but for now this will have to suffice.
2018-05-08 15:22:02 -07:00
Matthew Hooker 0a1842140b
Display build error when on-error=ask|abort 2018-05-08 04:06:03 -07:00
Megan Marsh 1bea658e16 fix command and inline calls on windows 2018-05-07 15:10:10 -07:00
Megan Marsh fabd1a6517 windows cmd env vars 2018-05-07 15:10:10 -07:00
Megan Marsh 9651432378 preserver BC for people using 'command' option 2018-05-07 15:10:10 -07:00
Megan Marsh dd183f22d9 update docs and add warnings around WSL limitations 2018-05-07 15:10:10 -07:00
Megan Marsh 51bcc7aa13 add new feature for telling shell-local whether to use linux pathing on windows; update docs with some examples. 2018-05-07 15:10:10 -07:00
Megan Marsh e983a94a88 fix default windows bash call for shell-local provisioner and move chmod command from the execute_command array into the portion of code where we actually generate inline scripts, sparing users the need to think about this modification which Packer should really handle on its own
make bash call work on windows
2018-05-07 15:10:10 -07:00
Megan Marsh 5da4377f21 first pass at docs update 2018-05-07 15:10:10 -07:00
Megan Marsh 854d6fb141 add tests making sure post-processor has backwards compatability 2018-05-07 15:10:10 -07:00
Megan Marsh f799003b66 tighten up shell-local config validation 2018-05-07 15:10:10 -07:00
Megan Marsh 479d36734d consolidate shell-local defaulting of InlineShebang and ExecuteCommand to the config validation 2018-05-07 15:10:10 -07:00
Megan Marsh d304234725 fix tests 2018-05-07 15:10:10 -07:00
Megan Marsh 67739270bb pull temp file writing into its own function for easier testing 2018-05-07 15:10:10 -07:00
Megan Marsh 6dc4b1cbdc move all of the run commands for shell-local provisioner and postprocessor into common library too 2018-05-07 15:10:09 -07:00
Megan Marsh c7c66bedcb set inline to an empty array, rather than nil 2018-05-07 15:10:09 -07:00
Megan Marsh 926327beba deduplicate all validation and interpolation of the shell-local config, sharing options between shell-local provisioner and post-processor. Maintain backwards compatibility with shell-local provisioner. 2018-05-07 15:10:09 -07:00
Megan Marsh 616b41e58f deduplicate the nearly identical communicators for the shell-local provisioner and post-processor, moving single communicator into a new common/shell-local module 2018-05-07 15:10:09 -07:00
M. Marsh bf6dc932d5
Merge pull request #6219 from jborean93/hyper-v-ip
Hyper-V: Add support retrieving IP for Server 2008 R2
2018-05-04 12:56:17 -07:00
DanHam 7e478f650e
Remove tmp files created by common/ tests 2018-04-30 18:16:46 +01:00
Jordan Borean 14e41fad7e
Hyper-V: Add support retrieving IP for Server 2008 2018-04-30 15:18:28 +10:00