Skip to content

Commit

Permalink
Merge branch 'main' into docs/step-customize
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken authored Mar 5, 2024
2 parents 93cac97 + acb47ad commit 6208989
Show file tree
Hide file tree
Showing 35 changed files with 88 additions and 88 deletions.
8 changes: 4 additions & 4 deletions .web-docs/components/builder/vsphere-clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1403,14 +1403,14 @@ Only use the `host` option. Optionally specify a `resource_pool`:
**JSON**

```json
"host": "esxi-1.vsphere65.test",
"host": "esxi-01.example.com",
"resource_pool": "pool1",
```

**HCL2**

```hcl
host = "esxi-1.vsphere65.test"
host = "esxi-01.example.com"
resource_pool = "pool1"
```

Expand All @@ -1423,14 +1423,14 @@ Use the `cluster` and `host`parameters:

```json
"cluster": "cluster1",
"host": "esxi-2.vsphere65.test",
"host": "esxi-02.example.com",
```

**HCL2**

```hcl
cluster = "cluster1"
host = "esxi-2.vsphere65.test"
host = "esxi-02.example.com"
```


Expand Down
10 changes: 5 additions & 5 deletions .web-docs/components/builder/vsphere-iso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1415,14 +1415,14 @@ Only use the `host` option. Optionally specify a `resource_pool`:
**JSON**

```json
"host": "esxi-1.vsphere65.test",
"host": "esxi-01.example.com",
"resource_pool": "pool1",
```

**HCL2**

```hcl
host = ""esxi-1.vsphere65.test""
host = ""esxi-01.example.com""
resource_pool = "pool1"
```

Expand All @@ -1435,14 +1435,14 @@ Use the `cluster` and `host`parameters:

```json
"cluster": "cluster1",
"host": "esxi-2.vsphere65.test",
"host": "esxi-02.example.com",
```

**HCL2**

```hcl
cluster = "cluster1"
host = "esxi-2.vsphere65.test"
host = "esxi-02.example.com"
```


Expand All @@ -1467,7 +1467,7 @@ resource_pool = "pool1"

## Required vSphere Privileges

It is recommended to create a custom vSphere role with the required privileges to integrate Packer with vSphere. Accounts or groups can be added to the role to ensure that Packer has **_the least privileged_** access to the infrastructure. For example, a named service account (_e.g._ [email protected]).
It is recommended to create a custom vSphere role with the required privileges to integrate Packer with vSphere. Accounts or groups can be added to the role to ensure that Packer has **_the least privileged_** access to the infrastructure. For example, a named service account (_e.g._ [email protected]).

Clone the default **Read-Only** vSphere role and add the following privileges, which are based on the capabilities of the `vsphere-iso` plugin:

Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
Please refer to [releases](https://github.com/hashicorp/packer-plugin-vsphere/releases) for the latest CHANGELOG information.

---

## 1.0.2 (October 18, 2021)

### NOTES:
### NOTES

Support for the HCP Packer registry is currently in beta and requires
Packer v1.7.7 [GH-115] [GH-120]

### FEATURES:
### FEATURES

* Add HCP Packer registry image metadata to all artifacts. [GH-115]
[GH-120]

## IMPROVEMENTS:
## IMPROVEMENTS

* Add `floppy_content` parameter, which is similar to `http_content` and
`cd_content`, but for floppy. [GH-117]
* Add skip_import parameter in content_library_destination configuration.
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ The plugin includes two builders which are able to create images, depending on y

Learn more: [VMware Product Lifecycle Matrix][vmware-product-lifecycle-matrix]

> **Note**
>
> This plugin requires API write access and is therefore not supported for use with a free VMware vSphere Hypervisor license.
* [Go 1.18][golang-install]
* [Go 1.19][golang-install]

Required if building the plugin.

Expand Down Expand Up @@ -50,7 +46,7 @@ packer {

#### Manual Installation

You can download [pre-built binary releases][releases-vsphere-plugin] of the plugin on GitHub. Once you have downloaded the latest release archive for your target operating system and architecture, uncompress to retrieve the plugin binary file for your platform.
You can download [pre-built binary releases][releases-vsphere-plugin] of the plugin on GitHub. Once you have downloaded the latest release archive for your target operating system and architecture, extract the release archive to retrieve the plugin binary file for your platform.

To install the downloaded plugin, please follow the Packer documentation on [installing a plugin][docs-packer-plugin-install].

Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/clone/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestCloneConfig_Timeout(t *testing.T) {
warns, err := conf.Prepare(raw)
testConfigOk(t, warns, err)
if conf.ShutdownConfig.Timeout != 3*time.Minute {
t.Fatalf("shutdown_timeout sould be equal 3 minutes, got %v", conf.ShutdownConfig.Timeout)
t.Fatalf("shutdown_timeout should be equal 3 minutes, got %v", conf.ShutdownConfig.Timeout)
}
}

Expand Down
4 changes: 2 additions & 2 deletions builder/vsphere/clone/step_clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ func TestCreateConfig_Prepare(t *testing.T) {
errs := c.config.Prepare()
if c.fail {
if len(errs) == 0 {
t.Fatalf("Config preprare should fail")
t.Fatalf("Config prepare should fail")
}
if errs[0].Error() != c.expectedErrMsg {
t.Fatalf("Expected error message: %s but was '%s'", c.expectedErrMsg, errs[0].Error())
}
} else {
if len(errs) != 0 {
t.Fatalf("Config preprare should not fail: %s", errs[0])
t.Fatalf("Config prepare should not fail: %s", errs[0])
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/clone/step_customize.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (c *CustomizeConfig) Prepare() ([]string, []error) {
}

if options_number > 1 {
errs = append(errs, errCustomizeOptionMutalExclusive)
errs = append(errs, errCustomizeOptionMutualExclusive)

Check failure on line 170 in builder/vsphere/clone/step_customize.go

View workflow job for this annotation

GitHub Actions / Darwin Go tests

undefined: errCustomizeOptionMutualExclusive

Check failure on line 170 in builder/vsphere/clone/step_customize.go

View workflow job for this annotation

GitHub Actions / Linux Go tests

undefined: errCustomizeOptionMutualExclusive

Check failure on line 170 in builder/vsphere/clone/step_customize.go

View workflow job for this annotation

GitHub Actions / Windows Go tests

undefined: errCustomizeOptionMutualExclusive
} else if options_number == 0 {
errs = append(errs, fmt.Errorf("one of `linux_options`, `windows_options`, `windows_sysprep_file` must be set"))
}
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/clone/step_customize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestSysprepFieldsMutuallyExclusive(t *testing.T) {
}

// Expected error message
expectedError := errCustomizeOptionMutalExclusive
expectedError := errCustomizeOptionMutualExclusive
_, errors := config.Prepare()

// Make sure we only received on error
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/common/hcp_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetVMMetadata(vm *driver.VirtualMachineDriver, state multistep.StateBag) ma
p := vm.NewResourcePool(info.ResourcePool)
poolPath, err := p.Path()
if err == nil && poolPath != "" {
labels["resurce_pool"] = poolPath
labels["resource_pool"] = poolPath
}
}

Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/common/step_wait_for_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ loop:

if prevIp == "" || prevIp != ip {
if prevIp == "" {
log.Printf("VM IP aquired: %s", ip)
log.Printf("VM IP acquired: %s", ip)
} else {
log.Printf("VM IP changed from %s to %s", prevIp, ip)
}
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/common/testing/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestConn() (driver.Driver, error) {
}

d, err := driver.NewDriver(&driver.ConnectConfig{
VCenterServer: "vcenter.vsphere65.test",
VCenterServer: "vcenter.example.com",
Username: username,
Password: password,
InsecureConnection: true,
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/driver/datastore_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestDatastoreAcc(t *testing.T) {
func TestFileUpload(t *testing.T) {
t.Skip("Acceptance tests not configured yet.")
dsName := "datastore1"
hostName := "esxi-1.vsphere65.test"
hostName := "esxi-01.example.com"

fileName := fmt.Sprintf("test-%v", time.Now().Unix())
tmpFile, err := os.CreateTemp("", fileName)
Expand Down
4 changes: 2 additions & 2 deletions builder/vsphere/driver/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAddStorageDevices(t *testing.T) {
noExistingDevices := object.VirtualDeviceList{}
storageConfigSpec, err := config.AddStorageDevices(noExistingDevices)
if err != nil {
t.Fatalf("unexpected erro: %q", err.Error())
t.Fatalf("unexpected error: %q", err.Error())
}
if len(storageConfigSpec) != 3 {
t.Fatalf("Expecting VirtualDeviceList to have 3 storage devices but had %d", len(storageConfigSpec))
Expand All @@ -41,7 +41,7 @@ func TestAddStorageDevices(t *testing.T) {

storageConfigSpec, err = config.AddStorageDevices(existingDevices)
if err != nil {
t.Fatalf("unexpected erro: %q", err.Error())
t.Fatalf("unexpected error: %q", err.Error())
}
if len(storageConfigSpec) != 3 {
t.Fatalf("Expecting VirtualDeviceList to have 3 storage devices but had %d", len(storageConfigSpec))
Expand Down
4 changes: 2 additions & 2 deletions builder/vsphere/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// Defines whether acceptance tests should be run
const TestHostName = "esxi-1.vsphere65.test"
const TestHostName = "esxi-01.example.com"

func newTestDriver(t *testing.T) Driver {
username := os.Getenv("VSPHERE_USERNAME")
Expand All @@ -37,7 +37,7 @@ func newTestDriver(t *testing.T) Driver {
}

d, err := NewDriver(&ConnectConfig{
VCenterServer: "vcenter.vsphere65.test",
VCenterServer: "vcenter.example.com",
Username: username,
Password: password,
InsecureConnection: true,
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/driver/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (l *LibraryFilePath) Validate() error {
l.path = strings.TrimLeft(l.path, "/")
parts := strings.Split(l.path, "/")
if len(parts) != 3 {
return fmt.Errorf("Not a valid Content Library File path. The path must contain the nanmes for the library, item and file.")
return fmt.Errorf("invalid content library file path. path must contain the names for the library, item, and file.")
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion builder/vsphere/driver/resource_pool_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "testing"
func TestResourcePoolAcc(t *testing.T) {
t.Skip("Acceptance tests not configured yet.")
d := newTestDriver(t)
p, err := d.FindResourcePool("", "esxi-1.vsphere65.test", "pool1/pool2")
p, err := d.FindResourcePool("", "esxi-01.example.com", "pool1/pool2")
if err != nil {
t.Fatalf("Cannot find the default resource pool '%v': %v", "pool1/pool2", err)
}
Expand Down
8 changes: 4 additions & 4 deletions builder/vsphere/driver/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ func (d *VCenterDriver) PreCleanVM(ui packersdk.Ui, vmPath string, force bool, v
// covert to a vm if it is a template so it can be deleted
isTemplate, err := vm.IsTemplate()
if err != nil {
return fmt.Errorf("error determing if the vm is a template%s: %v", vmPath, err)
return fmt.Errorf("error determining if the vm is a template%s: %v", vmPath, err)
} else if isTemplate {
ui.Say(fmt.Sprintf("%s is a template, attempting to convert it to a vm", vmPath))
err := vm.ConvertToVirtualMachine(vsphereCluster, vsphereHost, vsphereResourcePool)
if err != nil {
return fmt.Errorf("error convertng template back to virtual machine for cleanup %s: %v", vmPath, err)
return fmt.Errorf("error converting template back to virtual machine for cleanup %s: %v", vmPath, err)
}
}

Expand Down Expand Up @@ -316,7 +316,7 @@ func (vm *VirtualMachineDriver) FloppyDevices() (object.VirtualDeviceList, error
func (vm *VirtualMachineDriver) Clone(ctx context.Context, config *CloneConfig) (VirtualMachine, error) {
folder, err := vm.driver.FindFolder(config.Folder)
if err != nil {
return nil, fmt.Errorf("Error finding filder: %s", err)
return nil, fmt.Errorf("Error finding folder: %s", err)
}

var relocateSpec types.VirtualMachineRelocateSpec
Expand Down Expand Up @@ -1062,7 +1062,7 @@ func findNetwork(network string, host string, d *VCenterDriver) (object.NetworkR
return object.NewNetwork(d.client.Client, i.Network[0]), nil
}

return nil, fmt.Errorf("Couldn't find network; 'host' and 'network' not specified. At least one of the two must be specified.")
return nil, fmt.Errorf("error finding network; 'host' and 'network' not specified. at least one of the two must be specified.")
}

func newVGPUProfile(vGPUProfile string) types.VirtualPCIPassthrough {
Expand Down
6 changes: 3 additions & 3 deletions builder/vsphere/driver/vm_clone_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestVMAcc_clone(t *testing.T) {
t.Fatalf("Cannot find template vm '%v': %v", templateName, err)
}

log.Printf("[DEBUG] Clonning VM")
log.Printf("[DEBUG] Cloning VM")
vm, err := template.Clone(context.TODO(), tc.config)
if err != nil {
t.Fatalf("Cannot clone vm '%v': %v", templateName, err)
Expand Down Expand Up @@ -170,7 +170,7 @@ func configureCheck(t *testing.T, vm VirtualMachine, _ *CloneConfig) {

memoryHotAdd := vmInfo.Config.MemoryHotAddEnabled
if *memoryHotAdd != hwConfig.MemoryHotAddEnabled {
t.Errorf("VM should have Memroy hot add set to %v, got %v", hwConfig.MemoryHotAddEnabled, memoryHotAdd)
t.Errorf("VM should have memory hot add set to %v, got %v", hwConfig.MemoryHotAddEnabled, memoryHotAdd)
}
}

Expand Down Expand Up @@ -253,7 +253,7 @@ func startAndStopCheck(t *testing.T, vm VirtualMachine, config *CloneConfig) {
log.Printf("[DEBUG] Waiting max 1m0s for shutdown to complete")
err = vm.WaitForShutdown(context.TODO(), 1*time.Minute)
if err != nil {
t.Fatalf("Failed to wait for giest shutdown: %v", err)
t.Fatalf("Failed to wait for guest shutdown: %v", err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions builder/vsphere/examples/alpine/alpine-3.8.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"{{template_dir}}/setup.sh"
],
"guest_os_type": "other3xLinux64Guest",
"host": "esxi-1.vsphere65.test",
"host": "esxi-01.example.com",
"insecure_connection": true,
"iso_paths": [
"[datastore1] ISO/alpine-standard-3.8.2-x86_64.iso"
Expand All @@ -49,7 +49,7 @@
}
],
"username": "root",
"vcenter_server": "vcenter.vsphere65.test",
"vcenter_server": "vcenter.example.com",
"vm_name": "alpine-{{timestamp}}"
}
],
Expand All @@ -61,4 +61,4 @@
"type": "shell"
}
]
}
}
4 changes: 2 additions & 2 deletions builder/vsphere/examples/alpine/alpine-3.8.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ source "vsphere-iso" "autogenerated_1" {
disk_controller_type = ["pvscsi"]
floppy_files = ["${path.root}/answerfile", "${path.root}/setup.sh"]
guest_os_type = "other3xLinux64Guest"
host = "esxi-1.vsphere65.test"
host = "esxi-01.example.com"
insecure_connection = true
iso_paths = ["[datastore1] ISO/alpine-standard-3.8.2-x86_64.iso"]
network_adapters {
Expand All @@ -31,7 +31,7 @@ source "vsphere-iso" "autogenerated_1" {
disk_thin_provisioned = true
}
username = "root"
vcenter_server = "vcenter.vsphere65.test"
vcenter_server = "vcenter.example.com"
vm_name = "alpine-${local.timestamp}"
}

Expand Down
4 changes: 2 additions & 2 deletions builder/vsphere/examples/clone/alpine.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
{
"type": "vsphere-clone",

"vcenter_server": "vcenter.vsphere65.test",
"vcenter_server": "vcenter.example.com",
"username": "root",
"password": "jetbrains",
"insecure_connection": "true",

"template": "alpine",
"vm_name": "alpine-clone-{{timestamp}}",
"host": "esxi-1.vsphere65.test",
"host": "esxi-01.example.com",

"communicator": "none"
}
Expand Down
4 changes: 2 additions & 2 deletions builder/vsphere/examples/clone/alpine.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
source "vsphere-clone" "example_clone" {
communicator = "none"
host = "esxi-1.vsphere65.test"
host = "esxi-01.example.com"
insecure_connection = "true"
password = "jetbrains"
template = "alpine"
username = "root"
vcenter_server = "vcenter.vsphere65.test"
vcenter_server = "vcenter.example.com"
vm_name = "alpine-clone-${local.timestamp}"
}

Expand Down
Loading

0 comments on commit 6208989

Please sign in to comment.