forked from SUSE/ha-sap-terraform-deployments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsalt_provisioner.tf
53 lines (49 loc) · 1.74 KB
/
salt_provisioner.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
# This file contains the salt provisioning logic.
# It will be executed if 'provisioner' is set to 'salt' (default option) and the
# libvirt_domain.domain (drbd_node) resources are created (check triggers option).
resource "null_resource" "drbd_node_provisioner" {
count = var.common_variables["provisioner"] == "salt" ? var.drbd_count : 0
triggers = {
drbd_ids = libvirt_domain.drbd_domain[count.index].id
}
connection {
host = libvirt_domain.drbd_domain[count.index].network_interface.0.addresses.0
user = "root"
password = "linux"
}
provisioner "file" {
content = <<EOF
role: drbd_node
${var.common_variables["grains_output"]}
name_prefix: ${var.name}
hostname: ${var.name}0${count.index + 1}
network_domain: ${var.network_domain}
timezone: ${var.timezone}
host_ips: [${join(", ", formatlist("'%s'", var.host_ips))}]
host_ip: ${element(var.host_ips, count.index)}
drbd_cluster_vip: ${var.drbd_cluster_vip}
drbd_disk_device: /dev/vdb
fencing_mechanism: ${var.fencing_mechanism}
sbd_storage_type: ${var.sbd_storage_type}
sbd_disk_device: "${var.sbd_storage_type == "shared-disk" ? "/dev/vdc" : ""}"
sbd_lun_index: 2
iscsi_srv_ip: ${var.iscsi_srv_ip}
nfs_mounting_point: ${var.nfs_mounting_point}
nfs_export_name: ${var.nfs_export_name}
partitions:
1:
start: 0%
end: 100%
EOF
destination = "/tmp/grains"
}
}
module "drbd_provision" {
source = "../../../generic_modules/salt_provisioner"
node_count = var.common_variables["provisioner"] == "salt" ? var.drbd_count : 0
instance_ids = null_resource.drbd_node_provisioner.*.id
user = "root"
password = "linux"
public_ips = libvirt_domain.drbd_domain.*.network_interface.0.addresses.0
background = var.common_variables["background"]
}