-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
68 lines (59 loc) · 1.6 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
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
}
}
provider "libvirt" {
uri = "qemu:///system"
}
#provider "libvirt" {
# alias = "server2"
# uri = "qemu+ssh://[email protected]/system"
#}
resource "libvirt_volume" "os_volume" {
count = length(var.hostname) # нужно что бы знал количество элементов в массиве
name = "${var.hostname[count.index]}.qcow2"
pool = "default"
#source = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
source = "/var/lib/libvirt/images/terra-centos7.qcow2"
format = "qcow2"
}
#resource "libvirt_volume" "k3m1_data_volume" {
# name = "k3m1_data_volume"
# // 25 * 1024 * 1024 * 1024
# size = 26843545600
#}
# Define KVM domain to create
resource "libvirt_domain" "vm_domain" {
count = length(var.hostname) # нужно что бы знал количество элементов в массиве
name = "${var.hostname[count.index]}"
memory = "${var.ram[count.index]}"
vcpu = "${var.vcpu[count.index]}"
qemu_agent = true
network_interface {
network_name = "default"
hostname = "${var.hostname[count.index]}"
addresses = ["${var.ip[count.index]}"]
mac = "${var.mac[count.index]}"
}
disk {
#count = length(var.hostname)
volume_id = libvirt_volume.os_volume[count.index].id
}
# disk {
# volume_id = "${libvirt_volume.k3m1_data_volume.id}"
# }
#
console {
type = "pty"
target_type = "serial"
target_port = "0"
}
graphics {
type = "vnc"
listen_type = "address"
autoport = true
}
}