packer-cn/website/source/docs/post-processors/atlas.html.markdown

118 lines
4.1 KiB
Markdown
Raw Normal View History

2015-02-03 19:20:32 -05:00
---
2015-07-22 22:31:00 -04:00
description: |
The Atlas post-processor for Packer receives an artifact from a Packer build and
uploads it to Atlas. Atlas hosts and serves artifacts, allowing you to version
and distribute them in a simple way.
layout: docs
page_title: 'Atlas Post-Processor'
...
2015-02-03 19:20:32 -05:00
# Atlas Post-Processor
Type: `atlas`
2015-07-24 17:54:46 -04:00
The Atlas post-processor uploads artifacts from your packer builds to Atlas for
hosting. Artifacts hosted in Atlas are are automatically made available for use
with Vagrant and Terraform, and Atlas provides additional features for managing
versions and releases. [Learn more about packer in
Atlas.](https://atlas.hashicorp.com/help/packer/features)
2015-07-24 17:54:46 -04:00
You can also use the push command to [run packer builds in
Atlas](/docs/command-line/push.html). The push command and Atlas post-processor
can be used together or independently.
2015-02-03 19:20:32 -05:00
## Workflow
To take full advantage of Packer and Atlas, it's important to understand the
2015-07-22 22:31:00 -04:00
workflow for creating artifacts with Packer and storing them in Atlas using this
post-processor. The goal of the Atlas post-processor is to streamline the
distribution of public or private artifacts by hosting them in a central
location in Atlas.
2015-02-03 19:20:32 -05:00
Here is an example workflow:
2015-07-24 17:54:46 -04:00
1. Packer builds an AMI with the [Amazon AMI
builder](/docs/builders/amazon.html)
2015-07-22 23:25:58 -04:00
2. The `atlas` post-processor takes the resulting AMI and uploads it to Atlas.
The `atlas` post-processor is configured with the name of the AMI, for
example `hashicorp/foobar`, to create the artifact in Atlas or update the
version if the artifact already exists
3. The new version is ready and available to be used in deployments with a tool
like [Terraform](https://terraform.io)
2015-02-03 19:20:32 -05:00
## Configuration
The configuration allows you to specify and access the artifact in Atlas.
2015-02-03 19:20:32 -05:00
### Required:
- `token` (string) - Your access token for the Atlas API.
2015-07-24 17:54:46 -04:00
-> Login to Atlas to [generate an Atlas
Token](https://atlas.hashicorp.com/settings/tokens). The most convenient way to
configure your token is to set it to the `ATLAS_TOKEN` environment variable, but
you can also use `token` configuration option.
2015-02-03 19:20:32 -05:00
2015-07-22 23:25:58 -04:00
- `artifact` (string) - The shorthand tag for your artifact that maps to
Atlas, i.e `hashicorp/foobar` for `atlas.hashicorp.com/hashicorp/foobar`.
2015-07-24 17:54:46 -04:00
You must have access to the organization—hashicorp in this example—in order
to add an artifact to the organization in Atlas.
2015-02-03 19:20:32 -05:00
2015-09-04 15:51:35 -04:00
- `artifact_type` (string) - For uploading artifacts to Atlas. `artifact_type`
2015-09-04 16:01:35 -04:00
can be set to any unique identifier, however, the following are recommended
2015-09-08 13:51:24 -04:00
for consistency - `amazon.image`, `digitalocean.image`, `docker.image`,
`googlecompute.image`, `openstack.image`, `parallels.image`, `qemu.image`,
`virtualbox.image`, `vmware.image`, `custom.image`, and `vagrant.box`.
2015-02-03 19:20:32 -05:00
### Optional:
2015-07-22 23:25:58 -04:00
- `atlas_url` (string) - Override the base URL for Atlas. This is useful if
you're using Atlas Enterprise in your own network. Defaults to
`https://atlas.hashicorp.com/api/v1`.
2015-02-03 19:20:32 -05:00
2015-07-22 23:25:58 -04:00
- `metadata` (map) - Send metadata about the artifact. If the artifact type is
"vagrant.box", you must specify a "provider" metadata about what provider
to use.
2015-02-03 19:20:32 -05:00
### Example Configuration
2015-07-22 22:31:00 -04:00
``` {.javascript}
2015-02-03 19:20:32 -05:00
{
"variables": {
"aws_access_key": "ACCESS_KEY_HERE",
"aws_secret_key": "SECRET_KEY_HERE",
"atlas_token": "ATLAS_TOKEN_HERE"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-de0d9eb7",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "atlas-example {{timestamp}}"
}],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 30",
"sudo apt-get update",
"sudo apt-get install apache2 -y"
]
}],
"post-processors": [
{
"type": "atlas",
"token": "{{user `atlas_token`}}",
"artifact": "hashicorp/foobar",
"artifact_type": "amazon.image",
2015-02-03 19:20:32 -05:00
"metadata": {
"created_at": "{{timestamp}}"
}
}
]
}
```