This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bluedata_infra_ad-server.tf
64 lines (64 loc) · 2.26 KB
/
bluedata_infra_ad-server.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
# AD VM
resource "vsphere_virtual_machine" "ad_server" {
name = "${var.project_id}-ad"
count = var.ad_server_enabled ? 1 : 0
resource_pool_id = data.vsphere_resource_pool.pool.id
datastore_id = data.vsphere_datastore.datastore.id
num_cpus = var.ad_instance_cpu
memory = var.ad_instance_memory
guest_id = data.vsphere_virtual_machine.template.guest_id
scsi_type = data.vsphere_virtual_machine.template.scsi_type
network_interface {
network_id = data.vsphere_network.network.id
}
disk {
label = "${var.project_id}-ad-os-disk"
size = "400"
thin_provisioned = true
}
# clone from template
clone {
template_uuid = data.vsphere_virtual_machine.template.id
customize {
linux_options {
host_name = "${var.project_id}-ad"
domain = var.domain
time_zone = var.timezone
}
network_interface { } // use dhcp
}
}
provisioner "file" {
source = "${var.downstream_repo_dir}/modules/module-ad-server/files/"
destination = "/home/centos"
connection {
host = self.default_ip_address
user = var.user
private_key = file(var.ssh_prv_key_path)
}
}
provisioner "remote-exec" {
inline = [
"sudo yum install -y -q cloud-utils-growpart",
"sudo growpart /dev/sda 2",
"sudo xfs_growfs /",
"sudo yum update -y -q",
"sudo yum install -y -q docker openldap-clients",
"set -ex",
"sudo systemctl enable --now docker",
"sed -i s/AD_ADMIN_GROUP/${var.ad_admin_group}/g /home/centos/ad_user_setup.sh",
"sed -i s/AD_MEMBER_GROUP/${var.ad_member_group}/g /home/centos/ad_user_setup.sh",
"sed -i s/AD_ADMIN_GROUP/${var.ad_admin_group}/g /home/centos/ad_set_posix_classes.ldif",
"sed -i s/AD_MEMBER_GROUP/${var.ad_member_group}/g /home/centos/ad_set_posix_classes.ldif",
"while [ ! -f /home/centos/run_ad.sh ]; do sleep 2; done",
"/bin/bash /home/centos/run_ad.sh",
"sleep 120",
"/bin/bash /home/centos/ldif_modify.sh"
]
connection {
host = self.default_ip_address
user = var.user
private_key = file(var.ssh_prv_key_path)
}
}
}