This is a Packer plug-in for building Linode Images.
This project is currently not supported. Use at your own risk. Contributions welcome!
Requirements:
Go makes installing the Linode Images builder plugin for Packer easy:
GOBIN=~/.packer.d/plugins go install github.com/linode/packer-builder-linode
To fetch the code and improve the plugin itself:
git clone https://github.com/linode/packer-builder-linode
cd packer-builder-linode
make install
With the builder plugin installed, an Packer file like the example at test/fixtures/builder-linode/minimal.json
can create a Linode Image.
packer build -var "linode-token=$LINODE_TOKEN" test/fixtures/builder-linode/minimal.json
Some notes:
- You will need a Linode APIv4 Personal Access Token.
Get one here: https://developers.linode.com/api/v4#section/Personal-Access-Token
Naturally it's a bad idea to hard-code it, so you will probably want to pull it from an environment
variable, which is what
minimal.json
does. ssh_username
is required, generally this value should beroot
. All Linode images useroot
, except forlinode/containerlinux
which usescore
.
HashiCorp provides excellent guidance on how to build, use, and debug plugins:
Tests can be run in the following ways:
make test
This will run all unittests except and will not fail if acceptance tests against the actual Linode API are skipped.LINODE_TOKEN=... make testacc
This will run all unittests and will fail if acceptance tests aginst the actual Linode API do not succeed. ALINODE_TOKEN
must be set in the environment.
Helper tools to interact with Linode objects and assist in development can be found in cmd/
.
These can be built with go build
within their path. They all expect a LINODE_TOKEN
environment variable to be set.
list-images
- Lists all Linode images, both public and privatelist-events
- Lists the most recent page of events on the Linode accountlist-kernels
- Lists all Linode kernelsdelete-image
- Deletes a single Linode image whose numeric ID is required (delete_image 123
to remove imageprivate/123
)
The Linode CLI can also help during development.
Install it by running pip install linode-cli
.
These instructions are an alternative to installing packer-builder-linode
as a plugin.
To patch this plugin into Packer's source code, fetch this repository and Packer:
go get -d github.com/hashicorp/packer
go get -d github.com/linode/packer-builder-linode
Then copy the contents of linode/
and test/
to Packer's source tree:
cp -r linode $GOPATH/src/github.com/hashicorp/packer/builder/
cp -r test $GOPATH/src/github.com/hashicorp/packer/test
Then open up Packer's file command/plugin.go
and add Linode as a new builder.
diff --git a/command/plugin.go b/command/plugin.go
index 62c909168..088c4af70 100644
--- a/command/plugin.go
+++ b/command/plugin.go
@@ -29,6 +29,7 @@ import (
hyperonebuilder "github.com/hashicorp/packer/builder/hyperone"
hypervisobuilder "github.com/hashicorp/packer/builder/hyperv/iso"
hypervvmcxbuilder "github.com/hashicorp/packer/builder/hyperv/vmcx"
+ linodebuilder "github.com/hashicorp/packer/builder/linode"
lxcbuilder "github.com/hashicorp/packer/builder/lxc"
lxdbuilder "github.com/hashicorp/packer/builder/lxd"
ncloudbuilder "github.com/hashicorp/packer/builder/ncloud"
@@ -109,6 +110,7 @@ var Builders = map[string]packer.Builder{
"hyperone": new(hyperonebuilder.Builder),
"hyperv-iso": new(hypervisobuilder.Builder),
"hyperv-vmcx": new(hypervvmcxbuilder.Builder),
+ "linode": new(linodebuilder.Builder),
"lxc": new(lxcbuilder.Builder),
"lxd": new(lxdbuilder.Builder),
"ncloud": new(ncloudbuilder.Builder),
To verify that the Linode patching applied:
make dev
bin/packer build -var "linode-token=$LINODE_TOKEN" test/fixtures/builder-linode/minimal.json
Then you can go install
Packer, and it will have support for the "linode"
plugin.
Want to improve the Linode Packer Builder? Please start here.
Join us at #linodego on the gophers slack