Compare commits

..

62 Commits

Author SHA1 Message Date
Mitchell Hashimoto 12ba7ae443 v0.4.1 2013-12-07 21:05:53 -08:00
Mitchell Hashimoto d125dc9244 builder/vmware: clarify guestiphack error message [GH-639] 2013-12-07 10:31:57 -08:00
Mitchell Hashimoto 013c1829e4 provisioner/puppet-masterless: check for hiera config path [GH-656] 2013-12-06 19:30:06 -08:00
Mitchell Hashimoto 3b2e3456f6 website: fix docs for vmware esxi discrep [GH-674] 2013-12-06 19:14:20 -08:00
Mitchell Hashimoto ea09c1105c builder/vmware: correct logic in cehcking if file is still there 2013-12-06 19:12:49 -08:00
Mitchell Hashimoto b12871dc28 builder/vmware: more resilient to racing deletes [GH-675] 2013-12-06 19:11:40 -08:00
Mitchell Hashimoto ece02bb19d Update CHANGELOG 2013-12-06 19:05:19 -08:00
Mitchell Hashimoto 5997573f37 builder/amazon/instance: add location to upload command [GH-679] 2013-12-06 19:04:40 -08:00
Mitchell Hashimoto a21b3cee23 common: fix tests 2013-12-06 18:36:16 -08:00
Mitchell Hashimoto 382f813694 builder/amazon/chroot: remove unused import 2013-12-06 18:32:21 -08:00
Mitchell Hashimoto 1e2ce0e3e3 common: allow files that don't exist to be URLs [GH-683] 2013-12-06 18:31:56 -08:00
Mitchell Hashimoto fa9804857a builder/amazon/chroot: block when obtaining lock [GH-689] 2013-12-06 18:28:48 -08:00
Mitchell Hashimoto b5503a81d6 Merge pull request #657 from mitchellh/docs-users-vars
website: user Variables in Intro
2013-12-06 18:18:26 -08:00
Mitchell Hashimoto 5e9cc73b1f Update CHANGELOG 2013-12-06 18:17:20 -08:00
Mitchell Hashimoto 68540cff09 Merge pull request #660 from CpuID/master
builder/amazon/ebs: AssociatePublicIpAddress for launching
2013-12-06 18:15:19 -08:00
Mitchell Hashimoto 85765dd386 Revert "Merge pull request #663 from ktruong7/public-AMI"
This reverts commit b2fc77870b, reversing
changes made to 4789d3acc8.

This is already possible by setting groups.
2013-12-06 18:09:05 -08:00
Mitchell Hashimoto b2fc77870b Merge pull request #663 from ktruong7/public-AMI
builder/amazon/all: added option to make AMI public
2013-12-06 18:05:45 -08:00
Mitchell Hashimoto 4789d3acc8 Update CHANGELOG 2013-12-06 17:59:45 -08:00
Mitchell Hashimoto d5341d7b00 Merge pull request #637 from johnbellone/master
builder/openstack: add ProxyUrl parameter for OpenStack builder
2013-12-06 17:58:15 -08:00
Mitchell Hashimoto 7ec1c8dc44 Merge pull request #681 from pcfens/qemu-img-formats
builder/qemu: qemu format img is invalid
2013-12-06 17:55:32 -08:00
Mitchell Hashimoto 0b0cada619 Merge pull request #685 from veshi/master
builder/vmware: trivial bug fix in mechanism to clean installation ISOs for VMware build...
2013-12-06 17:55:11 -08:00
adrian kalaveshi a2de093b72 Trivial bug fix in mechanism to clean installation ISOs for VMware builder
The resolution of Bug #608 still had issues.  This change removes a
superfluous period.

Testing Done:
- built packer with my change
- built VMware VMs and saw that the vmx file had the expected
  changes.
2013-12-05 21:36:34 +00:00
Phil Fenstermacher 43bf7b2859 Changed error message and docs to match code - qemu-img options are qcow2 and raw 2013-12-04 14:05:07 -05:00
Matthew Hooker 23c13e29b1 Merge pull request #671 from kyleconroy/patch-1
documentation/README: Point gox link to correct repository
2013-11-30 00:03:08 -08:00
Kyle Conroy b3dbdc8c04 Point gox link to correct repository 2013-11-30 00:01:18 -08:00
ktruong7 12245bd79c fixed format issue 2013-11-27 10:48:32 -05:00
ktruong7 a6a35e17df fixed format issues 2013-11-27 10:47:06 -05:00
ktruong7 892e718c52 Added option to make ami public automatically 2013-11-26 09:59:16 -05:00
Nathan Sullivan edff648f73 fix some debugging for PublicIpAddress 2013-11-26 15:03:45 +10:00
Nathan Sullivan 996a6bab01 remove excess debugging 2013-11-26 15:02:43 +10:00
Nathan Sullivan 53ea9b97bf revert whitespace changes - not necessary anymore 2013-11-26 15:01:57 +10:00
Nathan Sullivan 98f7e819fd working AssociatePublicIpAddress support 2013-11-26 14:45:06 +10:00
Nathan Sullivan 90f1e031fd goamz aspects of AssociatePublicIpAddress working now 2013-11-26 14:14:43 +10:00
Nathan Sullivan 2f53dbe03f reverting testing stuff 2013-11-26 13:46:32 +10:00
Nathan Sullivan 6e619d7351 lets try a string instead of a bool for AssociatePublicIpAddress 2013-11-26 13:44:39 +10:00
Nathan Sullivan 2ea61e69bc oops bugfix for work on https://github.com/mitchellh/packer/issues/578 2013-11-26 12:05:37 +10:00
Nathan Sullivan b3657db43e docs update for https://github.com/mitchellh/packer/issues/578 2013-11-26 11:41:39 +10:00
Nathan Sullivan da0edb2aa7 https://github.com/mitchellh/packer/issues/578 2013-11-26 11:32:08 +10:00
ktruong7 453dab7d26 Merge branch 'master' of github.com:mitchellh/packer 2013-11-25 10:54:15 -05:00
Jack Pearkes ecef4dc426 website: prettyprint variables examle in parallel builds 2013-11-25 13:51:32 +01:00
Jack Pearkes bdd75a6c6f website: user user varibles in the intro (parallel builds) 2013-11-25 13:47:23 +01:00
Jack Pearkes f36d53c60f website: use user variables in the intro (ec2) 2013-11-25 13:36:32 +01:00
Jack Pearkes 8776680b70 website: move iam policy documentation to the root amazon page 2013-11-25 13:27:38 +01:00
Mitchell Hashimoto f4f45b814f Merge pull request #649 from bpot/chroot_gotcha
website: document chroot running process gotcha
2013-11-22 09:44:41 -08:00
Mitchell Hashimoto 4c16865aaa Merge pull request #650 from mitchellh/readme-gox
readme: add a note about the gox dependency for compiling
2013-11-22 08:41:50 -08:00
Mitchell Hashimoto 62ddbec0f6 Merge pull request #651 from mwhooker/readme/bzr
README/developing packer: Mention the bazaar requirement.
2013-11-22 08:39:34 -08:00
Matthew Hooker 131686d10e README/developing packer
Mention the bazaar requirement.

https://launchpad.net/tomb is the only package which uses bazaar so far.
2013-11-22 03:17:16 -08:00
Jack Pearkes cc5fc6dfae readme: add a note about the gox dependency for compiling
I thought about putting it in compile.sh or devcompile.sh, but then
I realized if gox changes upstream it will be buried and potentially
confusing to update. Hence including the `-u` in the readme for
`go get`.
2013-11-22 11:31:02 +01:00
Bob Potter c454b19898 website: document chroot running process gotcha 2013-11-22 00:11:40 -06:00
Mitchell Hashimoto dc0b849891 Merge pull request #646 from jtopper/bundle_vol_command_website
website: Match default ec2-bundle-vol documented on the website to the one that's used by the code.
2013-11-21 14:42:02 -08:00
Jon Topper 09a978d97e Match ec2-bundle-vol on web to code
Issue #248 contained a PR which changes the way bundle_vol_command is
used by default. This change to the defaults was not reflected on the
website, so I encountered the same issue when making changes to the
bundle_vol_command in my config.
2013-11-21 18:29:19 +00:00
Mitchell Hashimoto b9be641f8c Merge pull request #641 from ubermuda/patch-1
website: typo in vmware docs' YAML front matter
2013-11-20 16:34:48 -08:00
Geoffrey Bachelet f2381d0735 Typo in vmware docs' YAML front matter 2013-11-20 22:05:22 +01:00
Mitchell Hashimoto 32e2623867 packer: don't change background color in UI 2013-11-19 21:31:54 -08:00
John Bellone 41b5a4f28a Website: Update timeout to reflect real default.
The default in the actual code is 5m.
2013-11-19 17:22:17 -05:00
Mitchell Hashimoto 01049413bd website: Fix typo with esxi config 2013-11-19 14:12:49 -08:00
Mitchell Hashimoto 879e8d3ef4 up version for dev 2013-11-19 13:49:26 -08:00
Mitchell Hashimoto 8a36f8c6d5 scripts: upload works with new build style 2013-11-19 13:30:09 -08:00
John Bellone dbf6acf1e7 Add ProxyUrl parameter for OpenStack builder.
In my particular case I need to use a separate HTTP proxy to access my
OpenStack API than what is set in the environment. This commit adds an
optional parameter to the builder configuration and overrides the
net/http client that is used by the gophercloud library.
2013-11-19 13:55:55 -05:00
ktruong7 7760a9d746 Merge branch 'master' of github.com:mitchellh/packer 2013-11-08 15:10:19 -05:00
ktruong7 064e68fe80 update 2013-11-07 11:22:24 -05:00
ktruong7 c5ed552e33 Added a description field for the vmware builder that is written to the vm after a build 2013-11-07 11:13:52 -05:00
32 changed files with 273 additions and 140 deletions
+25
View File
@@ -1,3 +1,28 @@
## 0.4.1 (December 7, 2013)
IMPROVEMENTS:
* builder/amazon/ebs: New option allows associating a public IP with
non-default VPC instances. [GH-660]
* builder/openstack: A "proxy\_url" setting was added to define an HTTP
proxy to use when building with this builder. [GH-637]
BUG FIXES:
* core: Don't change background color on CLI anymore, making things look
a tad nicer in some terminals.
* core: multiple ISO URLs works properly in all builders. [GH-683]
* builder/amazon/chroot: Block when obtaining file lock to allow
parallel builds. [GH-689]
* builder/amazon/instance: Add location flag to upload bundle command
so that building AMIs works out of us-east-1 [GH-679]
* builder/vmware: Cleanup of VMX keys works properly so cd-rom won't
get stuck with ISO. [GH-685]
* builder/vmware: File cleanup is more resilient to file delete races
with the operating system. [GH-675]
* provisioner/puppet-masterless: Check for hiera config path existence
properly. [GH-656]
## 0.4.0 (November 19, 2013)
FEATURES:
+9 -2
View File
@@ -74,8 +74,15 @@ installed (version 1.1+ is _required_). Make sure you have Go properly installed
including setting up your [GOPATH](http://golang.org/doc/code.html#GOPATH).
For some additional dependencies, Go needs [Mercurial](http://mercurial.selenic.com/)
to be installed. Packer itself doesn't require this but a dependency of a
dependency does.
and [Bazaar](http://bazaar.canonical.com/en/) to be installed.
Packer itself doesn't require these, but a dependency of a dependency does.
You'll also need [`gox`](https://github.com/mitchellh/gox)
to compile packer. You can install that with:
```
$ go get -u github.com/mitchellh/gox
```
Next, clone this repository into `$GOPATH/src/github.com/mitchellh/packer` and
then just type `make`. In a few moments, you'll have a working `packer` executable:
+1 -7
View File
@@ -3,7 +3,6 @@
package chroot
import (
"errors"
"os"
"syscall"
)
@@ -14,13 +13,8 @@ const LOCK_NB = 4
const LOCK_UN = 8
func lockFile(f *os.File) error {
err := syscall.Flock(int(f.Fd()), LOCK_EX|LOCK_NB)
err := syscall.Flock(int(f.Fd()), LOCK_EX)
if err != nil {
errno, ok := err.(syscall.Errno)
if ok && errno == syscall.EWOULDBLOCK {
return errors.New("file already locked")
}
return err
}
+1 -1
View File
@@ -39,7 +39,7 @@ func (s *StepFlock) Run(state multistep.StateBag) multistep.StepAction {
// LOCK!
if err := lockFile(f); err != nil {
err := fmt.Errorf("Error creating lock: %s", err)
err := fmt.Errorf("Error obtaining lock: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
+15 -14
View File
@@ -11,20 +11,21 @@ import (
// RunConfig contains configuration for running an instance from a source
// AMI and details on how to access that launched image.
type RunConfig struct {
SourceAmi string `mapstructure:"source_ami"`
IamInstanceProfile string `mapstructure:"iam_instance_profile"`
InstanceType string `mapstructure:"instance_type"`
UserData string `mapstructure:"user_data"`
UserDataFile string `mapstructure:"user_data_file"`
RawSSHTimeout string `mapstructure:"ssh_timeout"`
SSHUsername string `mapstructure:"ssh_username"`
SSHPort int `mapstructure:"ssh_port"`
SecurityGroupId string `mapstructure:"security_group_id"`
SecurityGroupIds []string `mapstructure:"security_group_ids"`
SubnetId string `mapstructure:"subnet_id"`
TemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"`
VpcId string `mapstructure:"vpc_id"`
AvailabilityZone string `mapstructure:"availability_zone"`
SourceAmi string `mapstructure:"source_ami"`
IamInstanceProfile string `mapstructure:"iam_instance_profile"`
InstanceType string `mapstructure:"instance_type"`
UserData string `mapstructure:"user_data"`
UserDataFile string `mapstructure:"user_data_file"`
RawSSHTimeout string `mapstructure:"ssh_timeout"`
SSHUsername string `mapstructure:"ssh_username"`
SSHPort int `mapstructure:"ssh_port"`
SecurityGroupId string `mapstructure:"security_group_id"`
SecurityGroupIds []string `mapstructure:"security_group_ids"`
SubnetId string `mapstructure:"subnet_id"`
AssociatePublicIpAddress bool `mapstructure:"associate_public_ip_address"`
TemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"`
VpcId string `mapstructure:"vpc_id"`
AvailabilityZone string `mapstructure:"availability_zone"`
// Unexported fields that are calculated from others
sshTimeout time.Duration
+5 -1
View File
@@ -20,7 +20,11 @@ func SSHAddress(e *ec2.EC2, port int) func(multistep.StateBag) (string, error) {
if i.DNSName != "" {
host = i.DNSName
} else if i.VpcId != "" {
host = i.PrivateIpAddress
if i.PublicIpAddress != "" {
host = i.PublicIpAddress
} else {
host = i.PrivateIpAddress
}
}
if host != "" {
@@ -10,16 +10,17 @@ import (
)
type StepRunSourceInstance struct {
Debug bool
ExpectedRootDevice string
InstanceType string
UserData string
UserDataFile string
SourceAMI string
IamInstanceProfile string
SubnetId string
AvailabilityZone string
BlockDevices BlockDevices
Debug bool
ExpectedRootDevice string
InstanceType string
UserData string
UserDataFile string
SourceAMI string
IamInstanceProfile string
SubnetId string
AssociatePublicIpAddress bool
AvailabilityZone string
BlockDevices BlockDevices
instance *ec2.Instance
}
@@ -47,17 +48,18 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
}
runOpts := &ec2.RunInstances{
KeyName: keyName,
ImageId: s.SourceAMI,
InstanceType: s.InstanceType,
UserData: []byte(userData),
MinCount: 0,
MaxCount: 0,
SecurityGroups: securityGroups,
IamInstanceProfile: s.IamInstanceProfile,
SubnetId: s.SubnetId,
BlockDevices: s.BlockDevices.BuildLaunchDevices(),
AvailZone: s.AvailabilityZone,
KeyName: keyName,
ImageId: s.SourceAMI,
InstanceType: s.InstanceType,
UserData: []byte(userData),
MinCount: 0,
MaxCount: 0,
SecurityGroups: securityGroups,
IamInstanceProfile: s.IamInstanceProfile,
SubnetId: s.SubnetId,
AssociatePublicIpAddress: s.AssociatePublicIpAddress,
BlockDevices: s.BlockDevices.BuildLaunchDevices(),
AvailZone: s.AvailabilityZone,
}
ui.Say("Launching a source AWS instance...")
@@ -114,6 +116,10 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
ui.Message(fmt.Sprintf("Public DNS: %s", s.instance.DNSName))
}
if s.instance.PublicIpAddress != "" {
ui.Message(fmt.Sprintf("Public IP: %s", s.instance.PublicIpAddress))
}
if s.instance.PrivateIpAddress != "" {
ui.Message(fmt.Sprintf("Private IP: %s", s.instance.PrivateIpAddress))
}
+11 -10
View File
@@ -93,16 +93,17 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
VpcId: b.config.VpcId,
},
&awscommon.StepRunSourceInstance{
Debug: b.config.PackerDebug,
ExpectedRootDevice: "ebs",
InstanceType: b.config.InstanceType,
UserData: b.config.UserData,
UserDataFile: b.config.UserDataFile,
SourceAMI: b.config.SourceAmi,
IamInstanceProfile: b.config.IamInstanceProfile,
SubnetId: b.config.SubnetId,
AvailabilityZone: b.config.AvailabilityZone,
BlockDevices: b.config.BlockDevices,
Debug: b.config.PackerDebug,
ExpectedRootDevice: "ebs",
InstanceType: b.config.InstanceType,
UserData: b.config.UserData,
UserDataFile: b.config.UserDataFile,
SourceAMI: b.config.SourceAmi,
IamInstanceProfile: b.config.IamInstanceProfile,
SubnetId: b.config.SubnetId,
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
AvailabilityZone: b.config.AvailabilityZone,
BlockDevices: b.config.BlockDevices,
},
&common.StepConnectSSH{
SSHAddress: awscommon.SSHAddress(ec2conn, b.config.SSHPort),
+12 -10
View File
@@ -74,6 +74,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
"-s {{.SecretKey}} " +
"-d {{.BundleDirectory}} " +
"--batch " +
"--location {{.Region}} " +
"--retry"
}
@@ -196,16 +197,17 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
VpcId: b.config.VpcId,
},
&awscommon.StepRunSourceInstance{
Debug: b.config.PackerDebug,
ExpectedRootDevice: "instance-store",
InstanceType: b.config.InstanceType,
IamInstanceProfile: b.config.IamInstanceProfile,
UserData: b.config.UserData,
UserDataFile: b.config.UserDataFile,
SourceAMI: b.config.SourceAmi,
SubnetId: b.config.SubnetId,
AvailabilityZone: b.config.AvailabilityZone,
BlockDevices: b.config.BlockDevices,
Debug: b.config.PackerDebug,
ExpectedRootDevice: "instance-store",
InstanceType: b.config.InstanceType,
IamInstanceProfile: b.config.IamInstanceProfile,
UserData: b.config.UserData,
UserDataFile: b.config.UserDataFile,
SourceAMI: b.config.SourceAmi,
SubnetId: b.config.SubnetId,
AssociatePublicIpAddress: b.config.AssociatePublicIpAddress,
AvailabilityZone: b.config.AvailabilityZone,
BlockDevices: b.config.BlockDevices,
},
&common.StepConnectSSH{
SSHAddress: awscommon.SSHAddress(ec2conn, b.config.SSHPort),
+10 -1
View File
@@ -11,6 +11,7 @@ type uploadCmdData struct {
BucketName string
BundleDirectory string
ManifestPath string
Region string
SecretKey string
}
@@ -23,12 +24,20 @@ func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction {
manifestPath := state.Get("manifest_path").(string)
ui := state.Get("ui").(packer.Ui)
var err error
region, err := config.Region()
if err != nil {
err := fmt.Errorf("Error retrieving region: %s", err)
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
}
config.BundleUploadCommand, err = config.tpl.Process(config.BundleUploadCommand, uploadCmdData{
AccessKey: config.AccessKey,
BucketName: config.S3Bucket,
BundleDirectory: config.BundleDestination,
ManifestPath: manifestPath,
Region: region.Name,
SecretKey: config.SecretKey,
})
if err != nil {
+17
View File
@@ -4,6 +4,8 @@ import (
"fmt"
"github.com/mitchellh/packer/packer"
"github.com/rackspace/gophercloud"
"net/http"
"net/url"
"os"
)
@@ -14,6 +16,7 @@ type AccessConfig struct {
Project string `mapstructure:"project"`
Provider string `mapstructure:"provider"`
RawRegion string `mapstructure:"region"`
ProxyUrl string `mapstructure:"proxy_url"`
}
// Auth returns a valid Auth object for access to openstack services, or
@@ -23,6 +26,7 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
password := c.Password
project := c.Project
provider := c.Provider
proxy := c.ProxyUrl
if username == "" {
username = os.Getenv("SDK_USERNAME")
@@ -47,6 +51,19 @@ func (c *AccessConfig) Auth() (gophercloud.AccessProvider, error) {
authoptions.TenantName = project
}
// For corporate networks it may be the case where we want our API calls
// to be sent through a separate HTTP proxy than external traffic.
if proxy != "" {
url, err := url.Parse(proxy)
if err != nil {
return nil, err
}
// The gophercloud.Context has a UseCustomClient method which
// would allow us to override with a new instance of http.Client.
http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(url)}
}
return gophercloud.Authenticate(provider, authoptions)
}
+1 -1
View File
@@ -217,7 +217,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
if !(b.config.Format == "qcow2" || b.config.Format == "raw") {
errs = packer.MultiErrorAppend(
errs, errors.New("invalid format, only 'qcow2' or 'img' are allowed"))
errs, errors.New("invalid format, only 'qcow2' or 'raw' are allowed"))
}
if !(b.config.Accelerator == "kvm" || b.config.Accelerator == "xen") {
+2 -1
View File
@@ -314,7 +314,8 @@ func (d *ESX5Driver) checkGuestIPHackEnabled() error {
}
if record["IntValue"] != "1" {
return errors.New("GuestIPHack is required, enable with:\n" +
return errors.New(
"GuestIPHack is required, enable by running this on the ESX machine:\n" +
"esxcli system settings advanced set -o /Net/GuestIPHack -i 1")
}
+6 -2
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"os"
"path/filepath"
)
@@ -48,8 +49,11 @@ func (stepCleanFiles) Run(state multistep.StateBag) multistep.StepAction {
if !keep {
ui.Message(fmt.Sprintf("Deleting: %s", path))
if err = dir.Remove(path); err != nil {
state.Put("error", err)
return multistep.ActionHalt
// Only report the error if the file still exists
if _, serr := os.Stat(path); serr == nil || !os.IsNotExist(serr) {
state.Put("error", err)
return multistep.ActionHalt
}
}
}
}
+2 -2
View File
@@ -55,12 +55,12 @@ func (s stepCleanVMX) Run(state multistep.StateBag) multistep.StepAction {
continue
}
filenameKey := match + ".filename"
filenameKey := match + "filename"
if filename, ok := vmxData[filenameKey]; ok {
if filename == isoPath {
// Change the CD-ROM device back to auto-detect to eject
vmxData[filenameKey] = "auto detect"
vmxData[match+".devicetype"] = "cdrom-raw"
vmxData[match+"devicetype"] = "cdrom-raw"
}
}
}
+12 -12
View File
@@ -105,21 +105,21 @@ func DownloadableURL(original string) (string, error) {
url.Path = strings.Replace(url.Path, `\`, `/`, -1)
}
if _, err := os.Stat(url.Path); err != nil {
return "", err
}
// Only do the filepath transformations if the file appears
// to actually exist.
if _, err := os.Stat(url.Path); err == nil {
url.Path, err = filepath.Abs(url.Path)
if err != nil {
return "", err
}
url.Path, err = filepath.Abs(url.Path)
if err != nil {
return "", err
}
url.Path, err = filepath.EvalSymlinks(url.Path)
if err != nil {
return "", err
}
url.Path, err = filepath.EvalSymlinks(url.Path)
if err != nil {
return "", err
url.Path = filepath.Clean(url.Path)
}
url.Path = filepath.Clean(url.Path)
}
// Make sure it is lowercased
+2 -2
View File
@@ -144,8 +144,8 @@ func TestDownloadableURL_FilePaths(t *testing.T) {
for _, prefix := range []string{"", "file://"} {
// Nonexistent file
_, err = DownloadableURL(prefix + "i/dont/exist")
if err == nil {
t.Fatal("expected err")
if err != nil {
t.Fatalf("err: %s", err)
}
// Good file
+1 -1
View File
@@ -106,7 +106,7 @@ func (u *ColoredUi) colorize(message string, color UiColor, bold bool) string {
attr = 1
}
return fmt.Sprintf("\033[%d;%d;40m%s\033[0m", attr, color, message)
return fmt.Sprintf("\033[%d;%dm%s\033[0m", attr, color, message)
}
func (u *ColoredUi) supportsColors() bool {
+3 -3
View File
@@ -19,19 +19,19 @@ func TestColoredUi(t *testing.T) {
ui.Say("foo")
result := readWriter(bufferUi)
if result != "\033[1;33;40mfoo\033[0m\n" {
if result != "\033[1;33mfoo\033[0m\n" {
t.Fatalf("invalid output: %s", result)
}
ui.Message("foo")
result = readWriter(bufferUi)
if result != "\033[0;33;40mfoo\033[0m\n" {
if result != "\033[0;33mfoo\033[0m\n" {
t.Fatalf("invalid output: %s", result)
}
ui.Error("foo")
result = readWriter(bufferUi)
if result != "\033[1;31;40mfoo\033[0m\n" {
if result != "\033[1;31mfoo\033[0m\n" {
t.Fatalf("invalid output: %s", result)
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ import (
var GitCommit string
// The version of packer.
const Version = "0.4.0"
const Version = "0.4.1"
// Any pre-release marker for the version. If this is "" (empty string),
// then it means that it is a final release. Otherwise, this is the
+1 -1
View File
@@ -145,7 +145,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
// Validation
if p.config.HieraConfigPath != "" {
info, err := os.Stat(p.config.ManifestFile)
info, err := os.Stat(p.config.HieraConfigPath)
if err != nil {
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("hiera_config_path is invalid: %s", err))
+1 -1
View File
@@ -22,7 +22,7 @@ if [ -z $BINTRAY_API_KEY ]; then
exit 1
fi
for ARCHIVE in ./pkg/${VERSION}/dist/*; do
for ARCHIVE in ./pkg/dist/*; do
ARCHIVE_NAME=$(basename ${ARCHIVE})
echo Uploading: $ARCHIVE_NAME
@@ -184,39 +184,29 @@ out of your AMI builds.
Packer properly obtains a process lock for the parallelism-sensitive parts
of its internals such as finding an available device.
## Using an IAM Instance Profile
## Gotchas
If AWS keys are not specified in the template or through environment variables
Packer will use credentials provided by the instance's IAM profile, if it has one.
One of the difficulties with using the chroot builder is that your provisioning
scripts must not leave any processes running or packer will be unable to unmount
the filesystem.
The following policy document provides the minimal set permissions necessary for Packer to work:
For debian based distributions you can setup a [policy-rc.d](http://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt) file which will
prevent packages installed by your provisioners from starting services:
<pre class="prettyprint">
{
"Statement": [{
"Effect": "Allow",
"Action" : [
"ec2:AttachVolume",
"ec2:CreateVolume",
"ec2:DeleteVolume",
"ec2:DescribeVolumes",
"ec2:DetachVolume",
"ec2:DescribeInstances",
"ec2:CreateSnapshot",
"ec2:DeleteSnapshot",
"ec2:DescribeSnapshots",
"ec2:DescribeImages",
"ec2:RegisterImage",
"ec2:CreateTags"
],
"Resource" : "*"
}]
"type": "shell",
"inline": [
"echo '#!/bin/sh' > /usr/sbin/policy-rc.d",
"echo 'exit 101' >> /usr/sbin/policy-rc.d",
"chmod a+x /usr/sbin/policy-rc.d"
]
},
# ...
{
"type": "shell",
"inline": [
"rm -f /usr/sbin/policy-rc.d"
]
}
</pre>
Depending on what setting you use the following Actions might have to be allowed as well:
* `ec2:ModifyImageAttribute` when using `ami_description`
@@ -111,6 +111,10 @@ Optional:
* `subnet_id` (string) - If using VPC, the ID of the subnet, such as
"subnet-12345def", where Packer will launch the EC2 instance.
* `associate_public_ip_address` (bool) - If using a non-default VPC, public
IP addresses are not provided by default. If this is toggled, your new
instance will get a Public IP.
* `tags` (object of key/value strings) - Tags applied to the AMI.
* `user_data` (string) - User data to apply when launching the instance.
@@ -150,6 +150,10 @@ Optional:
* `subnet_id` (string) - If using VPC, the ID of the subnet, such as
"subnet-12345def", where Packer will launch the EC2 instance.
* `associate_public_ip_address` (bool) - If using a non-default VPC, public
IP addresses are not provided by default. If this is toggled, your new
instance will get a Public IP.
* `tags` (object of key/value strings) - Tags applied to the AMI.
* `user_data` (string) - User data to apply when launching the instance.
@@ -238,7 +242,7 @@ sudo -n ec2-bundle-vol \
-u {{.AccountId}} \
-c {{.CertPath}} \
-r {{.Architecture}} \
-e {{.PrivatePath}} \
-e {{.PrivatePath}}/* \
-d {{.Destination}} \
-p {{.Prefix}} \
--batch
@@ -269,6 +273,7 @@ sudo -n ec2-upload-bundle \
-s {{.SecretKey}} \
-d {{.BundleDirectory}} \
--batch \
--location {{.Region}} \
--retry
```
@@ -30,3 +30,40 @@ AMI. Packer supports the following builders at the moment:
<a href="/docs/builders/amazon-ebs.html">amazon-ebs builder</a>. It is
much easier to use and Amazon generally recommends EBS-backed images nowadays.
</div>
## Using an IAM Instance Profile
If AWS keys are not specified in the template or through environment variables
Packer will use credentials provided by the instance's IAM profile, if it has one.
The following policy document provides the minimal set permissions necessary for Packer to work:
<pre class="prettyprint">
{
"Statement": [{
"Effect": "Allow",
"Action" : [
"ec2:AttachVolume",
"ec2:CreateVolume",
"ec2:DeleteVolume",
"ec2:DescribeVolumes",
"ec2:DetachVolume",
"ec2:DescribeInstances",
"ec2:CreateSnapshot",
"ec2:DeleteSnapshot",
"ec2:DescribeSnapshots",
"ec2:DescribeImages",
"ec2:RegisterImage",
"ec2:CreateTags"
],
"Resource" : "*"
}]
}
</pre>
Depending on what setting you use the following Actions might have to be allowed as well:
* `ec2:ModifyImageAttribute` when using `ami_description`
@@ -59,7 +59,7 @@ Optional:
* `ssh_timeout` (string) - The time to wait for SSH to become available
before timing out. The format of this value is a duration such as "5s"
or "5m". The default SSH timeout is "1m".
or "1m". The default SSH timeout is "5m".
* `ssh_username` (string) - The username to use in order to communicate
over SSH to the running server. The default is "root".
@@ -115,7 +115,7 @@ Optional:
commands or kickstart type scripts must have proper adjustments for
resulting device names. The Qemu builder uses "virtio" by default.
* `format` (string) - Either "qcow2" or "img", this specifies the output
* `format` (string) - Either "qcow2" or "raw", this specifies the output
format of the virtual machine image. This defaults to "qcow2".
* `headless` (bool) - Packer defaults to building virtual machines by
@@ -87,7 +87,8 @@ Optional:
The default is "1", which corresponds to a growable virtual disk split in
2GB files. This option is for advanced usage, modify only if you
know what you're doing. For more information, please consult the
[Virtual Disk Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf).
[Virtual Disk Manager User's Guide](http://www.vmware.com/pdf/VirtualDiskManager.pdf)
for desktop VMware clients. For ESXi, refer to the proper ESXi documentation.
* `floppy_files` (array of strings) - A list of files to put onto a floppy
disk that is attached when the VM is booted for the first time. This is
@@ -152,7 +153,7 @@ Optional:
access the remote machine. By default this is empty. This only has an
effect if `remote_type` is enabled.
* `remote_user` (string) - The username for the SSH user that will access
* `remote_username` (string) - The username for the SSH user that will access
the remote machine. This is required if `remote_type` is enabled.
* `skip_compaction` (bool) - VMware-created disks are defragmented
@@ -46,10 +46,14 @@ briefly. Create a file `example.json` and fill it with the following contents:
<pre class="prettyprint">
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "YOUR KEY HERE",
"secret_key": "YOUR SECRET KEY HERE",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-de0d9eb7",
"instance_type": "t1.micro",
@@ -59,9 +63,11 @@ briefly. Create a file `example.json` and fill it with the following contents:
}
</pre>
Please fill in the `access_key` and `secret_key` with the proper values
for your account. Your security credentials can be found on
[this page](https://console.aws.amazon.com/iam/home?#security_credential).
When building, you'll pass in the `aws_access_key` and `aws_access_key` as
a [user variable](/docs/templates/user-variables.html), keeping your secret
keys out of the template. You can create security credentials
on [this page](https://console.aws.amazon.com/iam/home?#security_credential).
An example IAM policy document can be found in the [Amazon EC2 builder docs](/docs/builders/amazon.html).
This is a basic template that is ready-to-go. It should be immediately recognizable
as a normal, basic JSON object. Within the object, the `builders` section
@@ -106,7 +112,10 @@ should look similar to below. Note that this process typically takes a
few minutes.
```
$ packer build example.json
$ packer build \
-var 'aws_access_key=YOUR ACCESS KEY' \
-var 'aws_secret_key=YOUR SECRET KEY' \
example.json
==> amazon-ebs: amazon-ebs output will be in this color.
==> amazon-ebs: Creating temporary keypair for this instance...
@@ -63,13 +63,23 @@ array.
<pre class="prettyprint">
{
"type": "digitalocean",
"api_key": "INSERT API KEY HERE",
"client_id": "INSERT CLIENT ID HERE"
"api_key": "{{user `do_api_key`}}",
"client_id": "{{user `do_client_id`}}"
}
</pre>
Fill in your `api_key` and `client_id` for DigitalOcean as necessary.
The entire template should now [look like this](https://gist.github.com/mitchellh/51a447e38e7e496eb29c).
You'll also need to modify the `variables` section of the template
to include the access keys for DigitalOcean.
<pre class="prettyprint">
"variables": {
...
"do_api_key": "",
"do_client_id": ""
}
</pre>
The entire template should now [look like this](https://gist.github.com/pearkes/cc5f8505eee5403a43a6).
Additional builders are simply added to the `builders` array in the template.
This tells Packer to build multiple images. The builder `type` values don't
@@ -87,13 +97,18 @@ manual that contains a listing of all the available configuration options.
## Build
Now run `packer build example.json`. The output is too verbose to include
Now run `packer build` with your user variables. The output is too verbose to include
all of it, but a portion of it is reproduced below. Note that the ordering
and wording of the lines may be slightly different, but the effect is the
same.
```
$ packer build example.json
$ packer build \
-var 'aws_access_key=YOUR ACCESS KEY' \
-var 'aws_secret_key=YOUR SECRET KEY' \
-var 'do_api_key=YOUR API KEY' \
-var 'do_client_id=YOUR CLIENT ID' \
example.json
==> amazon-ebs: amazon-ebs output will be in this color.
==> digitalocean: digitalocean output will be in this color.
@@ -37,6 +37,7 @@ block below.
<pre class="prettyprint">
{
"variables": [...],
"builders": [...],
"provisioners": [{