diff options
author | clyhtsuriva <aimeric@adjutor.xyz> | 2025-02-08 20:20:02 +0100 |
---|---|---|
committer | clyhtsuriva <aimeric@adjutor.xyz> | 2025-02-08 20:20:02 +0100 |
commit | 41b4c6897cd61f8f7bbfc26d130150f135e1fefd (patch) | |
tree | 5c0f1702e82ac06050eb7681b8e404037a2a31e9 | |
parent | 1e0f492b1d7f998cb7996e0f307c1e32a07cea36 (diff) |
opentofu: add types and descriptions to modules' variables
-rw-r--r-- | opentofu/modules/ansible_provisioner/main.tf | 12 | ||||
-rw-r--r-- | opentofu/modules/ansible_provisioner/variables.tf | 26 | ||||
-rw-r--r-- | opentofu/modules/k8s_cluster/main.tf | 0 | ||||
-rw-r--r-- | opentofu/modules/k8s_cluster/outputs.tf | 0 | ||||
-rw-r--r-- | opentofu/modules/k8s_cluster/variables.tf | 0 | ||||
-rw-r--r-- | opentofu/modules/k8s_control_plane/variables.tf | 168 | ||||
-rw-r--r-- | opentofu/modules/k8s_worker/variables.tf | 175 | ||||
-rw-r--r-- | opentofu/versions.tf | 4 |
8 files changed, 322 insertions, 63 deletions
diff --git a/opentofu/modules/ansible_provisioner/main.tf b/opentofu/modules/ansible_provisioner/main.tf index cac666d..0de288e 100644 --- a/opentofu/modules/ansible_provisioner/main.tf +++ b/opentofu/modules/ansible_provisioner/main.tf @@ -1,15 +1,3 @@ -variable "vm_ip" { - default = null -} - -variable "inventory_file_path" { - default = null -} - -variable "vm_username" {} -variable "ssh_private_key_path" {} -variable "ansible_playbook_path" {} - resource "null_resource" "ansible_provisioner" { triggers = { ip_or_inventory = coalesce(var.vm_ip, var.inventory_file_path) # Choose based on what is provided diff --git a/opentofu/modules/ansible_provisioner/variables.tf b/opentofu/modules/ansible_provisioner/variables.tf new file mode 100644 index 0000000..0d15d01 --- /dev/null +++ b/opentofu/modules/ansible_provisioner/variables.tf @@ -0,0 +1,26 @@ +variable "vm_ip" { + type = string + default = null + description = "The IP address of the VM to provision. Either this or `inventory_file_path` must be provided." +} + +variable "inventory_file_path" { + type = string + default = null + description = "The path to the Ansible inventory file. Either this or `vm_ip` must be provided." +} + +variable "vm_username" { + type = string + description = "The username to use for SSH access to the VM." +} + +variable "ssh_private_key_path" { + type = string + description = "The path to the private SSH key for accessing the VM." +} + +variable "ansible_playbook_path" { + type = string + description = "The path to the Ansible playbook to execute." +} diff --git a/opentofu/modules/k8s_cluster/main.tf b/opentofu/modules/k8s_cluster/main.tf deleted file mode 100644 index e69de29..0000000 --- a/opentofu/modules/k8s_cluster/main.tf +++ /dev/null diff --git a/opentofu/modules/k8s_cluster/outputs.tf b/opentofu/modules/k8s_cluster/outputs.tf deleted file mode 100644 index e69de29..0000000 --- a/opentofu/modules/k8s_cluster/outputs.tf +++ /dev/null diff --git a/opentofu/modules/k8s_cluster/variables.tf b/opentofu/modules/k8s_cluster/variables.tf deleted file mode 100644 index e69de29..0000000 --- a/opentofu/modules/k8s_cluster/variables.tf +++ /dev/null diff --git a/opentofu/modules/k8s_control_plane/variables.tf b/opentofu/modules/k8s_control_plane/variables.tf index e359f77..4ffb3bd 100644 --- a/opentofu/modules/k8s_control_plane/variables.tf +++ b/opentofu/modules/k8s_control_plane/variables.tf @@ -1,25 +1,143 @@ -variable "name" {} -variable "desc" {} -variable "agent" {} -variable "target_node" {} -variable "tags" {} -variable "clone" {} -variable "full_clone" {} -variable "qemu_os" {} -variable "cores" {} -variable "sockets" {} -variable "cpu_type" {} -variable "memory" {} -variable "scsihw" {} -variable "bootdisk" {} -variable "cloudinit_storage" {} -variable "disk_storage" {} -variable "disk_size" {} -variable "iothread" {} -variable "replicate" {} -variable "network_id" {} -variable "network_model" {} -variable "network_bridge" {} -variable "ipconfig0" {} -variable "ciuser" {} -variable "sshkeys" {} +variable "name" { + type = string + description = "The name of the virtual machine." +} + +variable "desc" { + type = string + description = "A description of the virtual machine." + default = "" +} + +variable "agent" { + type = number + description = "Whether to enable the QEMU guest agent (0 = disabled, 1 = enabled)." + default = 0 +} + +variable "target_node" { + type = string + description = "The name of the Proxmox node where the VM will be created." +} + +variable "tags" { + type = string + description = "Tags to assign to the virtual machine." + default = "" +} + +variable "clone" { + type = string + description = "The name of the VM template to clone." +} + +variable "full_clone" { + type = bool + description = "Whether to create a full clone of the template (true) or a linked clone (false)." + default = true +} + +variable "qemu_os" { + type = string + description = "The type of OS installed on the VM." + default = "l26" # Default is Linux 2.6/3.x/4.x/5.x kernel +} + +variable "cores" { + type = number + description = "The number of CPU cores to allocate to the VM." + default = 1 +} + +variable "sockets" { + type = number + description = "The number of CPU sockets to allocate to the VM." + default = 1 +} + +variable "cpu_type" { + type = string + description = "The type of CPU to emulate (e.g., 'host', 'kvm64')." + default = "host" +} + +variable "memory" { + type = number + description = "The amount of memory (in MB) to allocate to the VM." + default = 1024 +} + +variable "scsihw" { + type = string + description = "The SCSI controller type (e.g., 'virtio-scsi-pci', 'virtio-scsi-single')." + default = "virtio-scsi-pci" +} + +variable "bootdisk" { + type = string + description = "The boot disk interface (e.g., 'scsi0', 'virtio0')." + default = "virtio0" +} + +variable "cloudinit_storage" { + type = string + description = "The storage pool for the cloud-init drive." +} + +variable "disk_storage" { + type = string + description = "The storage pool for the primary disk." +} + +variable "disk_size" { + type = string + description = "The size of the primary disk (e.g., '20G')." +} + +variable "iothread" { + type = bool + description = "Whether to enable IO threading for the disk." + default = false +} + +variable "replicate" { + type = bool + description = "Whether to replicate the disk to other nodes." + default = false +} + +variable "network_id" { + type = number + description = "The ID of the network interface." + default = 0 +} + +variable "network_model" { + type = string + description = "The model of the network interface (e.g., 'virtio')." + default = "virtio" +} + +variable "network_bridge" { + type = string + description = "The bridge to attach the network interface to." + default = "vmbr0" +} + +variable "ipconfig0" { + type = string + description = "The IP configuration for the VM (e.g., 'ip=dhcp')." + default = "ip=dhcp" +} + +variable "ciuser" { + type = string + description = "The username for cloud-init." + default = "" +} + +variable "sshkeys" { + type = string + description = "The SSH public keys to inject into the VM via cloud-init." + default = "" +} diff --git a/opentofu/modules/k8s_worker/variables.tf b/opentofu/modules/k8s_worker/variables.tf index 1328088..e11a5a2 100644 --- a/opentofu/modules/k8s_worker/variables.tf +++ b/opentofu/modules/k8s_worker/variables.tf @@ -1,26 +1,149 @@ -variable "vm_count" {} -variable "name_prefix" {} -variable "desc" {} -variable "agent" {} -variable "target_node" {} -variable "tags" {} -variable "clone" {} -variable "full_clone" {} -variable "qemu_os" {} -variable "cores" {} -variable "sockets" {} -variable "cpu_type" {} -variable "memory" {} -variable "scsihw" {} -variable "bootdisk" {} -variable "cloudinit_storage" {} -variable "disk_storage" {} -variable "disk_size" {} -variable "iothread" {} -variable "replicate" {} -variable "network_id" {} -variable "network_model" {} -variable "network_bridge" {} -variable "ipconfig0" {} -variable "ciuser" {} -variable "sshkeys" {} +variable "vm_count" { + type = number + description = "The number of virtual machines to create." + default = 1 +} + +variable "name_prefix" { + type = string + description = "The prefix for the names of the virtual machines. The VM names will be in the format '<name_prefix>-<index>'." +} + +variable "desc" { + type = string + description = "A description of the virtual machines." + default = "" +} + +variable "agent" { + type = number + description = "Whether to enable the QEMU guest agent (0 = disabled, 1 = enabled)." + default = 0 +} + +variable "target_node" { + type = string + description = "The name of the Proxmox node where the VMs will be created." +} + +variable "tags" { + type = string + description = "Tags to assign to the virtual machines." + default = "" +} + +variable "clone" { + type = string + description = "The name of the VM template to clone." +} + +variable "full_clone" { + type = bool + description = "Whether to create a full clone of the template (true) or a linked clone (false)." + default = true +} + +variable "qemu_os" { + type = string + description = "The type of OS installed on the VMs." + default = "l26" # Default is Linux 2.6/3.x/4.x/5.x kernel +} + +variable "cores" { + type = number + description = "The number of CPU cores to allocate to each VM." + default = 1 +} + +variable "sockets" { + type = number + description = "The number of CPU sockets to allocate to each VM." + default = 1 +} + +variable "cpu_type" { + type = string + description = "The type of CPU to emulate (e.g., 'host', 'kvm64')." + default = "host" +} + +variable "memory" { + type = number + description = "The amount of memory (in MB) to allocate to each VM." + default = 1024 +} + +variable "scsihw" { + type = string + description = "The SCSI controller type (e.g., 'virtio-scsi-pci', 'virtio-scsi-pci')." + default = "virtio-scsi-pci" +} + +variable "bootdisk" { + type = string + description = "The boot disk interface (e.g., 'scsi0', 'virtio0')." + default = "virtio0" +} + +variable "cloudinit_storage" { + type = string + description = "The storage pool for the cloud-init drive." +} + +variable "disk_storage" { + type = string + description = "The storage pool for the primary disk." +} + +variable "disk_size" { + type = string + description = "The size of the primary disk (e.g., '20G')." +} + +variable "iothread" { + type = bool + description = "Whether to enable IO threading for the disk." + default = false +} + +variable "replicate" { + type = bool + description = "Whether to replicate the disk to other nodes." + default = false +} + +variable "network_id" { + type = number + description = "The ID of the network interface." + default = 0 +} + +variable "network_model" { + type = string + description = "The model of the network interface (e.g., 'virtio')." + default = "virtio" +} + +variable "network_bridge" { + type = string + description = "The bridge to attach the network interface to." + default = "vmbr0" +} + +variable "ipconfig0" { + type = string + description = "The IP configuration for the VMs (e.g., 'ip=dhcp')." + default = "ip=dhcp" +} + +variable "ciuser" { + type = string + description = "The username for cloud-init." + default = "" +} + +variable "sshkeys" { + type = string + description = "The SSH public keys to inject into the VMs via cloud-init." + default = "" +} diff --git a/opentofu/versions.tf b/opentofu/versions.tf index d9656aa..de393ca 100644 --- a/opentofu/versions.tf +++ b/opentofu/versions.tf @@ -6,5 +6,9 @@ terraform { source = "telmate/proxmox" version = "3.0.1-rc6" } + local = { + source = "hashicorp/local" + version = ">= 2.4.0" + } } } |