diff --git a/main.tf b/main.tf index 3990c4b44d1a756a079ed08d9e922ed71c84b9e1..2031ad4572f62c66b0b5cacc4795d43639e8de6f 100644 --- a/main.tf +++ b/main.tf @@ -110,4 +110,26 @@ output "ohpc-ssh_host" { # calls the outputs defined in the ood-instance module output "ood-ssh_host" { value = "${module.create-ood-instance.ssh_host}" -} \ No newline at end of file +} + +# compute node post provision +resource "null_resource" "compute_ops" { + triggers = { + ohpc_instance = module.create-ohpc-instance.id + compute_instances = join(",", module.nodes.id) + } + + connection { + host = module.create-ohpc-instance.ssh_host + user = var.ohpc_user + private_key = file(var.ssh_private_key) + } + + # compute node + provisioner "remote-exec" { + inline = [ + for node, net in module.nodes.network: + "ansible-playbook -i /CRI_XCBC/hosts -l `hostname -s` -e \"{'node_name':'${node}', 'node_ip_v4':'${net[0].fixed_ip_v4}', 'node_mac':'${net[0].mac}'}\" /CRI_XCBC/site-ops.yaml -b -v" + ] + } +}