-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
89 lines (74 loc) · 2.7 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
terraform {
required_providers {
proxmox = {
source = "Telmate/proxmox"
}
}
}
locals {
combined_tags = concat(var.tags, ["kubernetes", "cluster", var.cluster_name])
}
module "master" {
source = "gitlab.com/devops9483002/proxmox-virtual-machine/proxmox"
version = "0.4.0"
count = length(var.master_mapping)
# General settings
name = "${var.cluster_name}-master-${count.index + 1}"
description = var.master_description
target_node = var.master_mapping[count.index].node
qemu_agent = var.qemu_agent
template_name = var.master_vm_template
tags = count.index == 0 ? concat(local.combined_tags, ["controlplane", "controlplane-master"]) : concat(local.combined_tags, ["controlplane", "controlplane-slave"])
# Network settings
ipconfig0_ip = var.master_mapping[count.index].ipconfig0_ip
ipconfig0_cidr = var.ipconfig0_cidr
ipconfig0_gw = var.ipconfig0_gw
nameserver = var.nameserver
# Cloud-init settings
os_type = var.os_type
cloudinit_user = var.cloudinit_user
cloudinit_password = var.cloudinit_password
cloudinit_sshkey = var.cloudinit_sshkey
cloudinit_cdrom = var.cloudinit_cdrom
# Hardware settings
sockets = var.master_sockets
cores = var.master_cores
memory = var.master_memory
disk_size = var.master_disk_size
storage_name = var.master_mapping[count.index].storage_name
# High Availability settings
hastate = var.hastate
hagroup = var.master_mapping[count.index].hagroup
}
module "worker" {
source = "gitlab.com/devops9483002/proxmox-virtual-machine/proxmox"
version = "0.4.0"
count = length(var.worker_mapping)
# General settings
name = "${var.cluster_name}-worker-${count.index + 1}"
description = var.worker_description
target_node = var.worker_mapping[count.index].node
qemu_agent = var.qemu_agent
template_name = var.worker_vm_template
tags = concat(local.combined_tags, ["worker"])
# Network settings
ipconfig0_ip = var.worker_mapping[count.index].ipconfig0_ip
ipconfig0_cidr = var.ipconfig0_cidr
ipconfig0_gw = var.ipconfig0_gw
nameserver = var.nameserver
# Cloud-init settings
os_type = var.os_type
cloudinit_user = var.cloudinit_user
cloudinit_password = var.cloudinit_password
cloudinit_sshkey = var.cloudinit_sshkey
cloudinit_cdrom = var.cloudinit_cdrom
# Hardware settings
sockets = var.worker_sockets
cores = var.worker_cores
memory = var.worker_memory
disk_size = var.worker_disk_size
storage_name = var.worker_mapping[count.index].storage_name
# High Availability settings
hastate = var.hastate
hagroup = var.worker_mapping[count.index].hagroup
}