Skip to content

Commit

Permalink
add autostart parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kubealex committed Jan 4, 2024
1 parent d98e596 commit 2ccbc3d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/terraform-libvirt-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module "instance_provisioning" {
source = "kubealex/libvirt-resources/libvirt//modules/terraform-libvirt-pool"
version = "0.0.1"
instance_count = 2
instance_autostart = true
instance_cloud_image = "https://download.fedoraproject.org/pub/fedora/linux/releases/39/Cloud/x86_64/images/Fedora-Cloud-Base-39-1.5.x86_64.qcow2"
instance_type = "linux"
instance_hostname = "web-server"
Expand Down
1 change: 1 addition & 0 deletions modules/terraform-libvirt-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This Terraform module provisions virtual instances with customizable configurati
| ------------------------------ | -------------------------------------------------- | -------- | ------------------------ |
| `instance_count` | Number of instances to create || `1` |
| `instance_cloud_image` | Cloud image to use for instance provisioning || |
| `instance_autostart` | Flag to set instance autostart || true |
| `instance_iso_image` | ISO to use for instance provisioning || |
| `instance_additional_volume_size` | Additional block device size || `0` |
| `instance_cloudinit_path` | Cloud-init config to use for instance provisioning || `./cloud_init.cfg` |
Expand Down
1 change: 1 addition & 0 deletions modules/terraform-libvirt-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ data "template_file" "user_data" {

resource "libvirt_domain" "service-vm" {
count = var.instance_count
autostart = var.instance_autostart
name = var.instance_count > 1 ? "${var.instance_hostname}-${count.index}" : var.instance_hostname
memory = var.instance_memory*1024
vcpu = var.instance_cpu
Expand Down
6 changes: 6 additions & 0 deletions modules/terraform-libvirt-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ variable "instance_count" {
description = "Number of instances to create"
}

variable "instance_autostart" {
type = bool
description = "Flag to configure autostart for the instance"
default = true
}

variable "instance_cloud_image" {
type = string
description = "Cloud image to use for instance provisioning"
Expand Down

0 comments on commit 2ccbc3d

Please sign in to comment.