From f9fdd9b49f2ecd2a41691a3422d8a5f857f4a1be Mon Sep 17 00:00:00 2001
From: Bo-Chun Louis Chen <louistw@uab.edu>
Date: Wed, 28 Aug 2019 12:44:56 -0500
Subject: [PATCH] Add user data in compute node provision

Modify warewulf config file with compute node info
---
 nodes/main.tf | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/nodes/main.tf b/nodes/main.tf
index 2c0b00d..cd92682 100644
--- a/nodes/main.tf
+++ b/nodes/main.tf
@@ -19,6 +19,14 @@ resource "openstack_compute_instance_v2" "compute" {
   key_pair        = var.key_pair
   security_groups = ["default"]
   count           = var.compute_node_count
+  user_data =  <<-EOF
+    #cloud-config
+    runcmd:
+     - [ bash, -xc, 'ethernet=$(cat /sys/class/net/eth0/address); nodename=$(hostname -s); sed -e "s/MY_HWADDR/$ethernet/" -e "s/MY_NODENAME/$nodename/" -i /warewulf/config;' ]
+     - [ bash, -xc, "echo $(date) ': hello world!'; until WWGETFILES_INTERVAL=0 bash -x /warewulf/bin/wwgetfiles; do echo waiting ; rm -f /tmp/.wwgetfile.lock ; sleep 10; done;" ]
+     - [ bash, -xc, "systemctl restart munge" ]
+     - [ bash, -xc, "systemctl restart slurmd" ]
+    EOF
 
 # defines the networks of the instance
   network {
-- 
GitLab