Merge branch 'master' into misc

This commit is contained in:
Megan Marsh 2018-10-22 11:07:30 -07:00 committed by GitHub
commit 091efae8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 180 additions and 53 deletions

View File

@ -1,8 +1,45 @@
## 1.3.2 (upcoming)
### IMPROVEMENTS:
* builder/amazon: Clean up security group wait code. [GH-6843]
* builder/qemu: Add `disk_detect_zeroes` option. [GH-6827]
* builder/hcloud: Add Hetzner Cloud builder. [GH-6871]
* builder/amazon: Add suppport for `vpc_filter`, `subnet_filter`, and `security_group_filter`. [GH-6374]
* provisioner/powershell: Provide better error when Packer can't find Powershell executable. [GH-6817]
* builder/amazon: Update aws-sdk-go to v1.15.54, adding support for `credential_source`. [GH-6849]
* builder/googlecompute: Return an error if `startup_script_file` is specified, but file does not exist. [GH-6848]
* builder/amazon: Add validation for required `device_name` paramater in `block_device_mappings`. [GH-6845]
* builder/scaleway: Add `boottype` parameter to config. [GH-6772]
* core: New option to add timestamps to UI output. [GH-6784]
* builder/azure: Add new `shared_image_gallery` option. [GH-6798]
* builder/openstack: Add new `disk_format` option. [GH-6702]
* builder/openstack: Fix bug where `source_image_name` wasn't being used to properly find a UUID. [GH-6751]
* provisioner/file: Improve error messaging when file destination is a directory with no trailing slash. [GH-6756]
* builder/alicloud: Add new `disable_stop_instance` option. [GH-6764]
* builder/scaleway: Update scaleway-cli vendor. [GH-6771]
### BUG FIXES:
* builder/amazon: Error validating credentials is no longer obscured by a region validation error. [GH-6865]
* core: Fix race conditions in progress bar code [GH-6858], [GH-6788], [GH-6851]
* post-processor/manifest: No longer provides an empty ID string for Azure's managed image artifact [GH-6822]
* provisioner/powershell: Fix a bug in the way we set the ProgressPreference variable in the default `execute_command` [GH-6838]
* builder/amazon: Fix error calculating defaults in AWS waiters. [GH-6727]
* provisioner/windows-restart: Fix extraneous break which forced early exit from our wait loop. [GH-6792]
* builder/azure: Updated Azure/go-ntlmssp dependency to resolve an issue with the winrm communicator not connecting to Windows machines requiring NTLMv2 session security
* builder/amazon: Waiter now fails rather than hanging for extra time when an image import fails. [GH-6747]
* core: Fix logger so it doesn't accidentally try to format unescaped strings. [GH-6824]
* builder/amazon: Increase default wait for image import to one hour. [GH-6818]
* core: Fix error where logging was always enabled when Packer was run from inside Terraform. [GH-6758]
* builder/alicloud: Fix type error in step_create_tags [GH-6763]
* builder/scaleway: Fix issues with ssh keys. [GH-6768]
* core: Fix various places in multiple builders where config was not being passed as a pointer. [GH-6739]
## 1.3.1 (September 13, 2018)
### IMPROVEMENTS:
* builder/amazon: automatically decode encoded authorization messages if
possible [GH-5415]
* builder:amazon: Optional cleanup of the authorized keys file [GH-6713]
* builder/qemu: Fixed bug where a -device in the qemuargs would override the default network settings, resulting in no network [GH-6807]
### BUG FIXES:
* builder/amazon: fix bugs relating to spot instances provisioning [GH-6697]

View File

@ -14,7 +14,7 @@ import (
// StepRegisterAMI creates the AMI.
type StepRegisterAMI struct {
RootVolumeSize int64
EnableAMIENASupport bool
EnableAMIENASupport *bool
EnableAMISriovNetSupport bool
}
@ -83,7 +83,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
registerOpts.SriovNetSupport = aws.String("simple")
}
if s.EnableAMIENASupport {
if s.EnableAMIENASupport != nil && *s.EnableAMIENASupport {
// Set EnaSupport to true
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
registerOpts.EnaSupport = aws.Bool(true)

View File

@ -19,7 +19,7 @@ type AMIConfig struct {
AMIRegions []string `mapstructure:"ami_regions"`
AMISkipRegionValidation bool `mapstructure:"skip_region_validation"`
AMITags TagMap `mapstructure:"tags"`
AMIENASupport bool `mapstructure:"ena_support"`
AMIENASupport *bool `mapstructure:"ena_support"`
AMISriovNetSupport bool `mapstructure:"sriov_support"`
AMIForceDeregister bool `mapstructure:"force_deregister"`
AMIForceDeleteSnapshot bool `mapstructure:"force_delete_snapshot"`

View File

@ -3,6 +3,7 @@ package common
import (
"context"
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
@ -11,7 +12,7 @@ import (
)
type StepModifyEBSBackedInstance struct {
EnableAMIENASupport bool
EnableAMIENASupport *bool
EnableAMISriovNetSupport bool
}
@ -37,16 +38,22 @@ func (s *StepModifyEBSBackedInstance) Run(_ context.Context, state multistep.Sta
}
}
// Set EnaSupport to true.
// Handle EnaSupport flag.
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
if s.EnableAMIENASupport {
ui.Say("Enabling Enhanced Networking (ENA)...")
if s.EnableAMIENASupport != nil {
var prefix string
if *s.EnableAMIENASupport {
prefix = "En"
} else {
prefix = "Dis"
}
ui.Say(fmt.Sprintf("%sabling Enhanced Networking (ENA)...", prefix))
_, err := ec2conn.ModifyInstanceAttribute(&ec2.ModifyInstanceAttributeInput{
InstanceId: instance.InstanceId,
EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(true)},
EnaSupport: &ec2.AttributeBooleanValue{Value: aws.Bool(*s.EnableAMIENASupport)},
})
if err != nil {
err := fmt.Errorf("Error enabling Enhanced Networking (ENA) on %s: %s", *instance.InstanceId, err)
err := fmt.Errorf("Error %sabling Enhanced Networking (ENA) on %s: %s", strings.ToLower(prefix), *instance.InstanceId, err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt

View File

@ -20,7 +20,7 @@ import (
type StepSourceAMIInfo struct {
SourceAmi string
EnableAMISriovNetSupport bool
EnableAMIENASupport bool
EnableAMIENASupport *bool
AMIVirtType string
AmiFilters AmiFilterOptions
}
@ -94,7 +94,7 @@ func (s *StepSourceAMIInfo) Run(_ context.Context, state multistep.StateBag) mul
// Enhanced Networking can only be enabled on HVM AMIs.
// See http://goo.gl/icuXh5
if s.EnableAMIENASupport || s.EnableAMISriovNetSupport {
if (s.EnableAMIENASupport != nil && *s.EnableAMIENASupport) || s.EnableAMISriovNetSupport {
err = s.canEnableEnhancedNetworking(image)
if err != nil {
state.Put("error", err)

View File

@ -70,7 +70,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, b.config.BlockDevices.Prepare(&b.config.ctx)...)
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) {
if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+

View File

@ -85,7 +85,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("no volume with name '%s' is found", b.config.RootDevice.SourceDeviceName))
}
if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) {
if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+

View File

@ -16,7 +16,7 @@ type StepRegisterAMI struct {
RootDevice RootBlockDevice
AMIDevices []*ec2.BlockDeviceMapping
LaunchDevices []*ec2.BlockDeviceMapping
EnableAMIENASupport bool
EnableAMIENASupport *bool
EnableAMISriovNetSupport bool
image *ec2.Image
}
@ -44,7 +44,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
registerOpts.SriovNetSupport = aws.String("simple")
}
if s.EnableAMIENASupport {
if s.EnableAMIENASupport != nil && *s.EnableAMIENASupport {
// Set EnaSupport to true
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
registerOpts.EnaSupport = aws.Bool(true)

View File

@ -24,7 +24,7 @@ type Config struct {
awscommon.RunConfig `mapstructure:",squash"`
VolumeMappings []BlockDevice `mapstructure:"ebs_volumes"`
AMIENASupport bool `mapstructure:"ena_support"`
AMIENASupport *bool `mapstructure:"ena_support"`
AMISriovNetSupport bool `mapstructure:"sriov_support"`
launchBlockDevices awscommon.BlockDevices
@ -70,7 +70,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, err)
}
if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) {
if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+

View File

@ -156,7 +156,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
errs, fmt.Errorf("x509_key_path points to bad file: %s", err))
}
if b.config.IsSpotInstance() && (b.config.AMIENASupport || b.config.AMISriovNetSupport) {
if b.config.IsSpotInstance() && ((b.config.AMIENASupport != nil && *b.config.AMIENASupport) || b.config.AMISriovNetSupport) {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Spot instances do not support modification, which is required "+
"when either `ena_support` or `sriov_support` are set. Please ensure "+

View File

@ -12,7 +12,7 @@ import (
)
type StepRegisterAMI struct {
EnableAMIENASupport bool
EnableAMIENASupport *bool
EnableAMISriovNetSupport bool
}
@ -38,7 +38,7 @@ func (s *StepRegisterAMI) Run(ctx context.Context, state multistep.StateBag) mul
// As of February 2017, this applies to C3, C4, D2, I2, R3, and M4 (excluding m4.16xlarge)
registerOpts.SriovNetSupport = aws.String("simple")
}
if s.EnableAMIENASupport {
if s.EnableAMIENASupport != nil && *s.EnableAMIENASupport {
// Set EnaSupport to true
// As of February 2017, this applies to C5, I3, P2, R4, X1, and m4.16xlarge
registerOpts.EnaSupport = aws.Bool(true)

View File

@ -102,6 +102,23 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) {
return
}
// Wait for volume to become available.
status, err := GetVolumeStatus(blockStorageClient, s.volumeID)
if err != nil {
ui.Error(fmt.Sprintf(
"Error getting the volume information. Please delete the volume manually: %s", s.volumeID))
return
}
if status != "available" {
ui.Say(fmt.Sprintf(
"Waiting for volume %s (volume id: %s) to become available...", s.VolumeName, s.volumeID))
if err := WaitForVolume(blockStorageClient, s.volumeID); err != nil {
ui.Error(fmt.Sprintf(
"Error getting the volume information. Please delete the volume manually: %s", s.volumeID))
return
}
}
ui.Say(fmt.Sprintf("Deleting volume: %s ...", s.volumeID))
err = volumes.Delete(blockStorageClient, s.volumeID).ExtractErr()
if err != nil {

View File

@ -15,7 +15,7 @@ func WaitForVolume(blockStorageClient *gophercloud.ServiceClient, volumeID strin
numErrors := 0
for {
volume, err := volumes.Get(blockStorageClient, volumeID).Extract()
status, err := GetVolumeStatus(blockStorageClient, volumeID)
if err != nil {
errCode, ok := err.(*gophercloud.ErrUnexpectedResponseCode)
if ok && (errCode.Actual == 500 || errCode.Actual == 404) {
@ -32,11 +32,11 @@ func WaitForVolume(blockStorageClient *gophercloud.ServiceClient, volumeID strin
return err
}
if volume.Status == "available" {
if status == "available" {
return nil
}
log.Printf("Waiting for volume creation status: %s", volume.Status)
log.Printf("Waiting for volume creation status: %s", status)
time.Sleep(2 * time.Second)
}
}
@ -65,3 +65,12 @@ func GetVolumeSize(imageClient *gophercloud.ServiceClient, imageID string) (int,
return volumeSizeGB, nil
}
func GetVolumeStatus(blockStorageClient *gophercloud.ServiceClient, volumeID string) (string, error) {
volume, err := volumes.Get(blockStorageClient, volumeID).Extract()
if err != nil {
return "", err
}
return volume.Status, nil
}

View File

@ -131,9 +131,11 @@ each category, the available configuration keys are alphabetized.
forces Packer to find an open device automatically.
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
on HVM-compatible AMIs. If `true`, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
If false, this will disable enhanced networking in the final AMI as opposed to passing
the setting through unchanged from the source. Note: you must make sure enhanced
networking is enabled on your instance. See [Amazon's documentation on enabling enhanced
networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
- `force_deregister` (boolean) - Force Packer to first deregister an existing
AMI if one with the same name already exists. Default `false`.

View File

@ -183,9 +183,11 @@ builder.
Default `false`.
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
If false, this will disable enhanced networking in the final AMI as opposed to passing
the setting through unchanged from the source. Note: you must make sure enhanced
networking is enabled on your instance. See [Amazon's documentation on enabling enhanced
networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
- `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source
instance to burst additional CPU beyond its available [CPU Credits]

View File

@ -176,9 +176,11 @@ builder.
Default `false`.
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
If false, this will disable enhanced networking in the final AMI as opposed to passing
the setting through unchanged from the source. Note: you must make sure enhanced
networking is enabled on your instance. See [Amazon's documentation on enabling enhanced
networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
- `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source
instance to burst additional CPU beyond its available [CPU Credits]

View File

@ -148,9 +148,11 @@ builder.
Default `false`.
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
If false, this will disable enhanced networking in the final AMI as opposed to passing
the setting through unchanged from the source. Note: you must make sure enhanced
networking is enabled on your instance. See [Amazon's documentation on enabling enhanced
networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
- `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source
instance to burst additional CPU beyond its available [CPU Credits]

View File

@ -200,9 +200,11 @@ builder.
Default `false`.
- `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
on HVM-compatible AMIs. If set, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
If false, this will disable enhanced networking in the final AMI as opposed to passing
the setting through unchanged from the source. Note: you must make sure enhanced
networking is enabled on your instance. See [Amazon's documentation on enabling enhanced
networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
- `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source
instance to burst additional CPU beyond its available [CPU Credits]

View File

@ -180,7 +180,7 @@ for Packer to work:
Note that if you'd like to create a spot instance, you must also add:
``` json
```
ec2:RequestSpotInstances,
ec2:CancelSpotInstanceRequests,
ec2:DescribeSpotInstanceRequests
@ -188,7 +188,7 @@ ec2:DescribeSpotInstanceRequests
If you have the `spot_price` parameter set to `auto`, you must also add:
``` json
```
ec2:DescribeSpotPriceHistory
```
@ -247,4 +247,4 @@ Excepting tasks that we know can take an extremely long time, this defaults to
40tries.
`AWS_POLL_DELAY_SECONDS` - How many seconds to wait in between status update
requests. Generally defaults to 2 or 5 seconds, depending on the task.
requests. Generally defaults to 2 or 5 seconds, depending on the task.

View File

@ -78,14 +78,14 @@ Each component is explained below:
- `timestamp` is a Unix timestamp in UTC of when the message was printed.
- `target` is the target of the following output. This is empty if the message
is related to Packer globally. Otherwise, this is generally a build name so
you can relate output to a specific build while parallel builds are running.
- `type` is the type of machine-readable message being outputted. There are a
set of standard types which are covered later, but each component of Packer
(builders, provisioners, etc.) may output their own custom types as well,
allowing the machine-readable output to be infinitely flexible.
- `target` When you call `packer build` this can be either empty or individual
build names, e.g. `amazon-ebs`. It is normally empty when builds are in
progress, and the build name when artifacts of particular builds are being
referred to.
- `type` is the type of machine-readable message being outputted. The two most
common `type`s are `ui` and `artifact`
- `data` is zero or more comma-separated values associated with the prior type.
The exact amount and meaning of this data is type-dependent, so you must read
@ -101,11 +101,58 @@ become a literal `\r`.
### Machine-Readable Message Types
The set of machine-readable message types can be found in the
[machine-readable format](/docs/commands/index.html) complete
documentation section. This section contains documentation on all the message
types exposed by Packer core as well as all the components that ship with
Packer by default.
Here's an incomplete list of types you may see in the machine-readable output:
You'll see these data types when you run `packer build`:
- `ui`: this means that the information being provided is a human-readable string
that would be sent to stdout even if we aren't in machine-readable mode. There
are three "data" subtypes associated with this type:
- `say`: in a non-machine-readable format, this would be bolded. Normally it is
used for anouncements about beginning new steps in the build process
- `message`: the most commonly used message type, used for basic updates during
the build process.
- `error`: reserved for errors
- `artifact-count`: This data type tells you how many artifacts a particular
build produced.
- `artifact`: This data type tells you information about what Packer created
during its build. An example of output follows the pattern
`timestamp, buildname, artifact, artifact_number, key, value` where `key` and
`value` contain information about the artifact.
For example:
```
1539967803,,ui,say,\n==> Builds finished. The artifacts of successful builds are:
1539967803,amazon-ebs,artifact-count,2
1539967803,amazon-ebs,artifact,0,builder-id,mitchellh.amazonebs
1539967803,amazon-ebs,artifact,0,id,eu-west-1:ami-04d23aca8bdd36e30
1539967803,amazon-ebs,artifact,0,string,AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n
1539967803,amazon-ebs,artifact,0,files-count,0
1539967803,amazon-ebs,artifact,0,end
1539967803,,ui,say,--> amazon-ebs: AMIs were created:\neu-west-1: ami-04d23aca8bdd36e30\n
1539967803,amazon-ebs,artifact,1,builder-id,
1539967803,amazon-ebs,artifact,1,id,
1539967803,amazon-ebs,artifact,1,string,
1539967803,amazon-ebs,artifact,1,files-count,0
2018/10/19 09:50:03 waiting for all plugin processes to complete...
1539967803,amazon-ebs,artifact,1,end
```
You'll see these data types when you run `packer version`:
- `version`: what version of Packer is running
- `version-prerelease`: Data will contain `dev` if version is prerelease, and
otherwise will be blank.
- `version-commit`: The git hash for the commit that the branch of Packer is
currently on; most useful for Packer developers.
## Autocompletion