|
1 | | -# Packer Plugin Scaffolding |
| 1 | +# Packer Plugin Bhyve |
2 | 2 |
|
3 | | -This repository is a template for a Packer multi-component plugin. It is intended as a starting point for creating Packer plugins, containing: |
4 | | -- A builder ([builder/scaffolding](builder/scaffolding)) |
5 | | -- A provisioner ([provisioner/scaffolding](provisioner/scaffolding)) |
6 | | -- A post-processor ([post-processor/scaffolding](post-processor/scaffolding)) |
7 | | -- A data source ([datasource/scaffolding](datasource/scaffolding)) |
8 | | -- Docs ([docs](docs)) |
9 | | -- A working example ([example](example)) |
| 3 | +This plugin can be used with HashiCorp [Packer](https://www.packer.io) to |
| 4 | +create custom images. It borrows from |
| 5 | +[packer-plugin-qemu](https://github.com/hashicorp/packer-plugin-qemu) with the |
| 6 | +aim of being able to reuse Packer machine templates as much as possible. |
10 | 7 |
|
11 | | -These folders contain boilerplate code that you will need to edit to create your own Packer multi-component plugin. |
12 | | -A full guide to creating Packer plugins can be found at [Extending Packer](https://www.packer.io/docs/plugins/creation). |
| 8 | +The current target platform is illumos, and while there are currently some |
| 9 | +hardcoded dependencies on that platform (such as VNICs), the long-term goal is |
| 10 | +that it should be cross-platform. |
13 | 11 |
|
14 | | -In this repository you will also find a pre-defined GitHub Action configuration for the release workflow |
15 | | -(`.goreleaser.yml` and `.github/workflows/release.yml`). The release workflow configuration makes sure the GitHub |
16 | | -release artifacts are created with the correct binaries and naming conventions. |
| 12 | +## Differences |
17 | 13 |
|
18 | | -Please see the [GitHub template repository documentation](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) |
19 | | -for how to create a new repository from this template on GitHub. |
| 14 | +Many packer-plugin-qemu variables are unsupported as they simply do not make |
| 15 | +sense in a bhyve context. |
20 | 16 |
|
21 | | -## Packer plugin projects |
| 17 | +Variables introduced for bhyve support are: |
22 | 18 |
|
23 | | -Here's a non exaustive list of Packer plugins that you can checkout: |
24 | | - |
25 | | -* [github.com/hashicorp/packer-plugin-docker](https://github.com/hashicorp/packer-plugin-docker) |
26 | | -* [github.com/exoscale/packer-plugin-exoscale](https://github.com/exoscale/packer-plugin-exoscale) |
27 | | -* [github.com/sylviamoss/packer-plugin-comment](https://github.com/sylviamoss/packer-plugin-comment) |
28 | | -* [github.com/hashicorp/packer-plugin-hashicups](https://github.com/hashicorp/packer-plugin-hashicups) |
29 | | - |
30 | | -Looking at their code will give you good examples. |
31 | | - |
32 | | -## Running Acceptance Tests |
33 | | - |
34 | | -Make sure to install the plugin with `go build .` and to have Packer installed locally. |
35 | | -Then source the built binary to the plugin path with `cp packer-plugin-scaffolding ~/.packer.d/plugins/packer-plugin-scaffolding` |
36 | | -Once everything needed is set up, run: |
37 | | -``` |
38 | | -PACKER_ACC=1 go test -count 1 -v ./... -timeout=120m |
39 | | -``` |
40 | | - |
41 | | -This will run the acceptance tests for all plugins in this set. |
42 | | - |
43 | | -## Test Plugin Example Action |
44 | | - |
45 | | -This scaffolding configures a [manually triggered plugin test action](/.github/workflows/test-plugin-example.yml). |
46 | | -By default, the action will run Packer at the latest version to init, validate, and build the example configuration |
47 | | -within the [example](example) folder. This is useful to quickly test a basic template of your plugin against Packer. |
48 | | - |
49 | | -The example must contain the `required_plugins` block and require your plugin at the latest or any other released version. |
50 | | -This will help test and validate plugin releases. |
51 | | - |
52 | | -## Registering Documentation on Packer.io |
53 | | - |
54 | | -Documentation for a plugin is maintained within the `docs` directory and served on GitHub. |
55 | | -To include plugin docs on Packer.io a global pre-hook has been added to the main scaffolding .goreleaser.yml file, that if uncommented will generate and include a docs.zip file as part of the plugin release. |
56 | | - |
57 | | -The `docs.zip` file will contain all of the `.mdx` files under the plugins root `docs/` directory that can be consumed remotely by Packer.io. |
58 | | - |
59 | | -Once the first `docs.zip` file has been included into a release you will need to open a one time pull-request against [hashicorp/packer](https://github.com/hashicorp/packer) to register the plugin docs. |
60 | | -This is done by adding the block below for the respective plugin to the file [website/data/docs-remote-navigation.js](https://github.com/hashicorp/packer/blob/master/website/data/docs-remote-plugins.json). |
61 | | - |
62 | | -```json |
63 | | -{ |
64 | | - "title": "Scaffolding", |
65 | | - "path": "scaffolding", |
66 | | - "repo": "hashicorp/packer-plugin-scaffolding", |
67 | | - "version": "latest", |
68 | | - "sourceBranch": "main" |
69 | | - } |
70 | | -``` |
71 | | - |
72 | | -If a plugin maintainer wishes to only include a specific version of released docs then the `"version"` key in the above configuration should be set to a released version of the plugin. Otherwise it should be set to `"latest"`. |
73 | | - |
74 | | -The `"sourceBranch"` key in the above configuration ensures potential contributors can link back to source files in the plugin repository from the Packer docs site. If a `"sourceBranch"` value is not present, it will default to `"main"`. |
75 | | - |
76 | | -The documentation structure needed for Packer.io can be generated manually, by creating a simple zip file called `docs.zip` of the docs directory and included in the plugin release. |
77 | | - |
78 | | -```/bin/bash |
79 | | -[[ -d docs/ ]] && zip -r docs.zip docs/ |
80 | | -``` |
81 | | - |
82 | | -Once the first `docs.zip` file has been included into a release you will need to open a one time pull-request against [hashicorp/packer](https://github.com/hashicorp/packer) to register the plugin docs. |
83 | | - |
84 | | -# Requirements |
85 | | - |
86 | | -- [packer-plugin-sdk](https://github.com/hashicorp/packer-plugin-sdk) >= v0.2.9 |
87 | | -- [Go](https://golang.org/doc/install) >= 1.17 |
88 | | - |
89 | | -## Packer Compatibility |
90 | | -This scaffolding template is compatible with Packer >= v1.7.0 |
| 19 | +* `host_nic`: The host NIC on which we create a VNIC for the virtual machine to |
| 20 | + use, as well as listen on for the Packer HTTP server. |
0 commit comments