Skip to content

Commit e7dcd93

Browse files
tenthirtyamlbajolet-hashicorp
authored andcommitted
refactor: update alpine example
Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
1 parent 7948b15 commit e7dcd93

File tree

7 files changed

+268
-194
lines changed

7 files changed

+268
-194
lines changed

examples/builder/vsphere-clone/alpine/alpine.json

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,78 @@
11
# Copyright (c) HashiCorp, Inc.
22
# SPDX-License-Identifier: MPL-2.0
33

4-
# "timestamp" template function replacement
4+
packer {
5+
required_plugins {
6+
vsphere = {
7+
version = "~> 1"
8+
source = "github.com/hashicorp/vsphere"
9+
}
10+
}
11+
}
12+
13+
variable "vm_name_prefix" {
14+
type = string
15+
default = "alpine"
16+
description = "Prefix for naming the virtual machine."
17+
}
18+
19+
variable "guest_os_type" {
20+
type = string
21+
default = "other5xLinux64Guest"
22+
description = "The type of guest OS to configure for the virtual machine."
23+
}
24+
25+
variable "username" {
26+
type = string
27+
default = "administrator@vsphere.local"
28+
sensitive = true
29+
description = "The username for authenticating with the vCenter instance."
30+
}
31+
32+
variable "password" {
33+
type = string
34+
default = "VMw@re1!"
35+
sensitive = true
36+
description = "The password for authenticating with the vCenter instance."
37+
}
38+
39+
variable "vcenter_server" {
40+
type = string
41+
default = "vcenter.example.com"
42+
description = "The vCenter instance used for managing the ESX host."
43+
}
44+
45+
variable "host" {
46+
type = string
47+
default = "esx-01.example.com"
48+
description = "The ESX host where the virtual machine will be built."
49+
}
50+
51+
variable "insecure_connection" {
52+
type = bool
53+
default = true
54+
description = "Set to true to allow insecure connections to the vCenter instance."
55+
}
56+
57+
variable "communicator"
58+
type = string
59+
default = "none"
60+
}
61+
562
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
663

7-
# source blocks are analogous to the "builders" in json templates. They are used
8-
# in build blocks. A build block runs provisioners and post-processors on a
9-
# source. Read the documentation for source blocks here:
10-
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
11-
source "vsphere-clone" "example_clone" {
12-
communicator = "none"
13-
host = "esxi-01.example.com"
14-
insecure_connection = "true"
15-
password = "VMw@re1!"
16-
template = "alpine"
17-
username = "administrator@vsphere.local"
18-
vcenter_server = "vcenter.example.com"
19-
vm_name = "alpine-clone-${local.timestamp}"
20-
}
21-
22-
# a build block invokes sources and runs provisioning steps on them. The
23-
# documentation for build blocks can be found here:
24-
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
64+
source "vsphere-clone" "example" {
65+
communicator = var.communicator
66+
username = var.username
67+
password = var.password
68+
vcenter_server = var.vcenter_server
69+
host = var.host
70+
insecure_connection = var.insecure_connection
71+
vm_name = "${var.vm_name_prefix}-${local.timestamp}"
72+
template = var.vm_name_prefix
73+
}
74+
2575
build {
26-
sources = ["source.vsphere-clone.example_clone"]
76+
sources = ["source.vsphere-clone.example"]
2777

2878
}

examples/builder/vsphere-iso/alpine/alpine-3.20.3.json

Lines changed: 0 additions & 65 deletions
This file was deleted.

examples/builder/vsphere-iso/alpine/alpine-3.20.3.pkr.hcl

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)