github.com/hashicorp/packer@v1.14.3/website/content/docs/provisioners/windows-restart.mdx (about)

     1  ---
     2  description: |
     3    The `windows-restart` provisioner restarts a Windows machine and waits for it to
     4    come back up. Learn how to use the `windows-restart` provisioner.
     5  page_title: windows-restart provisioner reference
     6  ---
     7  
     8  <BadgesHeader>
     9    <PluginBadge type="official" />
    10  </BadgesHeader>
    11  
    12  # `windows-restart` provisioner
    13  
    14  The `windows-restart` provisioner initiates a reboot on a Windows machine and
    15  waits for the machine to come back online.
    16  
    17  The Windows provisioning process often requires multiple reboots, and this
    18  provisioner helps to ease that process.
    19  
    20  Packer expects the machine to be ready to continue provisioning after it
    21  reboots. Packer detects that the reboot has completed by making an RPC call
    22  through the Windows Remote Management (WinRM) service, not by ACPI functions,
    23  so Windows must be completely booted in order to continue.
    24  
    25  ## Basic Example
    26  
    27  The example below is fully functional.
    28  
    29  <Tabs>
    30  <Tab heading="HCL2">
    31  
    32  ```hcl
    33  provisioner "windows-restart" {}
    34  ```
    35  
    36  </Tab>
    37  <Tab heading="JSON">
    38  
    39  ```json
    40  {
    41    "type": "windows-restart"
    42  }
    43  ```
    44  
    45  </Tab>
    46  </Tabs>
    47  
    48  ## Configuration Reference
    49  
    50  The reference of available configuration options is listed below.
    51  
    52  Optional parameters:
    53  
    54  - `check_registry` (bool) - if `true`, checks for several registry keys that
    55    indicate that the system is going to reboot. This is useful if an
    56    installation kicks off a reboot and you want the provisioner to wait for
    57    that reboot to complete before reconnecting. Please note that this option
    58    is a beta feature, and we generally recommend that you finish installs that
    59    auto-reboot (like Windows Updates) during your _autounattend_ phase before
    60    the `winrm` provisioner connects.
    61  
    62  - `registry_keys` (array of strings) - if `check-registry` is `true`,
    63    `windows-restart` will not reconnect until after all of the listed keys are
    64    no longer present in the registry.
    65  
    66  ```
    67    default:
    68  
    69        var DefaultRegistryKeys = []string{
    70          "HKLM:SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\RebootPending",
    71          "HKLM:SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\PackagesPending",
    72          "HKLM:Software\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\RebootInProgress",
    73        }
    74  ```
    75  
    76  - `restart_command` (string) - The command to execute to initiate the
    77    restart. By default this is `shutdown /r /f /t 0 /c "packer restart"`.
    78  
    79  - `restart_check_command` (string) - The command to run after executing `restart_command`
    80    to check if the guest machine has restarted. This command will retry until the connection
    81    to the guest machine has been restored or `restart_timeout` has exceeded.
    82  
    83  <Tabs>
    84  <Tab heading="HCL2">
    85  
    86  ```hcl
    87  provisioner "windows-restart" {
    88    restart_check_command = "powershell -command \"& {Write-Output 'restarted.'}\""
    89  }
    90  ```
    91  
    92  </Tab>
    93  <Tab heading="JSON">
    94  
    95  ```json
    96  {
    97    "type": "windows-restart",
    98    "restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
    99  }
   100  ```
   101  
   102  </Tab>
   103  </Tabs>
   104  
   105  - `restart_timeout` (string) - The timeout to wait for the restart. By
   106    default this is 5 minutes. Example value: `5m`. If you are installing
   107    updates or have a lot of startup services, you will probably need to
   108    increase this duration.
   109  
   110  @include 'provisioners/common-config.mdx'