From 72ff347d5cff541d4a9b70890f728b90f036aa60 Mon Sep 17 00:00:00 2001
From: Bo-Chun Louis Chen <louistw@uab.edu>
Date: Wed, 28 Aug 2019 13:24:17 -0500
Subject: [PATCH] Add compute-ops null-resource

Changing ohpc id and compute node id will trigger it
Will run node registration on ohpc node.
---
 main.tf | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/main.tf b/main.tf
index 3990c4b..2031ad4 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"
+    ]
+  }
+}
-- 
GitLab