This commit is contained in:
Philippe Caseiro 2023-02-27 14:14:10 +01:00
commit e2e930045c
2 changed files with 16 additions and 9 deletions

View File

@ -1,3 +1,9 @@
# terracadoles # terracadoles
Cadoles Terraform modules Cadoles Terraform modules
## Modules
* virtualMachine
* dns
* nebula

View File

@ -3,10 +3,6 @@ variable "vms" {
description = "Virtual Machines description" description = "Virtual Machines description"
} }
variable "image_driver" {
default = "qcow2"
}
variable "image_format" { variable "image_format" {
default = "qcow2" default = "qcow2"
} }
@ -32,6 +28,11 @@ variable "one_prod_ds" {
default = "101" default = "101"
} }
variable "one_sys_datastore" {
default = "100"
}
// system image // system image
resource "opennebula_image" "system" { resource "opennebula_image" "system" {
for_each = var.vms for_each = var.vms
@ -41,7 +42,6 @@ resource "opennebula_image" "system" {
datastore_id = var.one_prod_ds datastore_id = var.one_prod_ds
path = "https://vulcain.cadoles.com/empty_20G" path = "https://vulcain.cadoles.com/empty_20G"
persistent = each.value.system_image_persistent persistent = each.value.system_image_persistent
driver = var.image_driver
format = var.image_format format = var.image_format
dev_prefix = var.dev_prefix dev_prefix = var.dev_prefix
permissions = var.permissions permissions = var.permissions
@ -56,7 +56,6 @@ resource "opennebula_image" "data" {
datastore_id = var.one_prod_ds datastore_id = var.one_prod_ds
description = "data disk for ${each.key}" description = "data disk for ${each.key}"
persistent = each.value.data_image_persistent persistent = each.value.data_image_persistent
driver = var.image_driver
format = var.image_format format = var.image_format
dev_prefix = var.dev_prefix dev_prefix = var.dev_prefix
permissions = var.permissions permissions = var.permissions
@ -65,7 +64,7 @@ resource "opennebula_image" "data" {
resource "opennebula_template" "vm_template" { resource "opennebula_template" "vm_template" {
for_each = var.vms for_each = var.vms
name = each.key name = "${each.key}.${each.value.domain}"
cpu = each.value.cpu cpu = each.value.cpu
vcpu = each.value.vcpu vcpu = each.value.vcpu
memory = each.value.ram memory = each.value.ram
@ -91,6 +90,8 @@ resource "opennebula_template" "vm_template" {
} }
*/ */
sched_ds_requirements = ( each.value.sysdatastore != "" ? each.value.sysdatastore : var.one_sys_datastore )
os { os {
arch = "x86_64" arch = "x86_64"
boot = "disk0,nic0" boot = "disk0,nic0"
@ -103,7 +104,7 @@ resource "opennebula_template" "vm_template" {
content { content {
network_id = nic.value.network_id network_id = nic.value.network_id
model = "virtio" model = "virtio"
ip = nic.value.ip mac = nic.value.mac
} }
} }
permissions = var.permissions permissions = var.permissions