Compare commits

..

22 Commits

Author SHA1 Message Date
Matthew Hooker 6a8ae4b258 Cut version 1.0.2 2017-06-21 17:20:03 -07:00
Matthew Hooker 3ead2750b6 prep for 1.0.2 2017-06-21 16:54:16 -07:00
Matthew Hooker 4996c932f0 update changelog 2017-06-21 16:50:05 -07:00
Matthew Hooker c4569127e4 Merge pull request #5043 from hashicorp/fix5031
Revert "Universally provide POSIX semantics for the `shell` provision…
2017-06-21 16:36:44 -07:00
Matthew Hooker 56979a1974 Revert "Universally provide POSIX semantics for the shell provisioner."
This reverts commit 1ba7f9cc20.
2017-06-21 16:11:47 -07:00
Matthew Hooker 8681ea6026 report panic comment and shorter timeout 2017-06-21 15:56:29 -07:00
Matthew Hooker 2c8943a12d Merge pull request #5042 from hashicorp/fix5028
Don't do any logging in real main
2017-06-21 15:49:12 -07:00
Matthew Hooker 0af5b4d1ad don't do any logging in realMain.
We should write to os.Stderr explicitly, like we already do.

don't warn if config lookup fails in main
2017-06-21 15:23:31 -07:00
Matthew Hooker 5da9b3de61 Telemetry logging changes 2017-06-21 15:22:49 -07:00
Matthew Hooker 7358e65872 Merge pull request #5040 from hashicorp/fix5039
disambiguates windows-restart messages.
2017-06-21 14:55:50 -07:00
Matthew Hooker 831179dbc7 Merge pull request #5038 from hashicorp/5032
specify HostKeyCallback for vmware esx5 driver
2017-06-21 12:06:36 -07:00
Matthew Hooker 6581e0b7d6 add hostkeycallback everywhere else 2017-06-21 12:00:34 -07:00
Matthew Hooker 67e29e1eff disambiguates windows-restart messages. 2017-06-21 10:51:23 -07:00
Megan Marsh 2a6f5f1b13 specify HostKeyCallback for vmware esx5 driver 2017-06-21 10:09:11 -07:00
Matthew Hooker 837c35206a Merge pull request #5030 from hashicorp/5027_fix_template
update getting started docs to use a filter meaning they should stay …
2017-06-20 18:50:14 -07:00
Megan Marsh dc2912df4d update changelog for 5007 2017-06-20 13:26:07 -07:00
Megan Marsh ac15b33d2b Merge pull request #5029 from hashicorp/5007_instance_stop
add exponential backoff retry for stopping instance in amazon
2017-06-20 12:08:52 -07:00
Megan Marsh 52113dcdb9 update getting started docs to use a filter meaning they should stay up to date longer 2017-06-20 11:21:49 -07:00
Megan Marsh f7a703dfb2 add pending to allowable states while waiting for ebs instance to stop 2017-06-20 10:55:23 -07:00
Megan Marsh d706147423 add exponential backoff retry for stopping instance in amazon
retry only if the error is instancenotfound
2017-06-20 10:50:57 -07:00
Seth Vargo 7c30472d36 Update version everywhere 2017-06-19 17:11:50 -07:00
Megan Marsh 877cc6b7e0 next version is 1.0.2 2017-06-19 16:56:26 -07:00
15 changed files with 96 additions and 31 deletions
+16
View File
@@ -1,3 +1,19 @@
## (UNRELEASED)
## 1.0.2 (June 21, 2017)
### BUG FIXES:
* builder/amazon: Fix bugs related to stop instance command. [GH-5029]
* communicator/ssh: Fix ssh connection errors. [GH-5038]
* core: Remove logging that shouldn't be there when running commands. [GH-5042]
* provisioner/shell: Fix bug where scripts were being run under `sh`. [GH-5043]
### IMRPOVEMENTS:
* provisioner/windows-restart: make it clear that timeouts come from the
provisioner, not winrm. [GH-5040]
## 1.0.1 (June 19, 2017)
### IMPROVEMENTS:
@@ -3,7 +3,9 @@ package common
import (
"fmt"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
)
@@ -28,15 +30,47 @@ func (s *StepStopEBSBackedInstance) Run(state multistep.StateBag) multistep.Step
if !s.DisableStopInstance {
// Stop the instance so we can create an AMI from it
ui.Say("Stopping the source instance...")
_, err = ec2conn.StopInstances(&ec2.StopInstancesInput{
InstanceIds: []*string{instance.InstanceId},
// Amazon EC2 API follows an eventual consistency model.
// This means that if you run a command to modify or describe a resource
// that you just created, its ID might not have propagated throughout
// the system, and you will get an error responding that the resource
// does not exist.
// Work around this by retrying a few times, up to about 5 minutes.
err := common.Retry(10, 60, 6, func(i uint) (bool, error) {
ui.Message(fmt.Sprintf("Stopping instance, attempt %d", i+1))
_, err = ec2conn.StopInstances(&ec2.StopInstancesInput{
InstanceIds: []*string{instance.InstanceId},
})
if err == nil {
// success
return true, nil
}
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "InvalidInstanceID.NotFound" {
ui.Message(fmt.Sprintf(
"Error stopping instance; will retry ..."+
"Error: %s", err))
// retry
return false, nil
}
}
// errored, but not in expected way. Don't want to retry
return true, err
})
if err != nil {
err := fmt.Errorf("Error stopping instance: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
} else {
ui.Say("Automatic instance stop disabled. Please stop instance manually.")
}
@@ -44,7 +78,7 @@ func (s *StepStopEBSBackedInstance) Run(state multistep.StateBag) multistep.Step
// Wait for the instance to actual stop
ui.Say("Waiting for the instance to stop...")
stateChange := StateChangeConf{
Pending: []string{"running", "stopping"},
Pending: []string{"running", "pending", "stopping"},
Target: "stopped",
Refresh: InstanceStateRefreshFunc(ec2conn, *instance.InstanceId),
StepState: state,
+2
View File
@@ -36,6 +36,7 @@ func sshConfig(comm *communicator.Config) func(state multistep.StateBag) (*gossh
Auth: []gossh.AuthMethod{
gossh.PublicKeys(signer),
},
HostKeyCallback: gossh.InsecureIgnoreHostKey(),
}, nil
} else {
// password based auth
@@ -46,6 +47,7 @@ func sshConfig(comm *communicator.Config) func(state multistep.StateBag) (*gossh
gossh.KeyboardInteractive(
ssh.PasswordKeyboardInteractive(comm.SSHPassword)),
},
HostKeyCallback: gossh.InsecureIgnoreHostKey(),
}, nil
}
}
+2
View File
@@ -39,6 +39,7 @@ func SSHConfig(useAgent bool, username string, password string, privateKeyFile s
Auth: []gossh.AuthMethod{
gossh.PublicKeysCallback(agent.NewClient(sshAgent).Signers),
},
HostKeyCallback: gossh.InsecureIgnoreHostKey(),
}, nil
}
@@ -61,6 +62,7 @@ func SSHConfig(useAgent bool, username string, password string, privateKeyFile s
Auth: []gossh.AuthMethod{
gossh.PublicKeys(signer),
},
HostKeyCallback: gossh.InsecureIgnoreHostKey(),
}, nil
} else {
// password based auth
+3 -2
View File
@@ -395,8 +395,9 @@ func (d *ESX5Driver) connect() error {
sshConfig := &ssh.Config{
Connection: ssh.ConnectFunc("tcp", address),
SSHConfig: &gossh.ClientConfig{
User: d.Username,
Auth: auth,
User: d.Username,
Auth: auth,
HostKeyCallback: gossh.InsecureIgnoreHostKey(),
},
}
+4 -7
View File
@@ -53,6 +53,9 @@ func realMain() int {
logWriter = ioutil.Discard
}
// Disable logging here
log.SetOutput(ioutil.Discard)
// We always send logs to a temporary file that we use in case
// there is a panic. Otherwise, we delete it.
logTempFile, err := ioutil.TempFile("", "packer-log")
@@ -74,13 +77,7 @@ func realMain() int {
go copyOutput(outR, doneCh)
// Enable checkpoint for panic reporting
config, err := loadConfig()
if err != nil {
fmt.Fprintf(os.Stderr, "Couldn't load config: %s", err)
return 1
}
if !config.DisableCheckpoint {
if config, _ := loadConfig(); config != nil && !config.DisableCheckpoint {
packer.CheckpointReporter.Enable(config.DisableCheckpointSignature)
}
+8 -6
View File
@@ -37,13 +37,13 @@ type CheckpointTelemetry struct {
func (c *CheckpointTelemetry) Enable(disableSignature bool) {
configDir, err := ConfigDir()
if err != nil {
log.Printf("[ERR] Checkpoint telemetry setup error: %s", err)
log.Printf("[WARN] (telemetry) setup error: %s", err)
return
}
signatureFile := ""
if disableSignature {
log.Printf("[INFO] Checkpoint telemetry signature disabled")
log.Printf("[INFO] (telemetry) Checkpoint signature disabled")
} else {
signatureFile = filepath.Join(configDir, "checkpoint_signature")
}
@@ -76,14 +76,16 @@ func (c *CheckpointTelemetry) ReportPanic(m string) error {
panicParams.Payload = m
panicParams.EndTime = time.Now().UTC()
ctx, cancel := context.WithTimeout(context.Background(), 4500*time.Millisecond)
// This timeout can be longer because it runs in the real main.
// We're also okay waiting a bit longer to collect panic information
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
return checkpoint.Report(ctx, panicParams)
}
func (c *CheckpointTelemetry) AddSpan(name, pluginType string) *TelemetrySpan {
log.Printf("[TELEMETRY] Starting %s %s", pluginType, name)
log.Printf("[INFO] (telemetry) Starting %s %s", pluginType, name)
ts := &TelemetrySpan{
Name: name,
Type: pluginType,
@@ -127,9 +129,9 @@ type TelemetrySpan struct {
func (s *TelemetrySpan) End(err error) {
s.EndTime = time.Now().UTC()
log.Printf("[TELEMETRY] ending %s", s.Name)
log.Printf("[INFO] (telemetry) ending %s", s.Name)
if err != nil {
s.Error = err.Error()
log.Printf("[TELEMETRY] ERROR: %s", err.Error())
log.Printf("[INFO] (telemetry) found error: %s", err.Error())
}
}
+1 -1
View File
@@ -101,7 +101,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
}
if p.config.ExecuteCommand == "" {
p.config.ExecuteCommand = "chmod +x {{.Path}}; env {{.Vars}} {{.Path}}"
p.config.ExecuteCommand = "chmod +x {{.Path}}; {{.Vars}} {{.Path}}"
}
if p.config.ExpectDisconnect == nil {
+2 -2
View File
@@ -147,7 +147,7 @@ WaitLoop:
select {
case <-waitDone:
if err != nil {
ui.Error(fmt.Sprintf("Error waiting for WinRM: %s", err))
ui.Error(fmt.Sprintf("Error waiting for machine to restart: %s", err))
return err
}
@@ -155,7 +155,7 @@ WaitLoop:
close(p.cancel)
break WaitLoop
case <-timeout:
err := fmt.Errorf("Timeout waiting for WinRM.")
err := fmt.Errorf("Timeout waiting for machine to restart.")
ui.Error(err.Error())
close(p.cancel)
return err
+1 -1
View File
@@ -9,7 +9,7 @@ import (
var GitCommit string
// The main version number that is being run at the moment.
const Version = "1.0.1"
const Version = "1.0.2"
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION?="0.3.22"
VERSION?="0.3.26"
build:
@echo "==> Starting build in Docker..."
+1 -1
View File
@@ -2,7 +2,7 @@ set :base_url, "https://www.packer.io/"
activate :hashicorp do |h|
h.name = "packer"
h.version = "1.0.1"
h.version = "1.0.2"
h.github_slug = "hashicorp/packer"
h.website_root = "website"
end
+1 -1
View File
@@ -8,7 +8,7 @@
"builders": [
{
"type": "docker",
"image": "hashicorp/middleman-hashicorp:0.3.22",
"image": "hashicorp/middleman-hashicorp:0.3.26",
"discard": "true",
"run_command": ["-d", "-i", "-t", "{{ .Image }}", "/bin/sh"]
}
@@ -66,7 +66,7 @@ Optional parameters:
as well, which are covered in the section below.
- `execute_command` (string) - The command to use to execute the script. By
default this is `chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}`. The value
default this is `chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}`. The value
of this is treated as [configuration
template](/docs/templates/engine.html). There are two
available variables: `Path`, which is the path to the script to run, and
@@ -126,15 +126,18 @@ is being piped in with the value of `packer`.
By setting the `execute_command` to this, your script(s) can run with root
privileges without worrying about password prompts.
### `execute_command` Example
### FreeBSD Example
The following contrived example shows how to pass environment variables and
change the permissions of the script to be executed:
FreeBSD's default shell is `tcsh`, which deviates from POSIX semantics. In order
for packer to pass environment variables you will need to change the
`execute_command` to:
``` text
chmod +x {{ .Path }}; chmod 0700 {{ .Path}}; env {{ .Vars }} {{ .Path }}
chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}
```
Note the addition of `env` before `{{ .Vars }}`.
## Default Environmental Variables
In addition to being able to specify custom environmental variables using the
@@ -55,7 +55,15 @@ briefly. Create a file `example.json` and fill it with the following contents:
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-fce3c696",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp}}"