-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
63 lines (52 loc) · 1.19 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
terraform {
required_providers {
opennebula = {
source = "OpenNebula/opennebula"
}
}
}
data "opennebula_group" "group" {
name = var.group_name
}
resource "opennebula_virtual_machine" "instance" {
count = var.num
name = "${var.name}-${count.index + 1}"
cpu = var.cpus
vcpu = var.vcpus
memory = var.memory
group = data.opennebula_group.group.name
permissions = "660"
context = {
SSH_PUBLIC_KEY = var.ssh_key
NETWORK = "YES"
SET_HOSTNAME = "$NAME"
TOKEN = "YES"
}
os {
arch = "x86_64"
boot = "disk0"
}
disk {
image_id = var.image_id
size = 20000
target = "vda"
}
on_disk_change = "RECREATE"
graphics {
type = "VNC"
listen = "0.0.0.0"
}
nic {
network_id = var.network_id
security_groups = var.security_groups
ip = var.ip
}
dynamic "nic"{
for_each = var.second_nic == true ? [{net_id=var.second_nic_net, net_sgs=var.second_nic_sgs}] : []
content {
network_id = nic.value["net_id"]
security_groups = nic.value["net_sgs"]
}
}
sched_requirements = "(ARCH = \"x86_64\") & (HYPERVISOR = \"kvm\")"
}