Skip to content

Commit

Permalink
Add packer doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Golgautier committed Sep 23, 2022
1 parent f94babb commit cbc6a3b
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 0 deletions.
103 changes: 103 additions & 0 deletions docs/datasources.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
description: >
The nutanix packer plugin allow to use Packer on Nutanix AHV platform.
page_title: Nutanix plugin - Data Source
nav_title: Nutanix plugin
---

# Data source for Packer Nutanix plugin

This document is going to detail all Nutanix plugin source parameters.

## Principle
The Nutanix plugin will create a temporary VM as foundation of your Packer image, apply all providers your want to customize your image, then clone the VM disk image as your final Packer image.

## Environment configuration
These parameters allow to define information about platform and temporary VM used to create the image.

### Required
- `nutanix_username` (string) - User used for Prism Central login
- `nutanix_password` (string) - Password of this user for Prism Central login
- `nutanix_endpoint` (string) - Prism Central FQDN or IP
- `cluster_name` (string) - Nutanix cluster name used to create and store image
- `os_type` (string) - OS Type ("Linux" or "Windows")

### Optional
- `nutanix_port` (integer) - Port configured on Prism Central to connect on
- `nutanix_insecure` (boolean) - Authorize connection on Prism Central without valid certificate
- `cpu` (integer) - Number of vCPU for temporary VM
- `memory_mb` (integer) - Size of vRAM for temporary VM (in megabytes)
- `cd_files` (array of strings) - A list of files to place onto a CD that is attached when the VM is booted. This can include either files or directories; any directories will be copied onto the CD recursively, preserving directory structure hierarchy.
- `cd_label` (string) - Label of this CD Drive

## Output configuration
These parameters allow to configure everything around image creation, from the temporary VM connection to the final image definition.

### All OS
- `image_name` (string) - Name of the output image
- `shutdown_command` (string) - Command line to shutdown your temporary VM
- `shutdown_timeout` (string) - Timeout for VM shutdown (format : 2m)

### Dedicated to Linux
- `user_data` (string) - cloud-init (Linux) content base64 coded.
- `ssh_username` (string) - user for ssh connection initiated by Packer.
- `ssh_password` (string) - password for the this ssh user.

### Dedicated to Windows
- `communicator` (string) - Protocol used for Packer connection (ex "winrm")
- `winrm_port` (integer) - Port for WinRM communication (Default is 5986)
- `winrm_insecure` (boolean) - Allow insecure connection on WinRM
- `winrm_use_ssl` (boolean) - Request SSL connection with WinRM
- `winrm_timeout` (string) - Timeout for WinRM (format 45m)
- `winrm_username` (string) - User login for WinRM connection
- `winrm_password` (string) - Password this User


## Disk configuration
Use `vm_disks{}` entry to configure disk to your VM image. If you want to configure several disks, use this entry multiple times.

All parameters of this `vm_disks` section are described below.

2 types of disk configurations can by used : disk image and ISO image.

### Disk image
- `image_type` (string) - "DISK_IMAGE"
- `source_image_name` (string) - Name of the image used as disk source (If you want an empty disk, do not specify source)
- `disk_size_gb` (integer) - size of th disk (in gigabytes)

Sample:
```hcl
vm_disks {
image_type = "DISK_IMAGE"
source_image_name = "<myDiskImage>"
disk_size_gb = 40
}
```
### ISO Image
- `image_type` (string) - "ISO_IMAGE"
- `source_image_name` (string) - Name of the ISO image to mount

Sample:
```hcl
vm_disks {
image_type = "ISO_IMAGE"
source_image_name = "<myISOimage>"
}
```

## Network Configuration
Use `vm_nics{}` entry to configure NICs in your image

In this section, you have to define network you will connect on with this keyword :

- `subnet_name` (string) - Name of the cluster subnet to use

Sample
```hcl
vm_nics {
subnet_name = "<mySubnet>"
}
```

## Samples
You can find samples [here](../example) for these instructions usage.
98 changes: 98 additions & 0 deletions docs/readme.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Nutanix Plugin

<!--
Include a short overview about the plugin.

This document is a great location for creating a table of contents for each
of the components the plugin may provide. This document should load automatically
when navigating to the docs directory for a plugin.

-->
The `Nutanix` multi-component plugin can be used with HashiCorp [Packer](https://www.packer.io)
to create custom images.

---

[![Go Report Card](https://goreportcard.com/badge/github.com/nutanix-cloud-native/packer-plugin-nutanix)](https://goreportcard.com/report/github.com/nutanix-cloud-native/packer-plugin-nutanix)
![CI](https://github.com/nutanix-cloud-native/packer-plugin-nutanix/actions/workflows/integration.yml/badge.svg)
![Release](https://github.com/nutanix-cloud-native/packer-plugin-nutanix/actions/workflows/release.yml/badge.svg)

[![release](https://img.shields.io/github/release-pre/nutanix-cloud-native/packer-plugin-nutanix.svg)](https://github.com/nutanix-cloud-native/packer-plugin-nutanix/releases)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/nutanix-cloud-native/packer-plugin-nutanix/blob/master/LICENSE)
![Proudly written in Golang](https://img.shields.io/badge/written%20in-Golang-92d1e7.svg)
[![Releases](https://img.shields.io/github/downloads/nutanix-cloud-native/packer-plugin-nutanix/total.svg)](https://github.com/nutanix-cloud-native/packer-plugin-nutanix/releases)

---

## Installation

### Using pre-built releases

#### Using the `packer init` command

Starting from version 1.7, Packer supports a new `packer init` command allowing
automatic installation of Packer plugins. Read the
[Packer documentation](https://www.packer.io/docs/commands/init) for more information.

To install this plugin, copy and paste this code into your Packer configuration .
Then, run [`packer init`](https://www.packer.io/docs/commands/init).

```hcl
packer {
required_plugins {
nutanix = {
version = ">= 0.1.3"
source = "github.com/nutanix-cloud-native/nutanix"
}
}
}
```

#### Manual installation

You can find pre-built binary releases of the plugin [here](https://github.com/nutanix-cloud-native/packer-plugin-nutanix/releases).
Once you have downloaded the latest archive corresponding to your target OS,
uncompress it to retrieve the plugin binary file corresponding to your platform.
To install the plugin, please follow the official Packer documentation on [installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins).


#### From Source

If you prefer to build the plugin from its source code, clone the GitHub repository locally and run the command `make build` from the root directory.
Upon successful compilation, a `packer-plugin-nutanix` plugin binary file can be found in the root directory.
To install the compiled plugin, please follow the official Packer documentation on [installing a plugin](https://www.packer.io/docs/extending/plugins/#installing-plugins).

### Configuration

For more information on how to configure the plugin, please find some examples in the [`example/`](example) directory.


## Data sources

- The data source of the plugin is detailed [here](/docs/datasources.mdx).

## Limitations
### Building temporary ISOs on MacOS
If you want to use the cd_files Option to create an additional iso-image for kickstart-files or similiar be aware that MacOS won´t create a suitable file.
Please install xorriso for support on MacOS.
```
brew install xorriso
```
### Image Creation
Right now the plugin cannot upload source-images directly, but Terraform can be used to create a source image before running packer itself.
Create a Terraform Manifest using the Nutanix Provider to create your Image and define an output with your image uuid. You can pass this uuid into a Packer Variable. In that case the centos_iso_image_name Variable in the example settings file must be commented.
```
export PKR_VAR_centos_iso_image_name=$(terraform output -raw centos_uuid)
```
## Contributing
See the [contributing docs](CONTRIBUTING.md).

## Support
### Community Plus

This code is developed in the open with input from the community through issues and PRs. A Nutanix engineering team serves as the maintainer. Documentation is available in the project repository.

Issues and enhancement requests can be submitted in the [Issues tab of this repository](../../issues). Please search for and review the existing open issues before submitting a new issue.

## License
The project is released under version 2.0 of the [Apache license](http://www.apache.org/licenses/LICENSE-2.0).

0 comments on commit cbc6a3b

Please sign in to comment.