2013-06-21 17:50:00 -04:00
|
|
|
---
|
2015-07-22 22:31:00 -04:00
|
|
|
layout: intro
|
2017-03-25 18:13:52 -04:00
|
|
|
sidebar_current: intro-getting-started-install
|
|
|
|
page_title: Install Packer - Getting Started
|
|
|
|
description: |-
|
|
|
|
Packer must first be installed on the machine you want to run it on. To make
|
2017-05-09 14:37:49 -04:00
|
|
|
installation easier, Packer is distributed as a binary package for all supported
|
2017-03-25 18:13:52 -04:00
|
|
|
platforms and architectures. This page will not cover how to compile Packer
|
|
|
|
from source, as that is covered in the README and is only recommended for
|
|
|
|
advanced users.
|
|
|
|
---
|
2013-06-21 17:50:00 -04:00
|
|
|
|
2018-06-08 17:28:09 -04:00
|
|
|
# Install Options
|
2013-06-21 17:50:00 -04:00
|
|
|
|
2018-06-08 17:28:09 -04:00
|
|
|
Packer may be installed in the following ways:
|
2013-06-21 17:50:00 -04:00
|
|
|
|
2018-06-08 17:28:09 -04:00
|
|
|
1. Using a [precompiled binary](#precompiled-binaries); We release binaries
|
|
|
|
for all supported platforms and architectures. This method is recommended for
|
|
|
|
most users.
|
2013-06-21 17:50:00 -04:00
|
|
|
|
2018-06-08 17:28:09 -04:00
|
|
|
2. Installing [from source](#compiling-from-source) This method is only
|
|
|
|
recommended for advanced users.
|
|
|
|
|
|
|
|
3. An unoffical [alternative installation method](#alternative-installation-methods)
|
|
|
|
|
|
|
|
## Precompiled Binaries
|
|
|
|
|
|
|
|
To install the precompiled binary, [download](/downloads.html) the appropriate
|
|
|
|
package for your system. Packer is currently packaged as a zip file. We do not
|
|
|
|
have any near term plans to provide system packages.
|
2013-06-21 17:50:00 -04:00
|
|
|
|
|
|
|
Next, unzip the downloaded package into a directory where Packer will be
|
|
|
|
installed. On Unix systems, `~/packer` or `/usr/local/packer` is generally good,
|
2015-07-22 22:31:00 -04:00
|
|
|
depending on whether you want to restrict the install to just your user or
|
2018-06-08 17:28:09 -04:00
|
|
|
install it system-wide. If you intend to access it from the command-line, make
|
|
|
|
sure to place it somewhere on your `PATH` before `/usr/sbin`. On Windows
|
|
|
|
systems, you can put it wherever you'd like. The `packer` (or `packer.exe` for
|
|
|
|
Windows) binary inside is all that is necessary to run Packer. Any additional
|
|
|
|
files aren't required to run Packer.
|
2013-06-21 17:50:00 -04:00
|
|
|
|
2016-03-10 12:24:40 -05:00
|
|
|
After unzipping the package, the directory should contain a single binary
|
|
|
|
program called `packer`. The final step to
|
2015-07-22 22:31:00 -04:00
|
|
|
installation is to make sure the directory you installed Packer to is on the
|
|
|
|
PATH. See [this
|
2016-01-14 15:31:19 -05:00
|
|
|
page](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux)
|
2015-07-22 22:31:00 -04:00
|
|
|
for instructions on setting the PATH on Linux and Mac. [This
|
2016-01-14 15:31:19 -05:00
|
|
|
page](https://stackoverflow.com/questions/1618280/where-can-i-set-path-to-make-exe-on-windows)
|
2013-06-21 17:50:00 -04:00
|
|
|
contains instructions for setting the PATH on Windows.
|
|
|
|
|
2018-06-08 17:28:09 -04:00
|
|
|
## Compiling from Source
|
|
|
|
|
|
|
|
To compile from source, you will need [Go](https://golang.org) installed and
|
2018-06-09 02:59:00 -04:00
|
|
|
configured properly as well as a copy of [`git`](https://www.git-scm.com/)
|
|
|
|
in your `PATH`.
|
2018-06-08 17:28:09 -04:00
|
|
|
|
|
|
|
1. Clone the Packer repository from GitHub into your `GOPATH`:
|
|
|
|
|
|
|
|
``` shell
|
2018-06-12 08:31:29 -04:00
|
|
|
$ mkdir -p $(go env GOPATH)/src/github.com/hashicorp && cd $_
|
2018-06-08 17:28:09 -04:00
|
|
|
$ git clone https://github.com/hashicorp/packer.git
|
|
|
|
$ cd packer
|
|
|
|
```
|
|
|
|
|
|
|
|
2. Build Packer for your current system and put the
|
|
|
|
binary in `./bin/` (relative to the git checkout). The `make dev` target is
|
|
|
|
just a shortcut that builds `packer` for only your local build environment (no
|
|
|
|
cross-compiled targets).
|
|
|
|
|
|
|
|
``` shell
|
|
|
|
$ make dev
|
|
|
|
```
|
|
|
|
|
2013-06-21 17:50:00 -04:00
|
|
|
## Verifying the Installation
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
After installing Packer, verify the installation worked by opening a new command
|
|
|
|
prompt or console, and checking that `packer` is available:
|
2013-06-21 17:50:00 -04:00
|
|
|
|
2017-03-25 18:13:52 -04:00
|
|
|
```text
|
2013-06-21 17:50:00 -04:00
|
|
|
$ packer
|
|
|
|
usage: packer [--version] [--help] <command> [<args>]
|
|
|
|
|
|
|
|
Available commands are:
|
2014-12-17 01:01:56 -05:00
|
|
|
build build image(s) from template
|
|
|
|
fix fixes templates from old versions of packer
|
|
|
|
inspect see components of a template
|
|
|
|
push push template files to a Packer build service
|
|
|
|
validate check that a template is valid
|
|
|
|
version Prints the Packer version
|
2013-06-21 17:50:00 -04:00
|
|
|
```
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
If you get an error that `packer` could not be found, then your PATH environment
|
|
|
|
variable was not setup properly. Please go back and ensure that your PATH
|
|
|
|
variable contains the directory which has Packer installed.
|
2013-06-21 17:50:00 -04:00
|
|
|
|
|
|
|
Otherwise, Packer is installed and you're ready to go!
|
2013-08-03 19:44:30 -04:00
|
|
|
|
|
|
|
## Alternative Installation Methods
|
|
|
|
|
2015-07-22 22:31:00 -04:00
|
|
|
While the binary packages is the only official method of installation, there are
|
|
|
|
alternatives available.
|
2013-08-03 19:44:30 -04:00
|
|
|
|
|
|
|
### Homebrew
|
|
|
|
|
2016-10-08 02:52:13 -04:00
|
|
|
If you're using OS X and [Homebrew](http://brew.sh), you can install Packer by
|
|
|
|
running:
|
2013-08-03 19:44:30 -04:00
|
|
|
|
2015-07-24 21:41:42 -04:00
|
|
|
$ brew install packer
|
|
|
|
|
2016-08-04 09:48:14 -04:00
|
|
|
### Chocolatey
|
|
|
|
|
2016-10-08 02:52:13 -04:00
|
|
|
If you're using Windows and [Chocolatey](http://chocolatey.org), you can
|
|
|
|
install Packer by running:
|
2016-08-04 09:48:14 -04:00
|
|
|
|
2016-10-08 02:42:20 -04:00
|
|
|
choco install packer
|
2016-10-08 02:52:13 -04:00
|
|
|
|
2015-07-24 21:41:42 -04:00
|
|
|
## Troubleshooting
|
|
|
|
|
2015-07-24 23:55:08 -04:00
|
|
|
On some RedHat-based Linux distributions there is another tool named `packer`
|
|
|
|
installed by default. You can check for this using `which -a packer`. If you get
|
|
|
|
an error like this it indicates there is a name conflict.
|
2015-07-24 21:41:42 -04:00
|
|
|
|
|
|
|
$ packer
|
|
|
|
/usr/share/cracklib/pw_dict.pwd: Permission denied
|
|
|
|
/usr/share/cracklib/pw_dict: Permission denied
|
|
|
|
|
2015-07-24 23:55:08 -04:00
|
|
|
To fix this, you can create a symlink to packer that uses a different name like
|
|
|
|
`packer.io`, or invoke the `packer` binary you want using its absolute path,
|
|
|
|
e.g. `/usr/local/packer`.
|