github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/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 ephemeral key will be deleted at the end of the packer run
    26  during cleanup.
    27  
    28  ### Windows
    29  
    30  As of Packer 0.8.1 the default WinRM communicator will emit the password for a
    31  Remote Desktop Connection into your instance. This happens following the several
    32  minute pause as the instance is booted. Note a .pem key is still created for
    33  securely transmitting the password. Packer automatically decrypts the password
    34  for you in debug mode.
    35  
    36  ## Debugging Packer
    37  
    38  Issues occasionally arise where certain things may not work entirely correctly,
    39  or may not appear to work correctly. In these cases, it is sometimes helpful to
    40  see more details about what Packer is actually doing.
    41  
    42  Packer has detailed logs which can be enabled by setting the `PACKER_LOG`
    43  environmental variable to any value like this
    44  `PACKER_LOG=1 packer build <config.json>`. This will cause detailed logs to
    45  appear on stderr. The logs contain log messages from Packer as well as any
    46  plugins that are being used. Log messages from plugins are prefixed by their
    47  application name.
    48  
    49  Note that because Packer is highly parallelized, log messages sometimes appear
    50  out of order, especially with respect to plugins. In this case, it is important
    51  to pay attention to the timestamp of the log messages to determine order.
    52  
    53  In addition to simply enabling the log, you can set `PACKER_LOG_PATH` in order
    54  to force the log to always go to a specific file when logging is enabled. Note
    55  that even when `PACKER_LOG_PATH` is set, `PACKER_LOG` must be set in order for
    56  any logging to be enabled.
    57  
    58  ### Debugging Packer in Powershell/Windows
    59  
    60  In Windows you can set the detailed logs environmental variable `PACKER_LOG` or
    61  the log variable `PACKER_LOG_PATH` using powershell environment variables. For
    62  example:
    63  
    64      $env:PACKER_LOG=1
    65      $env:PACKER_LOG_PATH="packerlog.txt"
    66  
    67  If you find a bug with Packer, please include the detailed log by using a
    68  service such as [gist](https://gist.github.com).
    69  
    70  ## Issues Installing Ubuntu Packages
    71  
    72  Issues may arise using and building Ubuntu AMIs where common packages that
    73  *should* be installed from Ubuntu's Main repository are not found during a
    74  provisioner step:
    75  
    76      amazon-ebs: No candidate version found for build-essential
    77      amazon-ebs: No candidate version found for build-essential
    78  
    79  This, obviously can cause problems where a build is unable to finish
    80  successfully as the proper packages cannot be provisioned correctly. The problem
    81  arises when cloud-init has not finished fully running on the source AMI by the
    82  time that packer starts any provisioning steps.
    83  
    84  Adding the following provisioner to the packer template, allows for the
    85  cloud-init process to fully finish before packer starts provisioning the source
    86  AMI.
    87  
    88      {
    89        "type": "shell",
    90        "inline": [
    91          "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
    92        ]
    93      }