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
/
Copy pathbluedata_infra_main.tf
67 lines (57 loc) · 1.72 KB
/
bluedata_infra_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
provider "vsphere" {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = var.vsphere_server
# If you have a self-signed cert
allow_unverified_ssl = true
}
data "template_file" "cli_logging_config_template" {
template = file("etc/hpecp_cli_logging.conf")
vars = {
hpecp_cli_log_file = "${abspath(path.module)}/generated/hpecp_cli.log"
}
}
resource "local_file" "cli_logging_config_file" {
filename = "${path.module}/generated/hpecp_cli_logging.conf"
content = data.template_file.cli_logging_config_template.rendered
}
resource "local_file" "ca-cert" {
filename = "${path.module}/generated/ca-cert.pem"
content = var.ca_cert
}
resource "local_file" "ca-key" {
filename = "${path.module}/generated/ca-key.pem"
content = var.ca_key
}
# Vsphere resources
data "vsphere_datacenter" "dc" {
name = var.vsphere_datacenter
}
data "vsphere_datastore" "datastore" {
name = var.vsphere_datastore
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_resource_pool" "pool" {
name = var.vsphere_resourcepool
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "network" {
name = var.vsphere_network
datacenter_id = data.vsphere_datacenter.dc.id
}
# Password generator
resource "random_password" "rdp_admin_password" {
length = 16
special = true
override_special = "_%@"
}
data "vsphere_virtual_machine" "template" {
name = "CentOS7-Template"
datacenter_id = data.vsphere_datacenter.dc.id
}
resource "vsphere_virtual_machine" "rdp_server" {
count = var.rdp_server_enabled ? 1 : 0
name = "dummy-resource"
resource_pool_id = data.vsphere_resource_pool.pool.id
datacenter_id = data.vsphere_datacenter.dc.id
}