Document. add to windows-shell and powershell
This commit is contained in:
parent
d2e59e4e92
commit
6563eb213c
|
@ -234,12 +234,6 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||||
scripts := make([]string, len(p.config.Scripts))
|
scripts := make([]string, len(p.config.Scripts))
|
||||||
copy(scripts, p.config.Scripts)
|
copy(scripts, p.config.Scripts)
|
||||||
|
|
||||||
// Build our variables up by adding in the build name and builder type
|
|
||||||
envVars := make([]string, len(p.config.Vars)+2)
|
|
||||||
envVars[0] = "PACKER_BUILD_NAME=" + p.config.PackerBuildName
|
|
||||||
envVars[1] = "PACKER_BUILDER_TYPE=" + p.config.PackerBuilderType
|
|
||||||
copy(envVars, p.config.Vars)
|
|
||||||
|
|
||||||
if p.config.Inline != nil {
|
if p.config.Inline != nil {
|
||||||
temp, err := extractScript(p)
|
temp, err := extractScript(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -344,6 +338,7 @@ func (p *Provisioner) createFlattenedEnvVars(elevated bool) (flattened string, e
|
||||||
// Always available Packer provided env vars
|
// Always available Packer provided env vars
|
||||||
envVars["PACKER_BUILD_NAME"] = p.config.PackerBuildName
|
envVars["PACKER_BUILD_NAME"] = p.config.PackerBuildName
|
||||||
envVars["PACKER_BUILDER_TYPE"] = p.config.PackerBuilderType
|
envVars["PACKER_BUILDER_TYPE"] = p.config.PackerBuilderType
|
||||||
|
envVars["PACKER_HTTP_ADDR"] = common.GetHTTPAddr()
|
||||||
|
|
||||||
// Split vars into key/value components
|
// Split vars into key/value components
|
||||||
for _, envVar := range p.config.Vars {
|
for _, envVar := range p.config.Vars {
|
||||||
|
|
|
@ -188,13 +188,6 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||||
scripts := make([]string, len(p.config.Scripts))
|
scripts := make([]string, len(p.config.Scripts))
|
||||||
copy(scripts, p.config.Scripts)
|
copy(scripts, p.config.Scripts)
|
||||||
|
|
||||||
// Build our variables up by adding in the build name and builder type
|
|
||||||
envVars := make([]string, len(p.config.Vars)+2)
|
|
||||||
envVars[0] = "PACKER_BUILD_NAME=" + p.config.PackerBuildName
|
|
||||||
envVars[1] = "PACKER_BUILDER_TYPE=" + p.config.PackerBuilderType
|
|
||||||
|
|
||||||
copy(envVars, p.config.Vars)
|
|
||||||
|
|
||||||
if p.config.Inline != nil {
|
if p.config.Inline != nil {
|
||||||
temp, err := extractScript(p)
|
temp, err := extractScript(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -301,6 +294,7 @@ func (p *Provisioner) createFlattenedEnvVars() (flattened string, err error) {
|
||||||
// Always available Packer provided env vars
|
// Always available Packer provided env vars
|
||||||
envVars["PACKER_BUILD_NAME"] = p.config.PackerBuildName
|
envVars["PACKER_BUILD_NAME"] = p.config.PackerBuildName
|
||||||
envVars["PACKER_BUILDER_TYPE"] = p.config.PackerBuilderType
|
envVars["PACKER_BUILDER_TYPE"] = p.config.PackerBuilderType
|
||||||
|
envVars["PACKER_HTTP_ADDR"] = common.GetHTTPAddr()
|
||||||
|
|
||||||
// Split vars into key/value components
|
// Split vars into key/value components
|
||||||
for _, envVar := range p.config.Vars {
|
for _, envVar := range p.config.Vars {
|
||||||
|
|
|
@ -82,3 +82,25 @@ Optional parameters:
|
||||||
|
|
||||||
- `valid_exit_codes` (list of ints) - Valid exit codes for the script. By
|
- `valid_exit_codes` (list of ints) - Valid exit codes for the script. By
|
||||||
default this is just 0.
|
default this is just 0.
|
||||||
|
|
||||||
|
|
||||||
|
## Default Environmental Variables
|
||||||
|
|
||||||
|
In addition to being able to specify custom environmental variables using the
|
||||||
|
`environment_vars` configuration, the provisioner automatically defines certain
|
||||||
|
commonly useful environmental variables:
|
||||||
|
|
||||||
|
- `PACKER_BUILD_NAME` is set to the name of the build that Packer is running.
|
||||||
|
This is most useful when Packer is making multiple builds and you want to
|
||||||
|
distinguish them slightly from a common provisioning script.
|
||||||
|
|
||||||
|
- `PACKER_BUILDER_TYPE` is the type of the builder that was used to create the
|
||||||
|
machine that the script is running on. This is useful if you want to run
|
||||||
|
only certain parts of the script on systems built with certain builders.
|
||||||
|
|
||||||
|
- `PACKER_HTTP_ADDR` If using a builder that provides an http server for file
|
||||||
|
transfer (such as hyperv, parallels, qemu, virtualbox, and vmware), this
|
||||||
|
will be set to the address. You can use this address in your provisioner to
|
||||||
|
download large files over http. This may be useful if you're experiencing
|
||||||
|
slower speeds using the default file provisioner. A file provisioner using
|
||||||
|
the `winrm` communicator may experience these types of difficulties.
|
||||||
|
|
|
@ -149,6 +149,13 @@ commonly useful environmental variables:
|
||||||
machine that the script is running on. This is useful if you want to run
|
machine that the script is running on. This is useful if you want to run
|
||||||
only certain parts of the script on systems built with certain builders.
|
only certain parts of the script on systems built with certain builders.
|
||||||
|
|
||||||
|
- `PACKER_HTTP_ADDR` If using a builder that provides an http server for file
|
||||||
|
transfer (such as hyperv, parallels, qemu, virtualbox, and vmware), this
|
||||||
|
will be set to the address. You can use this address in your provisioner to
|
||||||
|
download large files over http. This may be useful if you're experiencing
|
||||||
|
slower speeds using the default file provisioner. A file provisioner using
|
||||||
|
the `winrm` communicator may experience these types of difficulties.
|
||||||
|
|
||||||
## Handling Reboots
|
## Handling Reboots
|
||||||
|
|
||||||
Provisioning sometimes involves restarts, usually when updating the operating
|
Provisioning sometimes involves restarts, usually when updating the operating
|
||||||
|
|
|
@ -73,3 +73,25 @@ Optional parameters:
|
||||||
exists in order to deal with times when SSH may restart, such as a
|
exists in order to deal with times when SSH may restart, such as a
|
||||||
system reboot. Set this to a higher value if reboots take a longer amount
|
system reboot. Set this to a higher value if reboots take a longer amount
|
||||||
of time.
|
of time.
|
||||||
|
|
||||||
|
|
||||||
|
## Default Environmental Variables
|
||||||
|
|
||||||
|
In addition to being able to specify custom environmental variables using the
|
||||||
|
`environment_vars` configuration, the provisioner automatically defines certain
|
||||||
|
commonly useful environmental variables:
|
||||||
|
|
||||||
|
- `PACKER_BUILD_NAME` is set to the name of the build that Packer is running.
|
||||||
|
This is most useful when Packer is making multiple builds and you want to
|
||||||
|
distinguish them slightly from a common provisioning script.
|
||||||
|
|
||||||
|
- `PACKER_BUILDER_TYPE` is the type of the builder that was used to create the
|
||||||
|
machine that the script is running on. This is useful if you want to run
|
||||||
|
only certain parts of the script on systems built with certain builders.
|
||||||
|
|
||||||
|
- `PACKER_HTTP_ADDR` If using a builder that provides an http server for file
|
||||||
|
transfer (such as hyperv, parallels, qemu, virtualbox, and vmware), this
|
||||||
|
will be set to the address. You can use this address in your provisioner to
|
||||||
|
download large files over http. This may be useful if you're experiencing
|
||||||
|
slower speeds using the default file provisioner. A file provisioner using
|
||||||
|
the `winrm` communicator may experience these types of difficulties.
|
||||||
|
|
Loading…
Reference in New Issue