From de66a0740c6b1a9ba586f9dc9d7788de8b28d71f Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Wed, 21 Aug 2019 10:31:55 -0500 Subject: [PATCH 01/10] Update submodule Point to diedpigs/CRI_XCBC on branch feat-update-private-ip --- .gitmodules | 4 ++-- CRI_XCBC | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index b7f611a..73575c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "CRI_XCBC"] path = CRI_XCBC - url = https://github.com/jprorama/CRI_XCBC.git - branch = feat-openstack + url = https://github.com/diedpigs/CRI_XCBC.git + branch = feat-update-private-ip diff --git a/CRI_XCBC b/CRI_XCBC index 1d7a787..15759e9 160000 --- a/CRI_XCBC +++ b/CRI_XCBC @@ -1 +1 @@ -Subproject commit 1d7a787a562130d8b96d1b85d087c4a3ecc34f41 +Subproject commit 15759e94ac0d65451bd9b9215da5b1f1c6f6a613 -- GitLab From 0f464fe85ddbcb37dc3d173446a0100bca9b9ed9 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Tue, 27 Aug 2019 16:15:24 -0500 Subject: [PATCH 02/10] Change compute source name c0 to compute --- nodes/main.tf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nodes/main.tf b/nodes/main.tf index 5fdb441..2c0b00d 100644 --- a/nodes/main.tf +++ b/nodes/main.tf @@ -10,10 +10,8 @@ variable "key_pair" {type = "string"} variable "compute_node_count" { } variable "internal_network" {} - - # creates compute node -resource "openstack_compute_instance_v2" "c0" { +resource "openstack_compute_instance_v2" "compute" { depends_on = [var.internal_subnet_id] name = "c${count.index}" image_name = var.image_compute -- GitLab From 10ecec7e6328298f3b7bb511880fbd3c9af80888 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 03/10] 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 From 3bed2fcf9165e7b36a73790f753ebf96cc850861 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Wed, 28 Aug 2019 12:47:47 -0500 Subject: [PATCH 04/10] Export compute node ids Accessible by calling module.nodes.id will return a list of compute node id Mainly using for null-resource trigger --- nodes/main.tf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nodes/main.tf b/nodes/main.tf index cd92682..f689eac 100644 --- a/nodes/main.tf +++ b/nodes/main.tf @@ -32,4 +32,9 @@ resource "openstack_compute_instance_v2" "compute" { network { name = var.internal_network } -} \ No newline at end of file +} + +# output +output "id" { + value = openstack_compute_instance_v2.compute.*.id +} -- GitLab From 67e54aeb25adff9e51bfb0fa3e574d01b7beec7b Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Wed, 28 Aug 2019 12:50:14 -0500 Subject: [PATCH 05/10] Export compute node network Accessible by calling module.nodes.network will return a map which key is node name and its network info --- nodes/main.tf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nodes/main.tf b/nodes/main.tf index f689eac..f0cfef1 100644 --- a/nodes/main.tf +++ b/nodes/main.tf @@ -38,3 +38,7 @@ resource "openstack_compute_instance_v2" "compute" { output "id" { value = openstack_compute_instance_v2.compute.*.id } + +output "network" { + value = zipmap(openstack_compute_instance_v2.compute.*.name, openstack_compute_instance_v2.compute.*.network) +} -- GitLab From 40202aea2c95316930493e164a384194ae376eff Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Wed, 28 Aug 2019 13:03:15 -0500 Subject: [PATCH 06/10] Export ohpc instance id Accessible by calling module.create-ohpc-instance.id will return a string --- ohpc-instance/main.tf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ohpc-instance/main.tf b/ohpc-instance/main.tf index 927a5e4..746a7e5 100644 --- a/ohpc-instance/main.tf +++ b/ohpc-instance/main.tf @@ -52,6 +52,10 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" { } } +output "id" { + value = openstack_compute_instance_v2.ohpc.id +} + output "ssh_host" { value = format(var.host_prefix,element(split(".", var.floating_ip_ohpc),3,),) -} \ No newline at end of file +} -- GitLab From ba6e56a6702f0509ea7c71c5865e6eb7aa8b5b91 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 07/10] 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 From f0911acf5c6585b2e0cbf6d74a47a555b458b0a8 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Thu, 29 Aug 2019 10:18:32 -0500 Subject: [PATCH 08/10] Update compute image name in vars.tf --- vars.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vars.tf b/vars.tf index 00bbcd1..b8a8633 100644 --- a/vars.tf +++ b/vars.tf @@ -27,7 +27,6 @@ variable "ohpc_user" {default = "centos"} variable "ood_user" {default = "centos"} variable "ssh_private_key" {default = "~/.ssh/id_rsa"} - # variables for node creation module -variable "image_compute" {default = "CentOS-7-x86_64-GenericCloud-1905"} +variable "image_compute" {default = "compute-v3"} variable "compute_node_count" {default = 2} -- GitLab From 0def2d05d23d485ae5f55b8cedf7775f20a2e806 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Thu, 29 Aug 2019 10:34:31 -0500 Subject: [PATCH 09/10] Add image data source in nodes module To avoid error when there's two images with same name use data source to get the latest image to boot up compute nodes --- nodes/main.tf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nodes/main.tf b/nodes/main.tf index f0cfef1..dfeeead 100644 --- a/nodes/main.tf +++ b/nodes/main.tf @@ -10,11 +10,16 @@ variable "key_pair" {type = "string"} variable "compute_node_count" { } variable "internal_network" {} +data "openstack_images_image_v2" "compute" { + name = var.image_compute + most_recent = true +} + # creates compute node resource "openstack_compute_instance_v2" "compute" { depends_on = [var.internal_subnet_id] name = "c${count.index}" - image_name = var.image_compute + image_id = data.openstack_images_image_v2.compute.id flavor_name = var.flavor key_pair = var.key_pair security_groups = ["default"] @@ -39,6 +44,10 @@ output "id" { value = openstack_compute_instance_v2.compute.*.id } +output "image_id" { + value = data.openstack_images_image_v2.compute.id +} + output "network" { value = zipmap(openstack_compute_instance_v2.compute.*.name, openstack_compute_instance_v2.compute.*.network) } -- GitLab From 8c4cf5b997196471a2e3e07f004d0ab0ff154ad4 Mon Sep 17 00:00:00 2001 From: Bo-Chun Louis Chen <louistw@uab.edu> Date: Fri, 30 Aug 2019 10:27:17 -0500 Subject: [PATCH 10/10] Update submodule commit --- .gitmodules | 4 ++-- CRI_XCBC | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 73575c9..a81cbf7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "CRI_XCBC"] path = CRI_XCBC - url = https://github.com/diedpigs/CRI_XCBC.git - branch = feat-update-private-ip + url = https://github.com/eesaanatluri/CRI_XCBC.git + branch = feat-separate-ohpc-tasks-image-build diff --git a/CRI_XCBC b/CRI_XCBC index 15759e9..076efcc 160000 --- a/CRI_XCBC +++ b/CRI_XCBC @@ -1 +1 @@ -Subproject commit 15759e94ac0d65451bd9b9215da5b1f1c6f6a613 +Subproject commit 076efccd8a19adedbefd1f21f50ed7c753f43842 -- GitLab