Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a8ae4b258 | |||
| 3ead2750b6 | |||
| 4996c932f0 | |||
| c4569127e4 | |||
| 56979a1974 | |||
| 8681ea6026 | |||
| 2c8943a12d | |||
| 0af5b4d1ad | |||
| 5da9b3de61 | |||
| 7358e65872 | |||
| 831179dbc7 | |||
| 6581e0b7d6 | |||
| 67e29e1eff | |||
| 2a6f5f1b13 | |||
| 837c35206a | |||
| dc2912df4d | |||
| ac15b33d2b | |||
| 52113dcdb9 | |||
| f7a703dfb2 | |||
| d706147423 | |||
| 7c30472d36 | |||
| 877cc6b7e0 |
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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
@@ -1,4 +1,4 @@
|
||||
VERSION?="0.3.22"
|
||||
VERSION?="0.3.26"
|
||||
|
||||
build:
|
||||
@echo "==> Starting build in Docker..."
|
||||
|
||||
+1
-1
@@ -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
@@ -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}}"
|
||||
|
||||
Reference in New Issue
Block a user