-
Notifications
You must be signed in to change notification settings - Fork 0
/
dra_assocoation.tf
37 lines (32 loc) · 1.65 KB
/
dra_assocoation.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
locals {
# we are using one password for all services and we have one DRA only
admin_password = var.dra_details == null ? "" : urlencode(var.dra_details.password)
archiver_username = var.dra_details == null ? "" : var.dra_details.archiver_username
archiver_password = var.dra_details == null ? "" : urlencode(var.dra_details.archiver_password)
admin_address = var.dra_details == null ? "" : var.dra_details.address
dra_association_commands = var.dra_details == null ? "" : <<-EOF
curl -k --max-time 10000 -X POST -G 'https://127.0.0.1:8443/register-to-dra' -d adminIpOrHostname=${local.admin_address} -d adminRegistrationPassword=${local.admin_password} -d adminReportingServer=true -d analyticsArchiveUsername=${local.archiver_username} -d analyticsArchivePassword=${local.archiver_password} -d resumeDraJobs=true --header "Authorization: Bearer ${module.hub_instance.access_tokens["archiver"].token}"
EOF
}
resource "null_resource" "dra_association" {
count = var.dra_details != null ? 1 : 0
connection {
type = "ssh"
user = module.hub_instance.ssh_user
private_key = file(var.ssh_key_pair.ssh_private_key_file_path)
host = var.use_public_ip ? module.hub_instance.public_ip : module.hub_instance.private_ip
bastion_host = local.bastion_host
bastion_private_key = local.bastion_private_key
bastion_user = local.bastion_user
script_path = local.script_path
}
provisioner "remote-exec" {
inline = concat([local.dra_association_commands])
}
depends_on = [
module.hub_instance.ready
]
triggers = {
key = local.dra_association_commands
}
}