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

148 lines
5.6 KiB
Markdown
Raw Normal View History

2015-02-03 19:20:32 -05:00
---
2017-06-14 21:04:16 -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.
2015-07-22 22:31:00 -04:00
layout: docs
2017-06-14 21:04:16 -04:00
page_title: 'Atlas - Post-Processor'
sidebar_current: 'docs-post-processors-atlas'
---
2015-02-03 19:20:32 -05:00
# Atlas Post-Processor
2017-12-11 20:12:57 -05:00
!> The Packer and Artifact Registry features of Atlas will no longer be
actively developed or maintained and will be fully decommissioned on Friday,
March 30, 2018. Please see our [guide on building immutable infrastructure with
2017-12-11 22:21:47 -05:00
Packer on CI/CD](/guides/packer-on-cicd/) for ideas on implementing these
features yourself.
2017-12-11 20:12:57 -05:00
2015-02-03 19:20:32 -05:00
Type: `atlas`
2015-07-24 17:54:46 -04:00
The Atlas post-processor uploads artifacts from your packer builds to Atlas for
2015-11-24 02:31:31 -05:00
hosting. Artifacts hosted in Atlas are automatically made available for use
with Terraform, and Atlas provides additional features for managing
2015-07-24 17:54:46 -04:00
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/commands/push.html). The push command and Atlas post-processor
2015-07-24 17:54:46 -04:00
can be used together or independently.
2015-02-03 19:20:32 -05:00
2017-06-14 21:04:16 -04:00
~> If you'd like to publish a Vagrant box to [Vagrant Cloud](https://vagrantcloud.com), you must use the [`vagrant-cloud`](/docs/post-processors/vagrant-cloud.html) post-processor.
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:
2017-06-14 21:04:16 -04:00
1. Packer builds an AMI with the [Amazon AMI
2015-07-24 17:54:46 -04:00
builder](/docs/builders/amazon.html)
2017-06-14 21:04:16 -04:00
2. The `atlas` post-processor takes the resulting AMI and uploads it to Atlas.
2015-07-22 23:25:58 -04:00
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
2017-06-14 21:04:16 -04:00
3. The new version is ready and available to be used in deployments with a
2016-05-09 19:53:27 -04:00
tool like [Terraform](https://www.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:
2017-06-14 21:04:16 -04:00
- `artifact` (string) - The shorthand tag for your artifact that maps to
2015-07-22 23:25:58 -04:00
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
2017-06-14 21:04:16 -04:00
- `artifact_type` (string) - For uploading artifacts to Atlas.
2016-05-09 19:53:27 -04:00
`artifact_type` can be set to any unique identifier, however, the following
are recommended for consistency - `amazon.image`, `azure.image`,
`cloudstack.image`, `digitalocean.image`, `docker.image`,
`googlecompute.image`, `hyperv.image`, `oneandone.image`,
`openstack.image`, `parallels.image`, `profitbricks.image`, `qemu.image`,
`triton.image`, `virtualbox.image`, `vmware.image`, and `custom.image`.
2015-02-03 19:20:32 -05:00
### Optional:
2017-06-14 21:04:16 -04:00
- `token` (string) - Your access token for the Atlas API.
2017-03-09 16:27:23 -05:00
2017-06-14 21:04:16 -04:00
-> Login to Atlas to [generate an Atlas
2017-03-09 16:27:23 -05:00
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.
2017-06-14 21:04:16 -04:00
- `atlas_url` (string) - Override the base URL for Atlas. This is useful if
2015-07-22 23:25:58 -04:00
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
2017-06-14 21:04:16 -04:00
- `metadata` (map) - Send metadata about the artifact.
2016-05-09 19:53:27 -04:00
2017-06-14 21:04:16 -04:00
- `description` (string) - Inside the metadata blob you can add a information
2016-05-09 19:53:27 -04:00
about the uploaded artifact to Atlas. This will be reflected in the box
description on Atlas.
2017-06-14 21:04:16 -04:00
- `provider` (string) - Used by Atlas to help determine, what should be used
2016-05-09 19:53:27 -04:00
to run the artifact.
2017-06-14 21:04:16 -04:00
- `version` (string) - Used by Atlas to give a semantic version to the
2016-05-09 19:53:27 -04:00
uploaded artifact.
2015-02-03 19:20:32 -05:00
## Environment Variables
2017-06-14 21:04:16 -04:00
- `ATLAS_CAFILE` (path) - This should be a path to an X.509 PEM-encoded public key. If specified, this will be used to validate the certificate authority that signed certificates used by an Atlas installation.
2017-06-14 21:04:16 -04:00
- `ATLAS_CAPATH` - This should be a path which contains an X.509 PEM-encoded public key file. If specified, this will be used to validate the certificate authority that signed certificates used by an Atlas installation.
2015-02-03 19:20:32 -05:00
### Example Configuration
2017-06-14 21:04:16 -04:00
``` json
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-fce3c696",
"instance_type": "t2.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": [
2015-02-03 19:20:32 -05:00
{
"type": "atlas",
"token": "{{user `atlas_token`}}",
"artifact": "hashicorp/foobar",
"artifact_type": "amazon.image",
"metadata": {
"created_at": "{{timestamp}}"
2015-02-03 19:20:32 -05:00
}
}
]
2015-02-03 19:20:32 -05:00
}
```
More information on the correct configuration of the `amazon-ebs` builder in this example can be found in the [amazon-ebs builder documentation](/docs/builders/amazon-ebs.html).