From d2a09faa897d1f3598c95ae08a591548ab1dd75b Mon Sep 17 00:00:00 2001
From: Krish Moodbidri <krish94@uab.edu>
Date: Fri, 30 Aug 2019 14:52:07 -0500
Subject: [PATCH] added user_data commands

---
 ood-instance/main.tf | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/ood-instance/main.tf b/ood-instance/main.tf
index 7d0d599..6c03920 100644
--- a/ood-instance/main.tf
+++ b/ood-instance/main.tf
@@ -28,6 +28,14 @@ resource "openstack_compute_instance_v2" "ood" {
   flavor_name     = var.flavor
   key_pair        = var.key_pair
   security_groups = ["default"]
+  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" ]
+    EOF
+
 
 # defines the networks of the instance
   network {
@@ -53,7 +61,12 @@ resource "openstack_compute_floatingip_associate_v2" "ood" {
 }
 
 
-
+output "id" {
+    value = openstack_compute_instance_v2.ood.id
+}
 output "ssh_host"{
     value = format(var.host_prefix,element(split(".", var.floating_ip_ood),3,),)
-}
\ No newline at end of file
+}
+output "network" {
+    value = openstack_compute_instance_v2.ood.network
+}
-- 
GitLab