github.com/ratanraj/packer@v1.3.2/website/source/docs/provisioners/windows-shell.html.md (about)

     1  ---
     2  description: |
     3      The windows-shell Packer provisioner runs commands on Windows using the cmd
     4      shell.
     5  layout: docs
     6  page_title: 'Windows Shell - Provisioners'
     7  sidebar_current: 'docs-provisioners-windows-shell'
     8  ---
     9  
    10  # Windows Shell Provisioner
    11  
    12  Type: `windows-shell`
    13  
    14  The windows-shell Packer provisioner runs commands on a Windows machine using
    15  `cmd`. It assumes it is running over WinRM.
    16  
    17  ## Basic Example
    18  
    19  The example below is fully functional.
    20  
    21  ``` json
    22  {
    23    "type": "windows-shell",
    24    "inline": ["dir c:\\"]
    25  }
    26  ```
    27  
    28  ## Configuration Reference
    29  
    30  The reference of available configuration options is listed below. The only
    31  required element is either "inline" or "script". Every other option is optional.
    32  
    33  Exactly *one* of the following is required:
    34  
    35  -   `inline` (array of strings) - This is an array of commands to execute. The
    36      commands are concatenated by newlines and turned into a single file, so they
    37      are all executed within the same context. This allows you to change
    38      directories in one command and use something in the directory in the next
    39      and so on. Inline scripts are the easiest way to pull off simple tasks
    40      within the machine.
    41  
    42  -   `script` (string) - The path to a script to upload and execute in
    43      the machine. This path can be absolute or relative. If it is relative, it is
    44      relative to the working directory when Packer is executed.
    45  
    46  -   `scripts` (array of strings) - An array of scripts to execute. The scripts
    47      will be uploaded and executed in the order specified. Each script is
    48      executed in isolation, so state such as variables from one script won't
    49      carry on to the next.
    50  
    51  Optional parameters:
    52  
    53  -   `binary` (boolean) - If true, specifies that the script(s) are binary files,
    54      and Packer should therefore not convert Windows line endings to Unix line
    55      endings (if there are any). By default this is false.
    56  
    57  -   `environment_vars` (array of strings) - An array of key/value pairs to
    58      inject prior to the execute\_command. The format should be `key=value`.
    59      Packer injects some environmental variables by default into the environment,
    60      as well, which are covered in the section below.
    61  
    62  -   `execute_command` (string) - The command to use to execute the script. By
    63      default this is `{{ .Vars }}"{{ .Path }}"`. The value of this is treated as
    64      [template engine](/docs/templates/engine.html).
    65      There are two available variables: `Path`, which is the path to the script
    66      to run, and `Vars`, which is the list of `environment_vars`, if configured.
    67  
    68  -   `remote_path` (string) - The path where the script will be uploaded to in
    69      the machine. This defaults to "c:/Windows/Temp/script.bat". This value must be a
    70      writable location and any parent directories must already exist.
    71  
    72  -   `start_retry_timeout` (string) - The amount of time to attempt to *start*
    73      the remote process. By default this is "5m" or 5 minutes. This setting
    74      exists in order to deal with times when SSH may restart, such as a
    75      system reboot. Set this to a higher value if reboots take a longer amount
    76      of time.
    77  
    78  ## Default Environmental Variables
    79  
    80  In addition to being able to specify custom environmental variables using the
    81  `environment_vars` configuration, the provisioner automatically defines certain
    82  commonly useful environmental variables:
    83  
    84  -   `PACKER_BUILD_NAME` is set to the
    85      [name of the build](/docs/templates/builders.html#named-builds) that Packer is running.
    86      This is most useful when Packer is making multiple builds and you want to
    87      distinguish them slightly from a common provisioning script.
    88  
    89  -   `PACKER_BUILDER_TYPE` is the type of the builder that was used to create the
    90      machine that the script is running on. This is useful if you want to run
    91      only certain parts of the script on systems built with certain builders.
    92  
    93  -   `PACKER_HTTP_ADDR` If using a builder that provides an http server for file
    94      transfer (such as hyperv, parallels, qemu, virtualbox, and vmware), this
    95      will be set to the address. You can use this address in your provisioner to
    96      download large files over http. This may be useful if you're experiencing
    97      slower speeds using the default file provisioner. A file provisioner using
    98      the `winrm` communicator may experience these types of difficulties.