github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/website/source/docs/post-processors/shell-local.html.md (about) 1 --- 2 description: | 3 The shell-local Packer post processor enables users to do some post processing after artifacts have been built. 4 layout: docs 5 page_title: Local Shell Post Processor 6 ... 7 8 # Local Shell Post Processor 9 10 Type: `shell-local` 11 12 The local shell post processor executes scripts locally during the post processing stage. Shell local provides an easy 13 way to automate executing some task with the packer outputs. 14 15 ## Basic example 16 17 The example below is fully functional. 18 19 ``` {.javascript} 20 { 21 "type": "shell-local", 22 "inline": ["echo foo"] 23 } 24 ``` 25 26 ## Configuration Reference 27 28 The reference of available configuration options is listed below. The only 29 required element is either "inline" or "script". Every other option is optional. 30 31 Exactly *one* of the following is required: 32 33 - `inline` (array of strings) - This is an array of commands to execute. The 34 commands are concatenated by newlines and turned into a single file, so they 35 are all executed within the same context. This allows you to change 36 directories in one command and use something in the directory in the next 37 and so on. Inline scripts are the easiest way to pull off simple tasks 38 within the machine. 39 40 - `script` (string) - The path to a script to upload and execute in 41 the machine. This path can be absolute or relative. If it is relative, it is 42 relative to the working directory when Packer is executed. 43 44 - `scripts` (array of strings) - An array of scripts to execute. The scripts 45 will be uploaded and executed in the order specified. Each script is 46 executed in isolation, so state such as variables from one script won't 47 carry on to the next. 48 49 Optional parameters: 50 51 - `environment_vars` (array of strings) - An array of key/value pairs to 52 inject prior to the execute\_command. The format should be `key=value`. 53 Packer injects some environmental variables by default into the environment, 54 as well, which are covered in the section below. 55 56 - `execute_command` (string) - The command to use to execute the script. By 57 default this is `chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}`. The value 58 of this is treated as [configuration 59 template](/docs/templates/configuration-templates.html). There are two 60 available variables: `Path`, which is the path to the script to run, and 61 `Vars`, which is the list of `environment_vars`, if configured. 62 63 - `inline_shebang` (string) - The 64 [shebang](http://en.wikipedia.org/wiki/Shebang_%28Unix%29) value to use when 65 running commands specified by `inline`. By default, this is `/bin/sh -e`. If 66 you're not using `inline`, then this configuration has no effect. 67 **Important:** If you customize this, be sure to include something like the 68 `-e` flag, otherwise individual steps failing won't fail the provisioner. 69 70 ## Execute Command Example 71 72 To many new users, the `execute_command` is puzzling. However, it provides an 73 important function: customization of how the command is executed. The most 74 common use case for this is dealing with **sudo password prompts**. You may also 75 need to customize this if you use a non-POSIX shell, such as `tcsh` on FreeBSD. 76 77 ## Default Environmental Variables 78 79 In addition to being able to specify custom environmental variables using the 80 `environment_vars` configuration, the provisioner automatically defines certain 81 commonly useful environmental variables: 82 83 - `PACKER_BUILD_NAME` is set to the name of the build that Packer is running. 84 This is most useful when Packer is making multiple builds and you want to 85 distinguish them slightly from a common provisioning script. 86 87 - `PACKER_BUILDER_TYPE` is the type of the builder that was used to create the 88 machine that the script is running on. This is useful if you want to run 89 only certain parts of the script on systems built with certain builders.