627 Commits

Author SHA1 Message Date
Matthew Hooker
f9f9d82419 Merge pull request from artburkart/closes_3320
Adds `force_delete_snapshot` flag
2016-11-30 12:53:34 -08:00
Arthur Burkart
5b59f56cdb Adds force_delete_snapshot flag
This PR adds the ability for Packer to clean up snapshots in addition to
deregistering AMIs at build time.

To test this, I used the following `test.json` file:

```json
{
  "builders": [
    {
      "type": "amazon-ebs",
      "region": "us-east-1",
      "source_ami": "ami-fce3c696",
      "ami_name": "packer-test",
      "instance_type": "m3.medium",
      "ssh_username": "ubuntu",
      "vpc_id": "some-vpc-id",
      "subnet_id": "some-subnet-routed-through-igw",
      "security_group_id": "some-security-group-with-port-22-access",
      "force_delete_snapshot": true
    }
  ],
  "provisioners": [
    {
      "type": "shell-local",
      "command": "echo 'hello'"
    }
  ]
}

```

I appreciate any constructive feedbakc that can be given. Cheers!
2016-11-29 23:39:36 -05:00
Rickard von Essen
99ee610afa
builder/amazon: Fix SSH Agent
Closes 
2016-11-29 22:33:53 +01:00
Matthew Hooker
aedf4ca465 Merge pull request from mitchellh/ebsvoluemartifact
add ebsvolume artifact
2016-11-28 15:50:03 -08:00
Matthew Hooker
50267572a4
add ebsvolume artifact 2016-11-28 15:26:09 -08:00
Rickard von Essen
a09f20f996 Merge pull request from artburkart:closes_3908
Closes : Adds snapshot tag overrides
2016-11-26 17:54:00 +01:00
Arthur Burkart
0c7e73b1cf
Implements Snapshot tagging
While implementing my acceptance test, I stumbled upon a comment stating
that snapshot deletion should also be implemented, so I snuck that in. I
can't help but wonder if there is some generic logic that is implemented
a few times throughout the packer code base that could maybe better serve
us if it were abstracted to the common package.
2016-11-26 17:48:26 +01:00
Rickard von Essen
17eda06d61
Fixed formatting 2016-11-24 21:12:20 +01:00
ephemeralsnow
e53f4be005 Fix 'The AssociatePublicIpAddress parameter is only supported for VPC launches.' 2016-11-24 17:01:32 +01:00
Rickard von Essen
96e9a8e6e9 Removed default value for ssh_username 2016-11-17 22:30:34 +01:00
Arthur Burkart
2e65867cba Closes : Adds snapshot tag overrides
This commit adds the ability to configure unique tags on snapshots
that are separate from the tags defined on the AMI. Anything applied
to the AMI will also be applied to the snapshots, but `snapshot_tags`
will override and append tags to the tags already applied to the snapshots
2016-11-15 23:16:27 -05:00
Matthew Hooker
9a91ae4e8f
fix new session error when creating cred chain.
the old and deprecated method won't error and so is safe to use
even if we're not in amazon.
2016-11-14 11:39:22 -08:00
Matthew Hooker
d81c06765d
fix go vet issue.
closes 
2016-11-07 10:17:53 -08:00
Matthew Hooker
f3f5f89fe6 Merge pull request from mitchellh/filterday
builder/amazon-ebs: show ami id found from filter
2016-11-02 12:25:46 -07:00
Matthew Hooker
60c459d6c8 Merge pull request from mitchellh/newsession
aws-sdk: use session.NewSession
2016-11-02 12:25:14 -07:00
Matthew Hooker
9bc23ea512 Merge pull request from mitchellh/waitfail
Waitfail
2016-11-02 12:21:51 -07:00
James Nugent
36c09af992 builder/amazon: Add tests for the ebs-volume builder
These smoke tests are effectively a mirror of the EBS builder tests.
2016-11-02 12:56:39 -04:00
James Nugent
b1ff8c3bfc builder/amazon: Add ebs-volume builder
This commit adds a builder that works like EBS builders, except does not
create an AMI, and instead is intended to create EBS volumes in an
initialized state. For example, the following template can be used to
create and export a set of 3 EBS Volumes in a ZFS zpool named `data` for
importing by instances running production systems:

```
{
	"variables": {
		"aws_access_key_id": "{{ env `AWS_ACCESS_KEY_ID` }}",
		"aws_secret_access_key": "{{ env `AWS_SECRET_ACCESS_KEY` }}",
		"region": "{{ env `AWS_REGION` }}",
		"source_ami": "{{ env `PACKER_SOURCE_AMI` }}",
		"vpc_id": "{{ env `PACKER_VPC_ID` }}",
		"subnet_id": "{{ env `PACKER_SUBNET_ID` }}"
	},
	"builders": [{
		"type": "amazon-ebs-volume",
		"access_key": "{{ user `aws_access_key_id` }}",
		"secret_key": "{{ user `aws_secret_access_key` }}",
		"region": "{{user `region`}}",
		"spot_price_auto_product": "Linux/UNIX (Amazon VPC)",

		"ssh_pty": true,
		"instance_type": "t2.medium",
		"vpc_id": "{{user `vpc_id` }}",
		"subnet_id": "{{user `subnet_id` }}",
		"associate_public_ip_address": true,
		"source_ami": "{{user `source_ami` }}",
		"ssh_username": "ubuntu",
		"ssh_timeout": "5m",

		"ebs_volumes": [
			{
				"device_name": "/dev/xvdf",
				"delete_on_termination": false,
				"volume_size": 10,
				"volume_type": "gp2",
				"tags": {
					"Name": "TeamCity-Data1",
					"zpool": "data",
					"Component": "TeamCity"
				}
			},
			{
				"device_name": "/dev/xvdg",
				"delete_on_termination": false,
				"volume_size": 10,
				"volume_type": "gp2",
				"tags": {
					"Name": "TeamCity-Data2",
					"zpool": "data",
					"Component": "TeamCity"
				}
			},
			{
				"device_name": "/dev/xvdh",
				"delete_on_termination": false,
				"volume_size": 10,
				"volume_type": "gp2",
				"tags": {
					"Name": "TeamCity-Data3",
					"zpool": "data",
					"Component": "TeamCity"
				}
			}
		]
	}],
	"provisioners": [
	{
		"type": "shell",
		"start_retry_timeout": "10m",
		"inline": [
			"DEBIAN_FRONTEND=noninteractive sudo apt-get update",
			"DEBIAN_FRONTEND=noninteractive sudo apt-get install -y zfs",
			"lsblk",
			"sudo parted /dev/xvdf --script mklabel GPT",
			"sudo parted /dev/xvdg --script mklabel GPT",
			"sudo parted /dev/xvdh --script mklabel GPT",
			"sudo zpool create -m none data raidz xvdf xvdg xvdh",
			"sudo zpool status",
			"sudo zpool export data",
			"sudo zpool status"
		]
	}
	]
}
```

StepModifyInstance and StepStopInstance are now shared between EBS and
EBS-Volume builders - move them into the AWS common directory and rename
them to indicate that they only apply to EBS-backed builders.
2016-11-02 12:56:39 -04:00
Matthew Hooker
d47e47cf1f rewrite to not use private aws package 2016-11-01 18:29:18 -07:00
Matthew Hooker
c4c46c349e implement security group waiter 2016-11-01 18:10:42 -07:00
Matthew Hooker
970b37077e Merge pull request from jen20/ssh-agent
builder/amazon: Allow use of local SSH Agent
2016-11-01 17:27:37 -07:00
Matthew Hooker
48bdae93d1 aws-sdk: use session.NewSession 2016-11-01 15:53:04 -07:00
Matthew Hooker
83b57b98ac show ami id found from filter 2016-11-01 15:26:43 -07:00
Matthew Hooker
d920b3fbf4 run gofmt 2016-11-01 14:08:04 -07:00
Matthew Hooker
0dd7d7ff3b fix error message 2016-10-31 16:44:18 -07:00
Ganesh kumar Sankaran
b9c6139d67 AWS async operations sometimes takes long times, if there are multiple parallel builds, polling at 2 second frequency will exceed the request limit. Allow 2 seconds to be overwritten with AWS_POLL_DELAY_SECONDS 2016-10-31 16:44:18 -07:00
Rickard von Essen
d66490ebfd
Properly cleanup AWS temporary key pairs
Closes  - Amazon key pair no longer cleaned up at end of build
2016-10-27 23:06:13 +02:00
Rickard von Essen
d16d5d9686 Merge pull request from ChrisLundquist/dynamic-source-ami
Dynamic source ami
2016-10-25 21:24:41 +02:00
Richard Owen
adddc60a1d Fix typo in encrypted ami step log message 2016-10-25 16:01:01 +01:00
James Nugent
395d88941c amazon: Allow SSH Agent auth for existing key pair
This commit allows SSH Agent authentication to be used with an existing
key pair defined in AWS.
2016-10-23 22:26:14 -05:00
James Nugent
7425fef2c7 builder/amazon: Allow use of local SSH Agent
This commit adds an option to use the local SSH Agent to authenticate
connections to source instances started by the the EBS and Instance
Store builders.

This is of use when the source AMI _already_ has configuration for
authorized SSH keys - for example if one uses an SSH certificate
authority.

A further extension (not implemented in this commit) is to allow SSH
agent use with a pre-defined key pair, in order to allow keys with
passphrases to be used without giving the passphrase to Packer.
2016-10-23 21:43:47 -05:00
Asif R Choudhury
48d94342ba Add us-east-2 (Ohio) AWS region 2016-10-17 21:31:41 -05:00
Rickard von Essen
c273bd6beb Merge pull request from jeremy-asher/amazon-ebs-delete-volumes-on-failure
clean up EBS volumes on failure
2016-10-15 14:57:15 +02:00
Rickard von Essen
0be3034e82 Merge pull request from rickard-von-essen/amz-ssh
builder/amazon: Allow using ssh_private_key_file and ssh_password
2016-10-03 10:22:15 +02:00
Rickard von Essen
acc2689b49
builder/amazon: Allow using ssh_private_key_file and ssh_password
This adds support for using amazon-ebs/amazon-instance builder without
a keypair. If a ssh_private_key_file is supplied without a
ssh_keypair_name no temporary ssh keypair is created. If ssh_password is
used no temporary ssh keypair is created and the password is used when
trying to connect.

Closes 
Closes 
2016-10-02 22:20:36 +02:00
Rickard von Essen
cffc8e892c Merge pull request from ahamidi/encrypted-boot-volume
Create AMI with encrypted boot volume
2016-10-02 01:02:43 +02:00
Chris Lundquist
9379cbc5d9 [dynamic-source-ami] support instance builder too 2016-10-01 23:01:01 +00:00
Chris Lundquist
ab3500b45c [dynamic-source-ami] support chroot builder 2016-10-01 22:56:09 +00:00
Chris Lundquist
1b4895c684 Merge remote-tracking branch 'origin/master' into dynamic-source-ami 2016-10-01 22:20:17 +00:00
Matthew Hooker
a9abe43325 builder/amazon: add retry login when creating tags.
also move Retry from builder/googlecompute/common to common/retry
2016-09-28 18:22:31 -07:00
Rickard von Essen
13c9db5dd5 Merge pull request from orivej/on-error
Add -on-error command line argument to allow preserving artifacts on builder errors
2016-09-20 12:28:14 +02:00
Jeremy Asher
aea05f6485 fix nil pointer dereference in amazon-chroot
The refactor of StepRegisterAmi to add the from_scratch parameter
incorrectly replaced iteration over image.BlockDeviceMappings with
iteration over the new mapping array when not using from_scratch.  This
fixes the regression and renames the parameters to newMappings and
mappings for better clarity.
2016-09-16 18:35:36 -07:00
Orivej Desh
6762965696 Add -on-error command line argument to allow preserving artifacts on builder errors
Resolves 
2016-09-16 12:15:00 +00:00
Rickard von Essen
3b47893eb8
builder/amazon: reverted wrongly modified ssh_test's. 2016-09-14 20:26:09 +02:00
Rickard von Essen
067155c344
builder/amazon: guard aginst empty/nil PrivateIpAddress and updated tests. 2016-09-14 00:16:09 +02:00
Rickard von Essen
7f4bee737c Merge pull request from tarrall/issue3751-ssh-privateip-classic
builder/amazon: Honor ssh_private_ip flag in EC2-Classic, not just VPC
2016-09-13 22:54:00 +02:00
Rickard von Essen
120b60ae37 Merge pull request from dpiddy/amazon-ssh-retry-fix
amazon/common/ssh: fix saving of instance to state
2016-09-12 15:04:35 +02:00
Dan Peterson
c7af9a67bc amazon/common/ssh: fix saving of instance to state
Fixes 
2016-09-09 10:16:53 -03:00
Jeremy Asher
1c392b23f9 generate warnings for unused options with from_scratch 2016-09-03 12:32:43 -07:00
Jeremy Asher
ef0c7543e1 add amazon-chroot post mount commands
This adds an additional PostMountCommands step to the amazon-chroot
builder which executes after the volume is mounted, but before the
extra chroot mounts and copy step.
2016-09-03 12:32:41 -07:00