packer-cn/website/source/docs/extend/plugins.html.md

72 lines
3.1 KiB
Markdown
Raw Normal View History

2013-06-10 20:17:31 -04:00
---
2015-07-22 22:31:00 -04:00
description: |
Packer Plugins allow new functionality to be added to Packer without modifying
the core source code. Packer plugins are able to add new commands, builders,
provisioners, hooks, and more. In fact, much of Packer itself is implemented by
writing plugins that are simply distributed with Packer. For example, all the
commands, builders, provisioners, and more that ship with Packer are implemented
as Plugins that are simply hardcoded to load with Packer.
layout: docs
page_title: 'Packer Plugins - Extend Packer'
...
2013-06-10 20:17:31 -04:00
# Packer Plugins
2015-07-22 22:31:00 -04:00
Packer Plugins allow new functionality to be added to Packer without modifying
the core source code. Packer plugins are able to add new commands, builders,
provisioners, hooks, and more. In fact, much of Packer itself is implemented by
writing plugins that are simply distributed with Packer. For example, all the
commands, builders, provisioners, and more that ship with Packer are implemented
as Plugins that are simply hardcoded to load with Packer.
2013-06-10 20:17:31 -04:00
2015-07-22 22:31:00 -04:00
This page will cover how to install and use plugins. If you're interested in
developing plugins, the documentation for that is available the [developing
plugins](/docs/extend/developing-plugins.html) page.
2013-06-10 20:17:31 -04:00
2015-07-22 22:31:00 -04:00
Because Packer is so young, there is no official listing of available Packer
plugins. Plugins are best found via Google. Typically, searching "packer plugin
*x*" will find what you're looking for if it exists. As Packer gets older, an
official plugin directory is planned.
2013-06-10 20:17:31 -04:00
## How Plugins Work
2015-07-22 22:31:00 -04:00
Packer plugins are completely separate, standalone applications that the core of
Packer starts and communicates with.
2013-06-10 20:17:31 -04:00
2015-07-22 22:31:00 -04:00
These plugin applications aren't meant to be run manually. Instead, Packer core
executes these plugin applications in a certain way and communicates with them.
2013-06-10 20:17:31 -04:00
For example, the VMware builder is actually a standalone binary named
2015-07-22 22:31:00 -04:00
`packer-builder-vmware`. The next time you run a Packer build, look at your
process list and you should see a handful of `packer-` prefixed applications
running.
2013-06-10 20:17:31 -04:00
## Installing Plugins
2015-07-22 22:31:00 -04:00
The easiest way to install a plugin is to name it correctly, then place it in
the proper directory. To name a plugin correctly, make sure the binary is named
`packer-TYPE-NAME`. For example, `packer-builder-amazon-ebs` for a "builder"
type plugin named "amazon-ebs". Valid types for plugins are down this page more.
2015-07-22 22:31:00 -04:00
Once the plugin is named properly, Packer automatically discovers plugins in the
following directories in the given order. If a conflicting plugin is found
later, it will take precedence over one found earlier.
2015-07-22 23:25:58 -04:00
1. The directory where `packer` is, or the executable directory.
2015-07-22 23:25:58 -04:00
2. `~/.packer.d/plugins` on Unix systems or `%APPDATA%/packer.d/plugins`
on Windows.
2015-07-22 23:25:58 -04:00
3. The current working directory.
The valid types for plugins are:
2015-07-22 23:25:58 -04:00
- `builder` - Plugins responsible for building images for a specific platform.
2015-07-22 23:25:58 -04:00
- `command` - A CLI sub-command for `packer`.
2015-07-22 23:25:58 -04:00
- `post-processor` - A post-processor responsible for taking an artifact from
a builder and turning it into something else.
2015-07-22 23:25:58 -04:00
- `provisioner` - A provisioner to install software on images created by
a builder.