Skip to content

Commit

Permalink
Merge pull request #1008 from Tinyblargon/new-ci-disk
Browse files Browse the repository at this point in the history
Move `cloudinit` disk to `disks` schema
  • Loading branch information
Tinyblargon authored May 18, 2024
2 parents 99bd91b + c585fa2 commit e967631
Show file tree
Hide file tree
Showing 4 changed files with 331 additions and 140 deletions.
10 changes: 9 additions & 1 deletion docs/guides/cloud_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,15 @@ EOF
*/
cicustom = "user=local:snippets/user_data_vm-${count.index}.yml"
/* Create the Cloud-Init drive on the "local-lvm" storage */
cloudinit_cdrom_storage = "local-lvm"
disks {
ide {
ide3 {
cloudinit {
storage = "local-lvm"
}
}
}
}
provisioner "remote-exec" {
inline = [
Expand Down
43 changes: 36 additions & 7 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ The following arguments are supported in the top level resource block.
| `ciuser` | `str` | | Override the default cloud-init user for provisioning. |
| `cipassword` | `str` | | Override the default cloud-init user's password. Sensitive. |
| `cicustom` | `str` | | Instead specifying ciuser, cipasword, etc... you can specify the path to a custom cloud-init config file here. Grants more flexibility in configuring cloud-init. |
| `cloudinit_cdrom_storage` | `str` | | Set the storage location for the cloud-init drive. Required when using cloud-init. |
| `searchdomain` | `str` | | Sets default DNS search domain suffix. |
| `nameserver` | `str` | | Sets default DNS server for guest. |
| `sshkeys` | `str` | | Newline delimited list of SSH public keys to add to authorized keys file for the cloud-init user. |
Expand Down Expand Up @@ -206,9 +205,10 @@ resource "proxmox_vm_qemu" "resource-name" {

### Disks.Ide Block

The `disks.ide` block is used to configure disks of type ide. It may only be specified once. It has the options `ide0` through `ide2`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:
The `disks.ide` block is used to configure disks of type ide. It may only be specified once. It has the options `ide0` through `ide3`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `cloudinit`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `cloudinit`: [Disks.x.Cloudinit Block](#disksxcloudinit-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

Expand All @@ -219,11 +219,21 @@ resource "proxmox_vm_qemu" "resource-name" {
disks {
ide {
ide0 {
disk {
cdrom {
//<arguments omitted for brevity...>
}
}
ide1 {
cloudinit {
//<arguments omitted for brevity...>
}
}
ide2 {
disk {
//<arguments omitted for brevity...>
}
}
ide3 {
passthrough {
//<arguments omitted for brevity...>
}
Expand All @@ -236,9 +246,10 @@ resource "proxmox_vm_qemu" "resource-name" {

### Disks.Sata Block

The `disks.sata` block is used to configure disks of type sata. It may only be specified once. It has the options `sata0` through `sata5`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:
The `disks.sata` block is used to configure disks of type sata. It may only be specified once. It has the options `sata0` through `sata5`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `cloudinit`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `cloudinit`: [Disks.x.Cloudinit Block](#disksxcloudinit-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

Expand All @@ -254,11 +265,16 @@ resource "proxmox_vm_qemu" "resource-name" {
}
}
sata1 {
disk {
cloudinit {
//<arguments omitted for brevity...>
}
}
sata2 {
disk {
//<arguments omitted for brevity...>
}
}
sata3 {
passthrough {
//<arguments omitted for brevity...>
}
Expand All @@ -272,9 +288,10 @@ resource "proxmox_vm_qemu" "resource-name" {

### Disks.Scsi Block

The `disks.scsi` block is used to configure disks of type scsi. It may only be specified once. It has the options `scsi0` through `scsi30`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:
The `disks.scsi` block is used to configure disks of type scsi. It may only be specified once. It has the options `scsi0` through `scsi30`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `cloudinit`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `cloudinit`: [Disks.x.Cloudinit Block](#disksxcloudinit-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

Expand All @@ -290,11 +307,16 @@ resource "proxmox_vm_qemu" "resource-name" {
}
}
scsi1 {
disk {
cloudinit {
//<arguments omitted for brevity...>
}
}
scsi2 {
disk {
//<arguments omitted for brevity...>
}
}
scsi3 {
passthrough {
//<arguments omitted for brevity...>
}
Expand Down Expand Up @@ -351,6 +373,13 @@ resource "proxmox_vm_qemu" "resource-name" {

When `iso` and `passthrough` are omitted an empty cdrom drive will be created.

### Disks.x.Cloudinit Block

Only **one** `cloudinit` block can be specified globally. This block is used to configure the cloud-init drive.

| Argument | Type | Default Value | Description|
| `cloudinit_cdrom_storage` | `str` | | Set the storage location for the cloud-init drive. Required when using cloud-init.|

### Disks.x.Disk Block

See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more details.
Expand Down
10 changes: 8 additions & 2 deletions examples/cloudinit_example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ resource "proxmox_vm_qemu" "cloudinit-test" {

# Setup the disk
disks {
ide {
ide3 {
cloudinit {
storage = "local-lvm"
}
}
}
virtio {
virtio0 {
disk {
Expand All @@ -55,8 +62,7 @@ resource "proxmox_vm_qemu" "cloudinit-test" {
}

# Setup the ip address using cloud-init.
cloudinit_cdrom_storage = "local-lvm"
boot = "order=virtio0;ide3"
boot = "order=virtio0"
# Keep in mind to use the CIDR notation for the ip.
ipconfig0 = "ip=192.168.10.20/24,gw=192.168.10.1"

Expand Down
Loading

0 comments on commit e967631

Please sign in to comment.