-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisks.tf
More file actions
50 lines (45 loc) · 1.36 KB
/
disks.tf
File metadata and controls
50 lines (45 loc) · 1.36 KB
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
resource "libvirt_pool" "default" {
name = "${var.node_pool_vm_name}"
type = "dir"
path = var.libvirt_pool_path
}
# for more info about paramater check this out
# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/cloudinit.html.markdown
# Use CloudInit to add our ssh-key to the instance
# you can add also meta_data field
resource "libvirt_cloudinit_disk" "commoninit" {
name = "commoninit.iso"
pool = libvirt_pool.default.name
user_data = <<EOF
#cloud-config
disable_root: 0
ssh_pwauth: 1
users:
- name: root
ssh-authorized-keys:
- ${file(var.ssh_pub_key_path)}
growpart:
mode: auto
devices: ['/']
EOF
network_config = <<EOF
version: 2
ethernets:
ens3:
dhcp4: true
EOF
}
# We fetch the latest ubuntu release image from their mirrors
resource "libvirt_volume" "base" {
name = "terraform-libvirt_volume-${var.node_pool_vm_name}-base"
pool = libvirt_pool.default.name
source = var.node_pool_vm_image_url
format = "qcow2"
}
resource "libvirt_volume" "resized" {
count = var.node_pool_size
name = "terraform-libvirt_volume-${var.node_pool_vm_name}-${count.index}"
base_volume_id = libvirt_volume.base.id
pool = libvirt_pool.default.name
size = var.node_pool_vm_volume_size
}