Skip to content

Commit fa956df

Browse files
authored
add ability to set Proxmox HA options (#23)
1 parent ce4058f commit fa956df

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.terraform.lock.hcl
2+
.terraform/

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Ability to set Proxmox HA options.
13+
1014
## [1.3.0] - 2022-12-03
1115

1216
### Added

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@ This module is an opinionated take on creating a VM in Proxmox; not all possible
1111
| Name | Description | Type | Default | Required |
1212
|------|-------------|------|---------|:--------:|
1313
| boot | Boot order for the instance. | `string` | `"cdn"` | no |
14-
| cicustom | Path(s) to cloud-init config files (ignored when pxe_boot is true). | `string` | `""` | no |
15-
| citemplate_storage | Name of the storage containing the cloud-init snippets (ignored when pxe_boot is true). | `string` | `"local"` | no |
16-
| clone | Name of the template to clone (ignored when pxe_boot is true). | `string` | `""` | no |
17-
| cloudinit_cdrom_storage | Name of the storage to create the cloud-init image in. | `string` | `"local-lvm"` | no |
14+
| cicustom | Path(s) to cloud-init config files (ignored when pxe_boot is true). | `string` | `null` | no |
15+
| citemplate_storage | Name of the storage containing the cloud-init snippets (ignored when pxe_boot is true). | `string` | `null` | no |
16+
| clone | Name of the template to clone (ignored when pxe_boot is true). | `string` | `null` | no |
17+
| cloudinit_cdrom_storage | Name of the storage to create the cloud-init image in (e.g. local-lvm). | `string` | `null` | no |
1818
| cores | Number of cores to allocate. | `number` | n/a | yes |
1919
| disks | List of objects representing additional disks. | <pre>list(object({<br> type = string<br> storage = string<br> size = string<br> }))</pre> | `null` | no |
20-
| full_clone | Create a full clone; if false, a linked clone will be created (ignored when pxe_boot is true). | `bool` | `false` | no |
21-
| instance_domain | Domain name to use. | `string` | n/a | yes |
20+
| full_clone | Create a full clone; if false, a linked clone will be created (ignored when pxe_boot is true). | `bool` | `null` | no |
21+
| hagroup | The HA group identifier the resource belongs to. | `string` | `null` | no |
22+
| hastate | Requested HA state for the resource. | `string` | `null` | no |
2223
| memory | Amount of memory to allocate. | `number` | n/a | yes |
23-
| nameserver | Nameserver to use in the instance. | `string` | n/a | yes |
2424
| network_interfaces | List of objects representing instance interface configuration. | <pre>list(object({<br> model = string<br> bridge = string<br> tag = number<br> macaddr = string<br> }))</pre> | n/a | yes |
25-
| os_type | Type of OS for preprovisioning. | `string` | `""` | no |
25+
| os_type | Type of OS for preprovisioning. | `string` | `null` | no |
2626
| pve_instance_description | Description of the instance. | `string` | n/a | yes |
2727
| pve_instance_name | Name of the instance. | `string` | n/a | yes |
2828
| pxe_boot | Set PXE boot mode | `bool` | `false` | no |
2929
| qemu_agent | Enable QEMU guest agent (must be installed in the template). Set to `1` to enable or `0` to disable. | `number` | `0` | no |
3030
| resource_pool | Name of the resource pool the assign the instance to. | `string` | n/a | yes |
31-
| searchdomain | DNS searchdomain to use. | `string` | n/a | yes |
3231
| snippet_dir | Name of the snippet subdirectory. | `string` | `"snippets"` | no |
3332
| snippet_file_base | Path to the directory containing the snippet_dir. | `string` | `"/var/lib/vz"` | no |
3433
| sockets | Number of sockets to allocate. | `number` | n/a | yes |

instance.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ resource "proxmox_vm_qemu" "proxmox_instance" {
1313
target_node = var.target_node
1414
pool = var.resource_pool
1515

16+
hastate = var.hastate
17+
hagroup = var.hagroup
18+
1619
cores = var.cores
1720
sockets = var.sockets
1821
memory = var.memory

variables.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ variable "resource_pool" {
4141
type = string
4242
}
4343

44+
variable "hastate" {
45+
default = null
46+
description = "Requested HA state for the resource."
47+
type = string
48+
validation {
49+
condition = anytrue([
50+
var.hastate == "disabled",
51+
var.hastate == "enabled",
52+
var.hastate == "ignored",
53+
var.hastate == "started",
54+
var.hastate == "stopped",
55+
var.hastate == null
56+
])
57+
error_message = "Must be one of 'disabled', 'enabled', 'ignored', 'started', 'stopped', or null (default)."
58+
}
59+
}
60+
61+
variable "hagroup" {
62+
default = null
63+
description = "The HA group identifier the resource belongs to."
64+
type = string
65+
}
66+
4467
variable "cores" {
4568
description = "Number of cores to allocate."
4669
type = number

0 commit comments

Comments
 (0)