Merge branch 'master' into ansible-inventory-dir

This commit is contained in:
Dan Fuchs 2017-04-26 13:20:00 -05:00 committed by GitHub
commit 8401057ed5
15 changed files with 53 additions and 7 deletions

View File

@ -7,6 +7,11 @@
* builder/openstack: Add ssh agent support. [GH-4655]
* builder/parallels-iso: Configuration of disk type, plain or expanding.
[GH-4621]
* provisioner/ansible: Add extra-vars `packer_build_name` and
`packer_builder_type`. [GH-4821]
* provisioner/ansible-local: Add extra-vars `packer_build_name`,
`packer_builder_type`, and `packer_http_addr`. [GH-4821]
## 1.0.0 (April 4, 2017)

View File

@ -13,3 +13,4 @@ Here's a list of things we like to get done in no particular order:
- [ ] windows sysprep provisioner (since it seems to generate a certain issue volume)
- [ ] allow arbitrary json patching for deployment document
- [ ] tag all resources with user-supplied tag
- [ ] managed disk support

0
builder/vmware/common/step_clean_vmx.go Executable file → Normal file
View File

0
builder/vmware/common/step_clean_vmx_test.go Executable file → Normal file
View File

0
builder/vmware/common/step_configure_vmx.go Executable file → Normal file
View File

0
builder/vmware/common/vmx.go Executable file → Normal file
View File

0
builder/vmware/common/vmx_test.go Executable file → Normal file
View File

0
builder/vmware/iso/builder.go Executable file → Normal file
View File

0
builder/vmware/iso/step_create_vmx.go Executable file → Normal file
View File

0
builder/vmware/vmx/step_clone_vmx.go Executable file → Normal file
View File

View File

@ -294,9 +294,10 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator) err
playbook := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.PlaybookFile)))
inventory := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.InventoryFile)))
extraArgs := ""
extraArgs := fmt.Sprintf(" --extra-vars \"packer_build_name=%s packer_builder_type=%s packer_http_addr=%s\" ",
p.config.PackerBuildName, p.config.PackerBuilderType, common.GetHTTPAddr())
if len(p.config.ExtraArguments) > 0 {
extraArgs = " " + strings.Join(p.config.ExtraArguments, " ")
extraArgs = extraArgs + strings.Join(p.config.ExtraArguments, " ")
}
// Fetch external dependencies

View File

@ -314,7 +314,9 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri
inventory := p.config.inventoryFile
var envvars []string
args := []string{playbook, "-i", inventory}
args := []string{"--extra-vars", fmt.Sprintf("packer_build_name=%s packer_builder_type=%s",
p.config.PackerBuildName, p.config.PackerBuilderType),
"-i", inventory, playbook}
if len(privKeyFile) > 0 {
args = append(args, "--private-key", privKeyFile)
}
@ -363,7 +365,7 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, pri
go repeat(stdout)
go repeat(stderr)
log.Printf("Executing Ansible: %s", strings.Join(cmd.Args, " "))
ui.Say(fmt.Sprintf("Executing Ansible: %s", strings.Join(cmd.Args, " ")))
if err := cmd.Start(); err != nil {
return err
}

View File

@ -326,7 +326,7 @@ builder.
```json
{
"type" : "amazon-surrogate",
"type" : "amazon-ebssurrogate",
"secret_key" : "YOUR SECRET KEY HERE",
"access_key" : "YOUR KEY HERE",
"region" : "us-east-1",

View File

@ -53,7 +53,8 @@ Optional:
To disable colors, set this to `PYTHONUNBUFFERED=1 ansible-playbook`.
- `extra_arguments` (array of strings) - An array of extra arguments to pass
to the ansible command. By default, this is empty.
to the ansible command. By default, this is empty. These arguments _will_
be passed through a shell and arguments should be quoted accordingly.
Usage example:
```
@ -136,3 +137,24 @@ chi-appservers
able to create directories and write into this folder. If the permissions
are not correct, use a shell provisioner prior to this to configure it
properly.
## Default Extra Variables
In addition to being able to specify extra arguments using the
`extra_arguments` configuration, the provisioner automatically defines certain
commonly useful Ansible 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 when using a common playbook.
- `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 playbook 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.

View File

@ -92,7 +92,8 @@ Optional Parameters:
Defaults to false.
- `extra_arguments` (array of strings) - Extra arguments to pass to Ansible.
Usage example:
These arguments _will not_ be passed through a shell and arguments should
not be quoted. Usage example:
```json
{
@ -121,6 +122,20 @@ Optional Parameters:
inventory directory with `host_vars` `group_vars` that you would like to use
in the playbook that this provisioner will run.
## Default Extra Variables
In addition to being able to specify extra arguments using the
`extra_arguments` configuration, the provisioner automatically defines certain
commonly useful Ansible 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 when using a common playbook.
- `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 playbook on systems built with certain builders.
## Limitations
### Redhat / CentOS