From 3218b98833f148a3ca1da1e7c7ba0c23fa709f05 Mon Sep 17 00:00:00 2001 From: Paul Bastide Date: Wed, 12 Jun 2024 20:41:42 -0400 Subject: [PATCH] OPENSHIFTP-124: Remove data.http.bastion_ip_retrieval logic and the http server creation Signed-off-by: Paul Bastide --- modules/5_worker/worker.tf | 106 +------------------------------------ 1 file changed, 1 insertion(+), 105 deletions(-) diff --git a/modules/5_worker/worker.tf b/modules/5_worker/worker.tf index a7d4fac..f0c79e9 100644 --- a/modules/5_worker/worker.tf +++ b/modules/5_worker/worker.tf @@ -54,112 +54,8 @@ locals { bastion_private_ip = [for lease in data.ibm_pi_dhcp.refresh_dhcp_server[0].leases : lease if lease.instance_mac == data.ibm_pi_instance.bastion_instance.networks[0].macaddress] } -# Dev Note: the hypervisor does not report the internal interfaces ip correctly -# This resource works around that problem through a temporary setup of an http -resource "null_resource" "secondary_retrieval_ignition_ip" { - count = var.cicd ? 1 : 0 - depends_on = [null_resource.nop] - - connection { - type = "ssh" - user = "root" - private_key = file(var.private_key_file) - host = var.bastion_public_ip - agent = var.ssh_agent - } - - provisioner "remote-exec" { - inline = [< /etc/httpd/conf.d/extra.conf -Listen $(ip -j -4 -o address | jq -r '.[].addr_info[] | select(.dev == "env2").local'):443 - - ServerName cicd - ServerAdmin cicd@localhost - DocumentRoot /var/www/vhosts/1/ - - AllowOverride None - - ErrorLog /var/log/apache2-error.log - -EOFX -mkdir -p /var/www/vhosts/1 -systemctl restart httpd - -os_ver=$(cat /etc/os-release | egrep "^VERSION_ID=" | awk -F'"' '{print $2}') -if [[ $os_ver != "9"* ]] -then - # RHEL8 - IFACES=$(nmcli device show 2>&1| grep GENERAL.DEVICE | grep -v env2 | grep -v lo | awk '{print $NF}') -else - # RHEL9 - IFACES=$(nmcli device show 2>&1| grep GENERAL.DEVICE | grep -v eth1 | grep -v lo | awk '{print $NF}') -fi - -for IFACE in $(echo $${IFACES}) -do - IP_ADDR="$(nmcli device show $${IFACE} 2>&1 | grep IP4.ADDRESS | sed 's|/24||g' | awk '{print $NF}')" - if [ -n "$${IP_ADDR}" ] - then - echo "Interface: $${IFACE} $${IP_ADDR}" - echo "$${IP_ADDR}" > /var/www/vhosts/1/ip - echo "$${IP_ADDR}" > /var/www/vhosts/1/index.html - chmod -R 777 /var/www/vhosts/1/ - fi -done -chown -R nobody:nobody /var/www/vhosts -firewall-cmd --permanent --zone=public --add-service=https -firewall-cmd --reload -EOF - ] - } -} - -data "http" "bastion_ip_retrieval" { - count = var.cicd ? 1 : 0 - depends_on = [null_resource.secondary_retrieval_ignition_ip] - url = "http://${var.bastion_public_ip}:443/ip" -} - -# Dev Note: at the end the https port shouldn't be active/listening -# resource "null_resource" "secondary_retrieval_shutdown" { -# count = var.cicd ? 1 : 0 -# depends_on = [null_resource.nop, data.http.bastion_ip_retrieval, null_resource.secondary_retrieval_ignition_ip] -# -# triggers = { -# private_key = sensitive(file(var.private_key_file)) -# host = var.bastion_public_ip -# agent = var.ssh_agent -# } -# -# connection { -# type = "ssh" -# user = "root" -# private_key = self.triggers.private_key -# host = self.triggers.host -# agent = self.triggers.agent -# } -# -# provisioner "remote-exec" { -# inline = [< /etc/httpd/conf.d/extra.conf -# systemctl restart httpd -# EOF -# ] -# } -# } - locals { - ignition_ip = length(var.ignition_ip) > 0 ? var.ignition_ip[0].instance_ip : length(local.bastion_private_ip) > 0 ? local.bastion_private_ip[0].instance_ip : chomp(data.http.bastion_ip_retrieval[0].response_body) + ignition_ip = length(var.ignition_ip) > 0 ? var.ignition_ip[0].instance_ip : length(local.bastion_private_ip) > 0 ? local.bastion_private_ip[0].instance_ip : "bad-ip" } # Modeled off the OpenShift Installer work for IPI PowerVS