Skip to content

Commit

Permalink
feat: improved modules
Browse files Browse the repository at this point in the history
  • Loading branch information
beholdenkey committed Oct 11, 2023
1 parent 7e17c72 commit 54ffce9
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 136 deletions.
63 changes: 36 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,50 @@ Terraform modules which creates Virtual Machines on Harvester HCI

<!-- BEGIN_TF_DOCS -->


## Modules

| Name | Source | Version |
| -------------------- | ------------------------------ | ------- |
| harvester_vm | ./modules/harvester-vm | n/a |
| harvester_vm_image | ./modules/harvester-vm-image | n/a |
| harvester_vm_network | ./modules/harvester-vm-network | n/a |
| Name | Source | Version |
|------|--------|---------|
| harvester_vm | ./modules/harvester-vm | n/a |
| harvester_vm_image | ./modules/harvester-vm-image | n/a |
| harvester_vm_network | ./modules/harvester-vm-network | n/a |



## Inputs

| Name | Description | Type | Default | Required |
| ------------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
| cluster_network_name | Cluster network name | `string` | n/a | yes |
| harvester_kubeconfig_path | Path to the kubeconfig file | `string` | n/a | yes |
| image_display_name | The display name for the OS image | `string` | n/a | yes |
| image_name | The name of the OS image | `string` | n/a | yes |
| image_namespace | The namespace where the image will reside | `string` | n/a | yes |
| image_source_type | Source type for the image (e.g., download, upload) | `string` | n/a | yes |
| image_url | URL from where the image will be downloaded | `string` | n/a | yes |
| network_name | Name of the network | `string` | n/a | yes |
| network_namespace | Namespace of the network | `string` | n/a | yes |
| network_vlan_id | VLAN ID for the network | `string` | n/a | yes |
| user_data | User data for cloud-init configuration | `string` | n/a | yes |
| vm_data | Configuration data for the virtual machine | `object({ name = string # Name of the virtual machine hostname = string # Hostname for the virtual machine namespace = string # Namespace where the VM will reside description = string # Description for the VM tags = map(string) # Tags associated with the VM cpus = number # Number of CPUs for the VM memory = string # Memory allocation for the VM disks = list(object({ # List of disks for the VM name = string # Name of the disk size = string # Size of the disk boot_order = number # Boot order for the disk })) })` | n/a | yes |
| image_tags | Tags associated with the image | `map(string)` | `{}` | no |
| network_data | Network data for cloud-init configuration | `string` | `""` | no |
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| cluster_network_name | Cluster network name | `string` | n/a | yes |
| harvester_kubeconfig_path | Path to the kubeconfig file | `string` | n/a | yes |
| image_display_name | The display name for the OS image | `string` | n/a | yes |
| image_name | The name of the OS image | `string` | n/a | yes |
| image_namespace | The namespace where the image will reside | `string` | n/a | yes |
| image_source_type | Source type for the image (e.g., download, upload) | `string` | n/a | yes |
| image_url | URL from where the image will be downloaded | `string` | n/a | yes |
| network_name | Name of the network | `string` | n/a | yes |
| network_namespace | Namespace of the network | `string` | n/a | yes |
| network_vlan_id | VLAN ID for the network | `string` | n/a | yes |
| user_data | User data for cloud-init configuration | `string` | n/a | yes |
| vm_cpus | Number of CPUs for the VM | `number` | n/a | yes |
| vm_description | Description for the VM | `string` | n/a | yes |
| vm_disks | List of disks for the VM | ```list(object({ name = string # Name of the disk type = string # Type of the disk size = string # Size of the disk bus = string # Bus type of the disk boot_order = number # Boot order for the disk auto_delete = bool # Auto delete flag for the disk }))``` | n/a | yes |
| vm_hostname | Hostname for the virtual machine | `string` | n/a | yes |
| vm_memory | Memory allocation for the VM | `string` | n/a | yes |
| vm_name | Name of the virtual machine | `string` | n/a | yes |
| vm_namespace | Namespace where the VM will reside | `string` | n/a | yes |
| image_tags | Tags associated with the image | `map(string)` | `{}` | no |
| network_data | Network data for cloud-init configuration | `string` | `""` | no |
| vm_tags | Tags associated with the VM | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
| ---------- | ------------------------------------- |
| image_id | The ID of the VM image |
| network_id | The name of the network |
| vm_id | The ID of the created virtual machine |

| Name | Description |
|------|-------------|
| image_id | The ID of the VM image |
| network_id | The name of the network |
| vm_id | The ID of the created virtual machine |
<!-- END_TF_DOCS -->

## References
Expand Down
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ module "harvester_vm_image" {
module "harvester_vm" {
source = "./modules/harvester-vm"
vm_image_id = module.harvester_vm_image.image_id
vm_data = var.vm_data
name = var.vm_name
hostname = var.vm_hostname
namespace = var.vm_namespace
description = var.vm_description
tags = var.vm_tags
cpu = var.vm_cpus
memory = var.vm_memory
disks = var.vm_disks
user_data = var.user_data
network_data = var.network_data
network_name = module.harvester_vm_network.network_name
Expand Down
38 changes: 21 additions & 17 deletions modules/harvester-vm-image/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
# Submodule - harvester-vm-image

<!-- BEGIN_TF_DOCS -->

## Providers

| Name | Version |
| --------- | ------- |
| harvester | 0.6.3 |
| Name | Version |
|------|---------|
| harvester | 0.6.3 |



## Resources

| Name | Type |
| ------------------------------------------------------------------------------------------------------------------ | -------- |
| Name | Type |
|------|------|
| [harvester_image.vm_image](https://registry.terraform.io/providers/harvester/harvester/0.6.3/docs/resources/image) | resource |

## Inputs

| Name | Description | Type | Default | Required |
| ------------ | -------------------------------------------------- | ------------- | ------- | :------: |
| display_name | The display name for the OS image | `string` | n/a | yes |
| name | The name of the OS image | `string` | n/a | yes |
| namespace | The namespace where the image will reside | `string` | n/a | yes |
| source_type | Source type for the image (e.g., download, upload) | `string` | n/a | yes |
| url | URL from where the image will be downloaded | `string` | n/a | yes |
| tags | Tags associated with the image | `map(string)` | `{}` | no |
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| display_name | The display name for the OS image | `string` | n/a | yes |
| name | The name of the OS image | `string` | n/a | yes |
| namespace | The namespace where the image will reside | `string` | n/a | yes |
| source_type | Source type for the image (e.g., download, upload) | `string` | n/a | yes |
| url | URL from where the image will be downloaded | `string` | n/a | yes |
| description | Any text you want that better describes this resource | `string` | `""` | no |
| pvc_name | PVC Name | `string` | `""` | no |
| pvc_namespace | PVC Namespace | `string` | `""` | no |
| storage_class_name | The name of the storage class | `string` | `""` | no |
| tags | Tags associated with the image | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
| -------- | ---------------------- |
| Name | Description |
|------|-------------|
| image_id | The ID of the VM image |

<!-- END_TF_DOCS -->
16 changes: 10 additions & 6 deletions modules/harvester-vm-image/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
resource "harvester_image" "vm_image" {
name = var.name
namespace = var.namespace
display_name = var.display_name
source_type = var.source_type
url = var.url
tags = var.tags
name = var.name
namespace = var.namespace
display_name = var.display_name
source_type = var.source_type
url = var.url
tags = var.tags
description = var.description
storage_class_name = var.storage_class_name
pvc_name = var.pvc_name
pvc_namespace = var.pvc_namespace
}
24 changes: 24 additions & 0 deletions modules/harvester-vm-image/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "display_name" {
type = string
}

variable "description" {
description = "Any text you want that better describes this resource"
type = string
default = ""
}

variable "source_type" {
description = "Source type for the image (e.g., download, upload)"
type = string
Expand All @@ -32,3 +38,21 @@ variable "tags" {
type = map(string)
default = {}
}

variable "storage_class_name" {
description = "The name of the storage class"
type = string
default = ""
}

variable "pvc_name" {
description = "PVC Name"
type = string
default = ""
}

variable "pvc_namespace" {
description = "PVC Namespace"
type = string
default = ""
}
30 changes: 15 additions & 15 deletions modules/harvester-vm-network/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# Submodule: harvester-vm-network

<!-- BEGIN_TF_DOCS -->

## Providers

| Name | Version |
| --------- | ------- |
| harvester | 0.6.3 |
| Name | Version |
|------|---------|
| harvester | 0.6.3 |



## Resources

| Name | Type |
| ------------------------------------------------------------------------------------------------------------------------ | -------- |
| Name | Type |
|------|------|
| [harvester_network.vm_network](https://registry.terraform.io/providers/harvester/harvester/0.6.3/docs/resources/network) | resource |

## Inputs

| Name | Description | Type | Default | Required |
| -------------------- | ------------------------ | -------- | ------- | :------: |
| cluster_network_name | Cluster network name | `string` | n/a | yes |
| name | Name of the network | `string` | n/a | yes |
| namespace | Namespace of the network | `string` | n/a | yes |
| vlan_id | VLAN ID for the network | `string` | n/a | yes |
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| cluster_network_name | Cluster network name | `string` | n/a | yes |
| name | Name of the network | `string` | n/a | yes |
| namespace | Namespace of the network | `string` | n/a | yes |
| vlan_id | VLAN ID for the network | `string` | n/a | yes |

## Outputs

| Name | Description |
| ------------ | ----------------------- |
| Name | Description |
|------|-------------|
| network_name | The name of the network |

<!-- END_TF_DOCS -->
Loading

0 comments on commit 54ffce9

Please sign in to comment.