github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/website/source/docs/other/debugging.html.md (about) 1 --- 2 description: | 3 Packer strives to be stable and bug-free, but issues inevitably arise where 4 certain things may not work entirely correctly, or may not appear to work 5 correctly. In these cases, it is sometimes helpful to see more details about 6 what Packer is actually doing. 7 layout: docs 8 page_title: Debugging Packer 9 ... 10 11 # Debugging Packer Builds 12 13 For remote builds with cloud providers like Amazon Web Services AMIs, debugging 14 a Packer build can be eased greatly with `packer build -debug`. This disables 15 parallelization and enables debug mode. 16 17 Debug mode informs the builders that they should output debugging information. 18 The exact behavior of debug mode is left to the builder. In general, builders 19 usually will stop between each step, waiting for keyboard input before 20 continuing. This will allow you to inspect state and so on. 21 22 In debug mode once the remote instance is instantiated, Packer will emit to the 23 current directory an ephemeral private ssh key as a .pem file. Using that you 24 can `ssh -i <key.pem>` into the remote build instance and see what is going on 25 for debugging. The key will only be emitted for cloud-based builders. The 26 ephemeral key will be deleted at the end of the packer run during cleanup. 27 28 For a local builder, the SSH session initiated will be visible in the detail 29 provided when `PACKER_LOG=1` environment variable is set prior to a build, 30 and you can connect to the local machine using the userid and password defined 31 in the kickstart or preseed associated with initialzing the local VM. 32 33 ### Windows 34 35 As of Packer 0.8.1 the default WinRM communicator will emit the password for a 36 Remote Desktop Connection into your instance. This happens following the several 37 minute pause as the instance is booted. Note a .pem key is still created for 38 securely transmitting the password. Packer automatically decrypts the password 39 for you in debug mode. 40 41 ## Debugging Packer 42 43 Issues occasionally arise where certain things may not work entirely correctly, 44 or may not appear to work correctly. In these cases, it is sometimes helpful to 45 see more details about what Packer is actually doing. 46 47 Packer has detailed logs which can be enabled by setting the `PACKER_LOG` 48 environmental variable to any value but `""` (empty string) and `"0"` like this 49 `PACKER_LOG=1 packer build <config.json>`. This will cause detailed logs to 50 appear on stderr. The logs contain log messages from Packer as well as any 51 plugins that are being used. Log messages from plugins are prefixed by their 52 application name. 53 54 Note that because Packer is highly parallelized, log messages sometimes appear 55 out of order, especially with respect to plugins. In this case, it is important 56 to pay attention to the timestamp of the log messages to determine order. 57 58 In addition to simply enabling the log, you can set `PACKER_LOG_PATH` in order 59 to force the log to always go to a specific file when logging is enabled. Note 60 that even when `PACKER_LOG_PATH` is set, `PACKER_LOG` must be set in order for 61 any logging to be enabled. 62 63 ### Debugging Packer in Powershell/Windows 64 65 In Windows you can set the detailed logs environmental variable `PACKER_LOG` or 66 the log variable `PACKER_LOG_PATH` using powershell environment variables. For 67 example: 68 69 $env:PACKER_LOG=1 70 $env:PACKER_LOG_PATH="packerlog.txt" 71 72 If you find a bug with Packer, please include the detailed log by using a 73 service such as [gist](https://gist.github.com). 74 75 ## Issues Installing Ubuntu Packages 76 77 Issues may arise using and building Ubuntu AMIs where common packages that 78 *should* be installed from Ubuntu's Main repository are not found during a 79 provisioner step: 80 81 amazon-ebs: No candidate version found for build-essential 82 amazon-ebs: No candidate version found for build-essential 83 84 This, obviously can cause problems where a build is unable to finish 85 successfully as the proper packages cannot be provisioned correctly. The problem 86 arises when cloud-init has not finished fully running on the source AMI by the 87 time that packer starts any provisioning steps. 88 89 Adding the following provisioner to the packer template, allows for the 90 cloud-init process to fully finish before packer starts provisioning the source 91 AMI. 92 93 { 94 "type": "shell", 95 "inline": [ 96 "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done" 97 ] 98 }