From 85f56b3b55f6f76e140d9d7b985203ec726a9aee Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 21 Oct 2025 13:11:58 +0530 Subject: [PATCH 01/34] waypoint test --- solutions/quickstart/main.tf | 3 ++- solutions/quickstart/variables.tf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 2a2c891a3..12a22a834 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -131,7 +131,8 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - source = "../.." + source = "terraform-ibm-modules/base-ocp-vpc/ibm" + version = "3.66.0" cluster_name = local.cluster_name resource_group_id = module.resource_group.resource_group_id region = var.region diff --git a/solutions/quickstart/variables.tf b/solutions/quickstart/variables.tf index cc4dfd243..d2e179d1c 100644 --- a/solutions/quickstart/variables.tf +++ b/solutions/quickstart/variables.tf @@ -14,7 +14,7 @@ variable "existing_resource_group_name" { variable "provider_visibility" { description = "Set the visibility value for the IBM terraform provider. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints)." type = string - default = "private" + default = "public" validation { condition = contains(["public", "private", "public-and-private"], var.provider_visibility) From 009ade40ef67499991b3e71b5425edd2eee45913 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 21 Oct 2025 14:36:51 +0530 Subject: [PATCH 02/34] test --- solutions/quickstart/main.tf | 1 + 1 file changed, 1 insertion(+) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 12a22a834..6ff1a7bfb 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -145,4 +145,5 @@ module "ocp_base" { access_tags = var.access_tags disable_public_endpoint = !var.allow_public_access_to_cluster_management cluster_config_endpoint_type = "default" + verify_worker_network_readiness = false } From 5fc3b714df447243fcbf23c79903c6beab93f711 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 10:29:41 +0530 Subject: [PATCH 03/34] test --- solutions/quickstart/main.tf | 14 +++- solutions/quickstart/scripts/install_tools.sh | 77 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 solutions/quickstart/scripts/install_tools.sh diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 5d685e2ef..55371d613 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,7 +1,19 @@ +resource "null_resource" "install_tools" { + provisioner "local-exec" { + command = "${path.module}/scripts/install_tools.sh" + interpreter = ["/bin/bash", "-c"] + } + + triggers = { + always_run = timestamp() + } +} + ####################################################################################################################### # Resource Group ####################################################################################################################### module "resource_group" { + depends_on = [null_resource.install_tools] source = "terraform-ibm-modules/resource-group/ibm" version = "1.4.0" existing_resource_group_name = var.existing_resource_group_name @@ -132,7 +144,7 @@ locals { ######################################################################################################################## module "ocp_base" { source = "terraform-ibm-modules/base-ocp-vpc/ibm" - version = "3.66.0" + version = "3.71.3" cluster_name = local.cluster_name resource_group_id = module.resource_group.resource_group_id region = var.region diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh new file mode 100644 index 000000000..edcf5957b --- /dev/null +++ b/solutions/quickstart/scripts/install_tools.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +set -euo pipefail + +echo "🔍 Checking and installing required CLI tools..." + +# --- Function to install jq --- +install_jq() { + echo "Installing jq..." + if command -v apt-get >/dev/null 2>&1; then + sudo apt-get update -y + sudo apt-get install -y jq + elif command -v yum >/dev/null 2>&1; then + sudo yum install -y jq + elif command -v dnf >/dev/null 2>&1; then + sudo dnf install -y jq + elif command -v brew >/dev/null 2>&1; then + brew install jq + else + echo "Error: No supported package manager found. Please install jq manually." + exit 1 + fi + echo "✅ jq installed successfully." +} + +# --- Check and install kubectl --- +if ! command -v kubectl >/dev/null 2>&1; then + echo "kubectl not found. Installing latest stable version..." + curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(uname | tr '[:upper:]' '[:lower:]')/amd64/kubectl" + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + echo "✅ kubectl installed successfully." +else + echo "✅ kubectl is already installed. Skipping installation." +fi + +# --- Check and install IBM Cloud CLI --- +if ! command -v ibmcloud >/dev/null 2>&1; then + echo "IBM Cloud CLI not found. Installing..." + curl -fsSL https://clis.cloud.ibm.com/install/linux | sh + echo "✅ IBM Cloud CLI installed successfully." +else + echo "✅ IBM Cloud CLI is already installed. Skipping installation." +fi + +# --- Ensure IBM Cloud Kubernetes Service CLI plugin --- +if ! ibmcloud plugin show container-service >/dev/null 2>&1; then + echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." + ibmcloud plugin install container-service -f + echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." +else + echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." +fi + +# --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- +if ! ibmcloud plugin show is >/dev/null 2>&1; then + echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." + ibmcloud plugin install is -f + echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." +else + echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." +fi + +# --- Check and install jq --- +if ! command -v jq >/dev/null 2>&1; then + install_jq +else + echo "✅ jq is already installed. Skipping installation." +fi + +echo "" +echo "🎉 All required CLI tools are installed:" +echo " - IBM Cloud CLI" +echo " - IBM Cloud Kubernetes Service CLI plugin" +echo " - IBM Cloud VPC Infrastructure Service CLI plugin" +echo " - kubectl" +echo " - jq" From 801fea009ffb346a6fc291d750cd523563d860b5 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 10:33:28 +0530 Subject: [PATCH 04/34] update permission --- solutions/quickstart/scripts/install_tools.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 solutions/quickstart/scripts/install_tools.sh diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh old mode 100644 new mode 100755 From a7090914f402265de9f6c4043cfcb92a219b2397 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 10:41:56 +0530 Subject: [PATCH 05/34] remove sudo --- solutions/quickstart/scripts/install_tools.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index edcf5957b..a7c1f297f 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -8,12 +8,12 @@ echo "🔍 Checking and installing required CLI tools..." install_jq() { echo "Installing jq..." if command -v apt-get >/dev/null 2>&1; then - sudo apt-get update -y - sudo apt-get install -y jq + apt-get update -y + apt-get install -y jq elif command -v yum >/dev/null 2>&1; then - sudo yum install -y jq + yum install -y jq elif command -v dnf >/dev/null 2>&1; then - sudo dnf install -y jq + dnf install -y jq elif command -v brew >/dev/null 2>&1; then brew install jq else @@ -28,7 +28,7 @@ if ! command -v kubectl >/dev/null 2>&1; then echo "kubectl not found. Installing latest stable version..." curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(uname | tr '[:upper:]' '[:lower:]')/amd64/kubectl" chmod +x ./kubectl - sudo mv ./kubectl /usr/local/bin/kubectl + mv ./kubectl /usr/local/bin/kubectl echo "✅ kubectl installed successfully." else echo "✅ kubectl is already installed. Skipping installation." From b13699063f6b55bb7c0eec45163b21478b129199 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 10:58:12 +0530 Subject: [PATCH 06/34] test --- solutions/quickstart/main.tf | 2 +- solutions/quickstart/scripts/install_tools.sh | 61 +++++++++++-------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 55371d613..02f099f19 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,6 +1,6 @@ resource "null_resource" "install_tools" { provisioner "local-exec" { - command = "${path.module}/scripts/install_tools.sh" + command = "${path.module}/scripts/install_tools.sh && source ~/.bashrc" interpreter = ["/bin/bash", "-c"] } diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index a7c1f297f..1e9b4e48a 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -2,43 +2,55 @@ set -euo pipefail -echo "🔍 Checking and installing required CLI tools..." +echo "🔍 Checking and installing required CLI tools (user-level, no sudo)..." + +# --- Setup local bin directory --- +LOCAL_BIN="$HOME/bin" +mkdir -p "$LOCAL_BIN" +export PATH="$LOCAL_BIN:$PATH" + +# --- Helper to add PATH persistently --- +if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then + echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$HOME/.bashrc" + echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" +fi # --- Function to install jq --- install_jq() { - echo "Installing jq..." - if command -v apt-get >/dev/null 2>&1; then - apt-get update -y - apt-get install -y jq - elif command -v yum >/dev/null 2>&1; then - yum install -y jq - elif command -v dnf >/dev/null 2>&1; then - dnf install -y jq - elif command -v brew >/dev/null 2>&1; then - brew install jq - else - echo "Error: No supported package manager found. Please install jq manually." - exit 1 - fi - echo "✅ jq installed successfully." + echo "Installing jq (locally)..." + JQ_VERSION="1.7" + ARCH=$(uname -m) + OS=$(uname | tr '[:upper:]' '[:lower:]') + + case "$ARCH" in + x86_64) JQ_ARCH="jq-linux64" ;; + aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases + *) echo "Unsupported architecture: $ARCH"; exit 1 ;; + esac + + curl -L -o "$LOCAL_BIN/jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" + chmod +x "$LOCAL_BIN/jq" + echo "✅ jq installed locally at $LOCAL_BIN/jq" } # --- Check and install kubectl --- if ! command -v kubectl >/dev/null 2>&1; then - echo "kubectl not found. Installing latest stable version..." - curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(uname | tr '[:upper:]' '[:lower:]')/amd64/kubectl" + echo "kubectl not found. Installing latest stable version locally..." + OS=$(uname | tr '[:upper:]' '[:lower:]') + KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) + curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" chmod +x ./kubectl - mv ./kubectl /usr/local/bin/kubectl - echo "✅ kubectl installed successfully." + mv ./kubectl "$LOCAL_BIN/kubectl" + echo "✅ kubectl installed locally at $LOCAL_BIN/kubectl" else echo "✅ kubectl is already installed. Skipping installation." fi # --- Check and install IBM Cloud CLI --- if ! command -v ibmcloud >/dev/null 2>&1; then - echo "IBM Cloud CLI not found. Installing..." - curl -fsSL https://clis.cloud.ibm.com/install/linux | sh - echo "✅ IBM Cloud CLI installed successfully." + echo "IBM Cloud CLI not found. Installing locally..." + curl -fsSL https://clis.cloud.ibm.com/install/linux | sh -s -- --install-location "$LOCAL_BIN" + echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" else echo "✅ IBM Cloud CLI is already installed. Skipping installation." fi @@ -69,9 +81,10 @@ else fi echo "" -echo "🎉 All required CLI tools are installed:" +echo "🎉 All required CLI tools are installed locally:" echo " - IBM Cloud CLI" echo " - IBM Cloud Kubernetes Service CLI plugin" echo " - IBM Cloud VPC Infrastructure Service CLI plugin" echo " - kubectl" echo " - jq" +echo "" From 1bae7eb82555ec1dfb07f96f615149ce60ca7e46 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 11:09:18 +0530 Subject: [PATCH 07/34] test2 --- solutions/quickstart/scripts/install_tools.sh | 106 +++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index 1e9b4e48a..3629e8a5f 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -15,6 +15,110 @@ if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" fi +install_ibm_cli() { +# Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) + +host="download.clis.cloud.ibm.com" +metadata_host="$host/ibm-cloud-cli-metadata" +binary_download_host="$host/ibm-cloud-cli" + +os_name=$(uname -s | tr '[:upper:]' '[:lower:]') +arch=$(uname -m | tr '[:upper:]' '[:lower:]') + +if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then + platform="linux64" +else + echo "This installer only supports Linux x86_64 (linux64). Quit installation." + exit 1 +fi + +# fetch version metadata of CLI +info_endpoint="https://$metadata_host/info.json" +info=$(curl -f -L -s "$info_endpoint") +status="$?" + +if [ $status -ne 0 ]; then + echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." + exit 1 +fi + +# parse latest version from metadata +latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') +if [ -z "$latest_version" ]; then + echo "Unable to parse latest version number. Quit installation." + exit 1 +fi + +# fetch all versions metadata of CLI +all_versions_endpoint="https://$metadata_host/all_versions.json" +all_versions=$(curl -f -L -s "$all_versions_endpoint") +status="$?" +if [ $status -ne 0 ]; then + echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." + exit 1 +fi + +# extract section of metadata for the desired version +metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') +if [ -z "$metadata_section" ]; then + echo "Unable to parse metadata for CLI version $latest_version. Quit installation." + exit 1 +fi + +# get platform-specific binary info +platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') + +# extract installer URL and checksum +installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') +sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') + +if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then + echo "Unable to parse installer URL or checksum. Quit installation." + exit 1 +fi + +file_name="IBM_Cloud_CLI.tar.gz" +tmp_dir="/tmp/ibmcloud_install" + +mkdir -p "$tmp_dir" +echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." + +if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then + echo "Download complete. Verifying integrity..." +else + echo "Download failed. Please check your network connection. Quit installation." + exit 1 +fi + +calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') +if [ "$sh1sum" != "$calculated_sha1sum" ]; then + echo "Downloaded file is corrupted (checksum mismatch). Quit installation." + rm -rf "$tmp_dir" + exit 1 +fi + +echo "Extracting package..." +tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 + +if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then + chmod 755 "${tmp_dir}/Bluemix_CLI/install" +fi + +echo "Running installer (no sudo)..." +"${tmp_dir}/Bluemix_CLI/install" -q +install_result=$? + +rm -rf "${tmp_dir}" + +if [ $install_result -eq 0 ]; then + echo "IBM Cloud CLI installation completed successfully." +else + echo "IBM Cloud CLI installation failed." + exit 1 +fi + +} + # --- Function to install jq --- install_jq() { echo "Installing jq (locally)..." @@ -49,7 +153,7 @@ fi # --- Check and install IBM Cloud CLI --- if ! command -v ibmcloud >/dev/null 2>&1; then echo "IBM Cloud CLI not found. Installing locally..." - curl -fsSL https://clis.cloud.ibm.com/install/linux | sh -s -- --install-location "$LOCAL_BIN" + install_ibm_cli echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" else echo "✅ IBM Cloud CLI is already installed. Skipping installation." From be1f89e61412c46cbea78ff77de0610bace696ba Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 11:17:00 +0530 Subject: [PATCH 08/34] test4 --- solutions/quickstart/scripts/install_tools.sh | 327 +++++++++--------- 1 file changed, 165 insertions(+), 162 deletions(-) diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index 3629e8a5f..1eb6d7d7c 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -11,184 +11,187 @@ export PATH="$LOCAL_BIN:$PATH" # --- Helper to add PATH persistently --- if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then - echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >> "$HOME/.bashrc" - echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" -fi - -install_ibm_cli() { -# Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) - -host="download.clis.cloud.ibm.com" -metadata_host="$host/ibm-cloud-cli-metadata" -binary_download_host="$host/ibm-cloud-cli" - -os_name=$(uname -s | tr '[:upper:]' '[:lower:]') -arch=$(uname -m | tr '[:upper:]' '[:lower:]') - -if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then - platform="linux64" -else - echo "This installer only supports Linux x86_64 (linux64). Quit installation." - exit 1 -fi - -# fetch version metadata of CLI -info_endpoint="https://$metadata_host/info.json" -info=$(curl -f -L -s "$info_endpoint") -status="$?" - -if [ $status -ne 0 ]; then - echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." - exit 1 -fi - -# parse latest version from metadata -latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') -if [ -z "$latest_version" ]; then - echo "Unable to parse latest version number. Quit installation." - exit 1 -fi - -# fetch all versions metadata of CLI -all_versions_endpoint="https://$metadata_host/all_versions.json" -all_versions=$(curl -f -L -s "$all_versions_endpoint") -status="$?" -if [ $status -ne 0 ]; then - echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." - exit 1 -fi - -# extract section of metadata for the desired version -metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') -if [ -z "$metadata_section" ]; then - echo "Unable to parse metadata for CLI version $latest_version. Quit installation." - exit 1 -fi - -# get platform-specific binary info -platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') - -# extract installer URL and checksum -installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') -sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') - -if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then - echo "Unable to parse installer URL or checksum. Quit installation." - exit 1 -fi - -file_name="IBM_Cloud_CLI.tar.gz" -tmp_dir="/tmp/ibmcloud_install" - -mkdir -p "$tmp_dir" -echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." - -if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then - echo "Download complete. Verifying integrity..." -else - echo "Download failed. Please check your network connection. Quit installation." - exit 1 -fi - -calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') -if [ "$sh1sum" != "$calculated_sha1sum" ]; then - echo "Downloaded file is corrupted (checksum mismatch). Quit installation." - rm -rf "$tmp_dir" - exit 1 -fi - -echo "Extracting package..." -tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 - -if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then - chmod 755 "${tmp_dir}/Bluemix_CLI/install" -fi - -echo "Running installer (no sudo)..." -"${tmp_dir}/Bluemix_CLI/install" -q -install_result=$? - -rm -rf "${tmp_dir}" - -if [ $install_result -eq 0 ]; then - echo "IBM Cloud CLI installation completed successfully." -else - echo "IBM Cloud CLI installation failed." - exit 1 -fi - -} + echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" + echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" +fi + +# install_ibm_cli() { +# # Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) + +# host="download.clis.cloud.ibm.com" +# metadata_host="$host/ibm-cloud-cli-metadata" +# binary_download_host="$host/ibm-cloud-cli" + +# os_name=$(uname -s | tr '[:upper:]' '[:lower:]') +# arch=$(uname -m | tr '[:upper:]' '[:lower:]') + +# if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then +# platform="linux64" +# else +# echo "This installer only supports Linux x86_64 (linux64). Quit installation." +# exit 1 +# fi + +# # fetch version metadata of CLI +# info_endpoint="https://$metadata_host/info.json" +# info=$(curl -f -L -s "$info_endpoint") +# status="$?" + +# if [ $status -ne 0 ]; then +# echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." +# exit 1 +# fi + +# # parse latest version from metadata +# latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') +# if [ -z "$latest_version" ]; then +# echo "Unable to parse latest version number. Quit installation." +# exit 1 +# fi + +# # fetch all versions metadata of CLI +# all_versions_endpoint="https://$metadata_host/all_versions.json" +# all_versions=$(curl -f -L -s "$all_versions_endpoint") +# status="$?" +# if [ $status -ne 0 ]; then +# echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." +# exit 1 +# fi + +# # extract section of metadata for the desired version +# metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') +# if [ -z "$metadata_section" ]; then +# echo "Unable to parse metadata for CLI version $latest_version. Quit installation." +# exit 1 +# fi + +# # get platform-specific binary info +# platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') + +# # extract installer URL and checksum +# installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') +# sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') + +# if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then +# echo "Unable to parse installer URL or checksum. Quit installation." +# exit 1 +# fi + +# file_name="IBM_Cloud_CLI.tar.gz" +# tmp_dir="/tmp/ibmcloud_install" + +# mkdir -p "$tmp_dir" +# echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." + +# if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then +# echo "Download complete. Verifying integrity..." +# else +# echo "Download failed. Please check your network connection. Quit installation." +# exit 1 +# fi + +# calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') +# if [ "$sh1sum" != "$calculated_sha1sum" ]; then +# echo "Downloaded file is corrupted (checksum mismatch). Quit installation." +# rm -rf "$tmp_dir" +# exit 1 +# fi + +# echo "Extracting package..." +# tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 + +# if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then +# chmod 755 "${tmp_dir}/Bluemix_CLI/install" +# fi + +# echo "Running installer (no sudo)..." +# "${tmp_dir}/Bluemix_CLI/install" -q +# install_result=$? + +# rm -rf "${tmp_dir}" + +# if [ $install_result -eq 0 ]; then +# echo "IBM Cloud CLI installation completed successfully." +# else +# echo "IBM Cloud CLI installation failed." +# exit 1 +# fi + +# } # --- Function to install jq --- install_jq() { - echo "Installing jq (locally)..." - JQ_VERSION="1.7" - ARCH=$(uname -m) - OS=$(uname | tr '[:upper:]' '[:lower:]') - - case "$ARCH" in - x86_64) JQ_ARCH="jq-linux64" ;; - aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases - *) echo "Unsupported architecture: $ARCH"; exit 1 ;; - esac - - curl -L -o "$LOCAL_BIN/jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" - chmod +x "$LOCAL_BIN/jq" - echo "✅ jq installed locally at $LOCAL_BIN/jq" + echo "Installing jq (locally)..." + JQ_VERSION="1.7" + ARCH=$(uname -m) + OS=$(uname | tr '[:upper:]' '[:lower:]') + + case "$ARCH" in + x86_64) JQ_ARCH="jq-linux64" ;; + aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; + esac + + curl -L -o "$LOCAL_BIN/jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" + chmod +x "$LOCAL_BIN/jq" + echo "✅ jq installed locally at $LOCAL_BIN/jq" } # --- Check and install kubectl --- if ! command -v kubectl >/dev/null 2>&1; then - echo "kubectl not found. Installing latest stable version locally..." - OS=$(uname | tr '[:upper:]' '[:lower:]') - KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) - curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" - chmod +x ./kubectl - mv ./kubectl "$LOCAL_BIN/kubectl" - echo "✅ kubectl installed locally at $LOCAL_BIN/kubectl" -else - echo "✅ kubectl is already installed. Skipping installation." -fi - -# --- Check and install IBM Cloud CLI --- -if ! command -v ibmcloud >/dev/null 2>&1; then - echo "IBM Cloud CLI not found. Installing locally..." - install_ibm_cli - echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" + echo "kubectl not found. Installing latest stable version locally..." + OS=$(uname | tr '[:upper:]' '[:lower:]') + KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) + curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" + chmod +x ./kubectl + mv ./kubectl "$LOCAL_BIN/kubectl" + echo "✅ kubectl installed locally at $LOCAL_BIN/kubectl" else - echo "✅ IBM Cloud CLI is already installed. Skipping installation." -fi - -# --- Ensure IBM Cloud Kubernetes Service CLI plugin --- -if ! ibmcloud plugin show container-service >/dev/null 2>&1; then - echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." - ibmcloud plugin install container-service -f - echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." -else - echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." -fi - -# --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- -if ! ibmcloud plugin show is >/dev/null 2>&1; then - echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." - ibmcloud plugin install is -f - echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." -else - echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." -fi + echo "✅ kubectl is already installed. Skipping installation." +fi + +# # --- Check and install IBM Cloud CLI --- +# if ! command -v ibmcloud >/dev/null 2>&1; then +# echo "IBM Cloud CLI not found. Installing locally..." +# install_ibm_cli +# echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" +# else +# echo "✅ IBM Cloud CLI is already installed. Skipping installation." +# fi + +# # --- Ensure IBM Cloud Kubernetes Service CLI plugin --- +# if ! ibmcloud plugin show container-service >/dev/null 2>&1; then +# echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." +# ibmcloud plugin install container-service -f +# echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." +# else +# echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." +# fi + +# # --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- +# if ! ibmcloud plugin show is >/dev/null 2>&1; then +# echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." +# ibmcloud plugin install is -f +# echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." +# else +# echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." +# fi # --- Check and install jq --- if ! command -v jq >/dev/null 2>&1; then - install_jq + install_jq else - echo "✅ jq is already installed. Skipping installation." + echo "✅ jq is already installed. Skipping installation." fi echo "" echo "🎉 All required CLI tools are installed locally:" -echo " - IBM Cloud CLI" -echo " - IBM Cloud Kubernetes Service CLI plugin" -echo " - IBM Cloud VPC Infrastructure Service CLI plugin" +# echo " - IBM Cloud CLI" +# echo " - IBM Cloud Kubernetes Service CLI plugin" +# echo " - IBM Cloud VPC Infrastructure Service CLI plugin" echo " - kubectl" echo " - jq" echo "" From 3269dc2d12338cc8ffc1a4f1d50afcbfe43d1866 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 12:29:44 +0530 Subject: [PATCH 09/34] verify --- solutions/quickstart/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 02f099f19..8978d42f0 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -157,5 +157,5 @@ module "ocp_base" { access_tags = var.access_tags disable_public_endpoint = !var.allow_public_access_to_cluster_management cluster_config_endpoint_type = "default" - verify_worker_network_readiness = false + # verify_worker_network_readiness = false } From af23992ada5bdcec6fa3d89f674ad6e095622b4b Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 13:35:41 +0530 Subject: [PATCH 10/34] test --- solutions/quickstart/main.tf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 8978d42f0..4ce70ca1e 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,7 +1,11 @@ resource "null_resource" "install_tools" { + # provisioner "local-exec" { + # command = "${path.module}/scripts/install_tools.sh && source ~/.bashrc" + # interpreter = ["/bin/bash", "-c"] + # } + # download kubectl provisioner "local-exec" { - command = "${path.module}/scripts/install_tools.sh && source ~/.bashrc" - interpreter = ["/bin/bash", "-c"] + command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" } triggers = { From 30f5ccbb656979e42873109ff375697b8a2e9c1d Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 13:36:22 +0530 Subject: [PATCH 11/34] test2 --- solutions/quickstart/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 4ce70ca1e..2e748a181 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -17,7 +17,6 @@ resource "null_resource" "install_tools" { # Resource Group ####################################################################################################################### module "resource_group" { - depends_on = [null_resource.install_tools] source = "terraform-ibm-modules/resource-group/ibm" version = "1.4.0" existing_resource_group_name = var.existing_resource_group_name @@ -147,6 +146,7 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { + depends_on = [null_resource.install_tools] source = "terraform-ibm-modules/base-ocp-vpc/ibm" version = "3.71.3" cluster_name = local.cluster_name From 1d2e280e818a0e926c0afc6ffe64ff5241a000a5 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 14:13:04 +0530 Subject: [PATCH 12/34] test --- solutions/quickstart/main.tf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 2e748a181..cca6981ca 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -4,10 +4,15 @@ resource "null_resource" "install_tools" { # interpreter = ["/bin/bash", "-c"] # } # download kubectl + depends_on = [module.ocp_base] provisioner "local-exec" { command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" } + provisioner "local-exec" { + command = "kubectl create namespace meta && kubectl create secret generic minio -n meta --from-literal=rootUser=ck_infra_admin --from-literal=rootPassword=f23ff2#DcejC:d" + } + triggers = { always_run = timestamp() } @@ -146,7 +151,7 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - depends_on = [null_resource.install_tools] + # depends_on = [null_resource.install_tools] source = "terraform-ibm-modules/base-ocp-vpc/ibm" version = "3.71.3" cluster_name = local.cluster_name @@ -161,5 +166,5 @@ module "ocp_base" { access_tags = var.access_tags disable_public_endpoint = !var.allow_public_access_to_cluster_management cluster_config_endpoint_type = "default" - # verify_worker_network_readiness = false + verify_worker_network_readiness = false } From c114a14cdf079551ff89c5cb599482ae7978a528 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 14:15:48 +0530 Subject: [PATCH 13/34] test3 --- solutions/quickstart/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index cca6981ca..253bd75a2 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -4,7 +4,7 @@ resource "null_resource" "install_tools" { # interpreter = ["/bin/bash", "-c"] # } # download kubectl - depends_on = [module.ocp_base] + # depends_on = [module.ocp_base] provisioner "local-exec" { command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" } From 8b0d65d8f5cc8e1a07de14f6058df9c0b69a7f0f Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Mon, 10 Nov 2025 19:41:10 +0530 Subject: [PATCH 14/34] test5 --- solutions/quickstart/main.tf | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 253bd75a2..7b9a8c292 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,21 +1,18 @@ -resource "null_resource" "install_tools" { - # provisioner "local-exec" { - # command = "${path.module}/scripts/install_tools.sh && source ~/.bashrc" - # interpreter = ["/bin/bash", "-c"] - # } - # download kubectl - # depends_on = [module.ocp_base] - provisioner "local-exec" { - command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" +resource "null_resource" "custom" { + # change trigger to run every time + triggers = { + build_number = "${timestamp()}" } + # download kubectl provisioner "local-exec" { - command = "kubectl create namespace meta && kubectl create secret generic minio -n meta --from-literal=rootUser=ck_infra_admin --from-literal=rootPassword=f23ff2#DcejC:d" + command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" } - triggers = { - always_run = timestamp() - } + # # run kubectl + # provisioner "local-exec" { + # command = "./kubectl apply -f deployment.yaml" + # } } ####################################################################################################################### @@ -151,7 +148,7 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - # depends_on = [null_resource.install_tools] + depends_on = [null_resource.custom] source = "terraform-ibm-modules/base-ocp-vpc/ibm" version = "3.71.3" cluster_name = local.cluster_name @@ -166,5 +163,5 @@ module "ocp_base" { access_tags = var.access_tags disable_public_endpoint = !var.allow_public_access_to_cluster_management cluster_config_endpoint_type = "default" - verify_worker_network_readiness = false + verify_worker_network_readiness = true } From 10669904f5a423c06a642a9590fa2db852804486 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 11 Nov 2025 14:24:04 +0530 Subject: [PATCH 15/34] test9 --- solutions/quickstart/main.tf | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 7b9a8c292..b5e8454d0 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,19 +1,19 @@ -resource "null_resource" "custom" { - # change trigger to run every time - triggers = { - build_number = "${timestamp()}" - } - - # download kubectl - provisioner "local-exec" { - command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" - } - - # # run kubectl - # provisioner "local-exec" { - # command = "./kubectl apply -f deployment.yaml" - # } -} +# resource "null_resource" "custom" { +# # change trigger to run every time +# triggers = { +# build_number = "${timestamp()}" +# } + +# # download kubectl +# provisioner "local-exec" { +# command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" +# } + +# # # run kubectl +# # provisioner "local-exec" { +# # command = "./kubectl apply -f deployment.yaml" +# # } +# } ####################################################################################################################### # Resource Group @@ -149,8 +149,8 @@ locals { ######################################################################################################################## module "ocp_base" { depends_on = [null_resource.custom] - source = "terraform-ibm-modules/base-ocp-vpc/ibm" - version = "3.71.3" + source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" + # version = "3.71.3" cluster_name = local.cluster_name resource_group_id = module.resource_group.resource_group_id region = var.region From 827b341cb253d830cc26cf9464b45b1819d14cc5 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 11 Nov 2025 14:28:24 +0530 Subject: [PATCH 16/34] test8 --- solutions/quickstart/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index b5e8454d0..08b4e3c8f 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -148,7 +148,7 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - depends_on = [null_resource.custom] + # depends_on = [null_resource.custom] source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" # version = "3.71.3" cluster_name = local.cluster_name From 6f6dc7b5196d50d5a68f24b5bbbcb55d3b04c703 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Wed, 12 Nov 2025 08:46:26 +0530 Subject: [PATCH 17/34] test7 --- solutions/quickstart/main.tf | 35 +++++++++---------- solutions/quickstart/scripts/install_tools.sh | 30 ++++++++-------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 08b4e3c8f..0df9243b4 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,19 +1,18 @@ -# resource "null_resource" "custom" { -# # change trigger to run every time -# triggers = { -# build_number = "${timestamp()}" -# } - -# # download kubectl -# provisioner "local-exec" { -# command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl" -# } - -# # # run kubectl -# # provisioner "local-exec" { -# # command = "./kubectl apply -f deployment.yaml" -# # } -# } +resource "null_resource" "custom" { + # change trigger to run every time + triggers = { + build_number = "${timestamp()}" + } + + # download kubectl + provisioner "local-exec" { + command = "bash ${path.module}/scripts/install_tools.sh && export PATH=$PATH:$PWD" + } + + provisioner "local-exec" { + command = "kubectl" + } +} ####################################################################################################################### # Resource Group @@ -148,8 +147,8 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - # depends_on = [null_resource.custom] - source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" + depends_on = [null_resource.custom] + source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" # version = "3.71.3" cluster_name = local.cluster_name resource_group_id = module.resource_group.resource_group_id diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index 1eb6d7d7c..b4537ba1c 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -4,16 +4,16 @@ set -euo pipefail echo "🔍 Checking and installing required CLI tools (user-level, no sudo)..." -# --- Setup local bin directory --- -LOCAL_BIN="$HOME/bin" -mkdir -p "$LOCAL_BIN" -export PATH="$LOCAL_BIN:$PATH" - -# --- Helper to add PATH persistently --- -if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then - echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" - echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" -fi +# # --- Setup local bin directory --- +# LOCAL_BIN="$HOME/bin" +# mkdir -p "$LOCAL_BIN" +# export PATH="$LOCAL_BIN:$PATH" + +# # --- Helper to add PATH persistently --- +# if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then +# echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" +# echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" +# fi # install_ibm_cli() { # # Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) @@ -135,9 +135,9 @@ install_jq() { ;; esac - curl -L -o "$LOCAL_BIN/jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" - chmod +x "$LOCAL_BIN/jq" - echo "✅ jq installed locally at $LOCAL_BIN/jq" + curl -L -o "jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" + chmod +x "jq" + echo "✅ jq installed locally at jq" } # --- Check and install kubectl --- @@ -147,8 +147,8 @@ if ! command -v kubectl >/dev/null 2>&1; then KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" chmod +x ./kubectl - mv ./kubectl "$LOCAL_BIN/kubectl" - echo "✅ kubectl installed locally at $LOCAL_BIN/kubectl" + # mv ./kubectl "kubectl" + echo "✅ kubectl installed locally at kubectl" else echo "✅ kubectl is already installed. Skipping installation." fi From 138c8dc83406bf28acbd1b00351464771b649ce4 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Wed, 12 Nov 2025 08:51:26 +0530 Subject: [PATCH 18/34] test6 --- solutions/quickstart/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 0df9243b4..daf901a1d 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -6,11 +6,11 @@ resource "null_resource" "custom" { # download kubectl provisioner "local-exec" { - command = "bash ${path.module}/scripts/install_tools.sh && export PATH=$PATH:$PWD" + command = "bash ${path.module}/scripts/install_tools.sh" } provisioner "local-exec" { - command = "kubectl" + command = "export PATH=$PATH:$PWD && kubectl" } } From ba51705e387c123811d5f450e5a7ee6a744c10e8 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Wed, 12 Nov 2025 08:58:34 +0530 Subject: [PATCH 19/34] test5 --- solutions/quickstart/main.tf | 5 +- solutions/quickstart/scripts/install_tools.sh | 399 ++++++++++-------- 2 files changed, 223 insertions(+), 181 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index daf901a1d..23966b111 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -9,8 +9,11 @@ resource "null_resource" "custom" { command = "bash ${path.module}/scripts/install_tools.sh" } + # provisioner "local-exec" { + # command = "export PATH=$PATH:$PWD && kubectl" + # } provisioner "local-exec" { - command = "export PATH=$PATH:$PWD && kubectl" + command = "kubectl" } } diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index b4537ba1c..95d3c0c01 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -1,197 +1,236 @@ -#!/bin/bash - -set -euo pipefail - -echo "🔍 Checking and installing required CLI tools (user-level, no sudo)..." - -# # --- Setup local bin directory --- -# LOCAL_BIN="$HOME/bin" -# mkdir -p "$LOCAL_BIN" -# export PATH="$LOCAL_BIN:$PATH" - -# # --- Helper to add PATH persistently --- -# if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then -# echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" -# echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" -# fi - -# install_ibm_cli() { -# # Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) - -# host="download.clis.cloud.ibm.com" -# metadata_host="$host/ibm-cloud-cli-metadata" -# binary_download_host="$host/ibm-cloud-cli" - -# os_name=$(uname -s | tr '[:upper:]' '[:lower:]') -# arch=$(uname -m | tr '[:upper:]' '[:lower:]') - -# if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then -# platform="linux64" -# else -# echo "This installer only supports Linux x86_64 (linux64). Quit installation." -# exit 1 -# fi - -# # fetch version metadata of CLI -# info_endpoint="https://$metadata_host/info.json" -# info=$(curl -f -L -s "$info_endpoint") -# status="$?" - -# if [ $status -ne 0 ]; then -# echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." -# exit 1 -# fi - -# # parse latest version from metadata -# latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') -# if [ -z "$latest_version" ]; then -# echo "Unable to parse latest version number. Quit installation." -# exit 1 -# fi - -# # fetch all versions metadata of CLI -# all_versions_endpoint="https://$metadata_host/all_versions.json" -# all_versions=$(curl -f -L -s "$all_versions_endpoint") -# status="$?" -# if [ $status -ne 0 ]; then -# echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." -# exit 1 -# fi - -# # extract section of metadata for the desired version -# metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') -# if [ -z "$metadata_section" ]; then -# echo "Unable to parse metadata for CLI version $latest_version. Quit installation." -# exit 1 -# fi - -# # get platform-specific binary info -# platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') - -# # extract installer URL and checksum -# installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') -# sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') - -# if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then -# echo "Unable to parse installer URL or checksum. Quit installation." +# #!/bin/bash + +# set -euo pipefail + +# echo "🔍 Checking and installing required CLI tools (user-level, no sudo)..." + +# # # --- Setup local bin directory --- +# # LOCAL_BIN="$HOME/bin" +# # mkdir -p "$LOCAL_BIN" +# # export PATH="$LOCAL_BIN:$PATH" + +# # # --- Helper to add PATH persistently --- +# # if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then +# # echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" +# # echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" +# # fi + +# # install_ibm_cli() { +# # # Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) + +# # host="download.clis.cloud.ibm.com" +# # metadata_host="$host/ibm-cloud-cli-metadata" +# # binary_download_host="$host/ibm-cloud-cli" + +# # os_name=$(uname -s | tr '[:upper:]' '[:lower:]') +# # arch=$(uname -m | tr '[:upper:]' '[:lower:]') + +# # if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then +# # platform="linux64" +# # else +# # echo "This installer only supports Linux x86_64 (linux64). Quit installation." +# # exit 1 +# # fi + +# # # fetch version metadata of CLI +# # info_endpoint="https://$metadata_host/info.json" +# # info=$(curl -f -L -s "$info_endpoint") +# # status="$?" + +# # if [ $status -ne 0 ]; then +# # echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." +# # exit 1 +# # fi + +# # # parse latest version from metadata +# # latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') +# # if [ -z "$latest_version" ]; then +# # echo "Unable to parse latest version number. Quit installation." +# # exit 1 +# # fi + +# # # fetch all versions metadata of CLI +# # all_versions_endpoint="https://$metadata_host/all_versions.json" +# # all_versions=$(curl -f -L -s "$all_versions_endpoint") +# # status="$?" +# # if [ $status -ne 0 ]; then +# # echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." +# # exit 1 +# # fi + +# # # extract section of metadata for the desired version +# # metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') +# # if [ -z "$metadata_section" ]; then +# # echo "Unable to parse metadata for CLI version $latest_version. Quit installation." +# # exit 1 +# # fi + +# # # get platform-specific binary info +# # platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') + +# # # extract installer URL and checksum +# # installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') +# # sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') + +# # if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then +# # echo "Unable to parse installer URL or checksum. Quit installation." +# # exit 1 +# # fi + +# # file_name="IBM_Cloud_CLI.tar.gz" +# # tmp_dir="/tmp/ibmcloud_install" + +# # mkdir -p "$tmp_dir" +# # echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." + +# # if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then +# # echo "Download complete. Verifying integrity..." +# # else +# # echo "Download failed. Please check your network connection. Quit installation." +# # exit 1 +# # fi + +# # calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') +# # if [ "$sh1sum" != "$calculated_sha1sum" ]; then +# # echo "Downloaded file is corrupted (checksum mismatch). Quit installation." +# # rm -rf "$tmp_dir" +# # exit 1 +# # fi + +# # echo "Extracting package..." +# # tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 + +# # if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then +# # chmod 755 "${tmp_dir}/Bluemix_CLI/install" +# # fi + +# # echo "Running installer (no sudo)..." +# # "${tmp_dir}/Bluemix_CLI/install" -q +# # install_result=$? + +# # rm -rf "${tmp_dir}" + +# # if [ $install_result -eq 0 ]; then +# # echo "IBM Cloud CLI installation completed successfully." +# # else +# # echo "IBM Cloud CLI installation failed." +# # exit 1 +# # fi + +# # } + +# # --- Function to install jq --- +# install_jq() { +# echo "Installing jq (locally)..." +# JQ_VERSION="1.7" +# ARCH=$(uname -m) +# OS=$(uname | tr '[:upper:]' '[:lower:]') + +# case "$ARCH" in +# x86_64) JQ_ARCH="jq-linux64" ;; +# aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases +# *) +# echo "Unsupported architecture: $ARCH" # exit 1 -# fi +# ;; +# esac -# file_name="IBM_Cloud_CLI.tar.gz" -# tmp_dir="/tmp/ibmcloud_install" - -# mkdir -p "$tmp_dir" -# echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." - -# if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then -# echo "Download complete. Verifying integrity..." -# else -# echo "Download failed. Please check your network connection. Quit installation." -# exit 1 -# fi +# curl -L -o "jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" +# chmod +x "jq" +# echo "✅ jq installed locally at jq" +# } -# calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') -# if [ "$sh1sum" != "$calculated_sha1sum" ]; then -# echo "Downloaded file is corrupted (checksum mismatch). Quit installation." -# rm -rf "$tmp_dir" -# exit 1 -# fi +# # --- Check and install kubectl --- +# if ! command -v kubectl >/dev/null 2>&1; then +# echo "kubectl not found. Installing latest stable version locally..." +# OS=$(uname | tr '[:upper:]' '[:lower:]') +# KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) +# curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" +# chmod +x ./kubectl +# # mv ./kubectl "kubectl" +# echo "✅ kubectl installed locally at kubectl" +# else +# echo "✅ kubectl is already installed. Skipping installation." +# fi -# echo "Extracting package..." -# tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 +# # # --- Check and install IBM Cloud CLI --- +# # if ! command -v ibmcloud >/dev/null 2>&1; then +# # echo "IBM Cloud CLI not found. Installing locally..." +# # install_ibm_cli +# # echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" +# # else +# # echo "✅ IBM Cloud CLI is already installed. Skipping installation." +# # fi + +# # # --- Ensure IBM Cloud Kubernetes Service CLI plugin --- +# # if ! ibmcloud plugin show container-service >/dev/null 2>&1; then +# # echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." +# # ibmcloud plugin install container-service -f +# # echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." +# # else +# # echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." +# # fi + +# # # --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- +# # if ! ibmcloud plugin show is >/dev/null 2>&1; then +# # echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." +# # ibmcloud plugin install is -f +# # echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." +# # else +# # echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." +# # fi + +# # --- Check and install jq --- +# if ! command -v jq >/dev/null 2>&1; then +# install_jq +# else +# echo "✅ jq is already installed. Skipping installation." +# fi -# if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then -# chmod 755 "${tmp_dir}/Bluemix_CLI/install" -# fi +# echo "" +# echo "🎉 All required CLI tools are installed locally:" +# # echo " - IBM Cloud CLI" +# # echo " - IBM Cloud Kubernetes Service CLI plugin" +# # echo " - IBM Cloud VPC Infrastructure Service CLI plugin" +# echo " - kubectl" +# echo " - jq" +# echo "" -# echo "Running installer (no sudo)..." -# "${tmp_dir}/Bluemix_CLI/install" -q -# install_result=$? -# rm -rf "${tmp_dir}" +#!/usr/bin/env bash +set -euo pipefail -# if [ $install_result -eq 0 ]; then -# echo "IBM Cloud CLI installation completed successfully." -# else -# echo "IBM Cloud CLI installation failed." -# exit 1 -# fi +TARGET_DIR="$PWD" -# } +if [[ ! -d "$TARGET_DIR" ]]; then + echo "❌ Error: '$TARGET_DIR' is not a directory." + exit 1 +fi -# --- Function to install jq --- -install_jq() { - echo "Installing jq (locally)..." - JQ_VERSION="1.7" - ARCH=$(uname -m) - OS=$(uname | tr '[:upper:]' '[:lower:]') - - case "$ARCH" in - x86_64) JQ_ARCH="jq-linux64" ;; - aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases - *) - echo "Unsupported architecture: $ARCH" - exit 1 - ;; - esac - - curl -L -o "jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" - chmod +x "jq" - echo "✅ jq installed locally at jq" -} - -# --- Check and install kubectl --- -if ! command -v kubectl >/dev/null 2>&1; then - echo "kubectl not found. Installing latest stable version locally..." - OS=$(uname | tr '[:upper:]' '[:lower:]') - KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) - curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" - chmod +x ./kubectl - # mv ./kubectl "kubectl" - echo "✅ kubectl installed locally at kubectl" +# --- Detect shell config file --- +if [[ -n "${ZSH_VERSION-}" ]]; then + SHELL_RC="$HOME/.zshrc" +elif [[ -n "${BASH_VERSION-}" ]]; then + SHELL_RC="$HOME/.bashrc" else - echo "✅ kubectl is already installed. Skipping installation." + # Fallback for unknown shells + SHELL_RC="$HOME/.bashrc" fi -# # --- Check and install IBM Cloud CLI --- -# if ! command -v ibmcloud >/dev/null 2>&1; then -# echo "IBM Cloud CLI not found. Installing locally..." -# install_ibm_cli -# echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" -# else -# echo "✅ IBM Cloud CLI is already installed. Skipping installation." -# fi - -# # --- Ensure IBM Cloud Kubernetes Service CLI plugin --- -# if ! ibmcloud plugin show container-service >/dev/null 2>&1; then -# echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." -# ibmcloud plugin install container-service -f -# echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." -# else -# echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." -# fi - -# # --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- -# if ! ibmcloud plugin show is >/dev/null 2>&1; then -# echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." -# ibmcloud plugin install is -f -# echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." -# else -# echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." -# fi +# --- Check if already added --- +EXPORT_LINE="export PATH=\$PATH:$TARGET_DIR" -# --- Check and install jq --- -if ! command -v jq >/dev/null 2>&1; then - install_jq +if grep -Fxq "$EXPORT_LINE" "$SHELL_RC"; then + echo "✅ PATH already includes $TARGET_DIR in $SHELL_RC" else - echo "✅ jq is already installed. Skipping installation." + echo "" >> "$SHELL_RC" + echo "# Added by add-to-path.sh on $(date)" >> "$SHELL_RC" + echo "$EXPORT_LINE" >> "$SHELL_RC" + echo "✅ Added $TARGET_DIR to PATH in $SHELL_RC" fi -echo "" -echo "🎉 All required CLI tools are installed locally:" -# echo " - IBM Cloud CLI" -# echo " - IBM Cloud Kubernetes Service CLI plugin" -# echo " - IBM Cloud VPC Infrastructure Service CLI plugin" -echo " - kubectl" -echo " - jq" -echo "" +# --- Apply change immediately --- +# shellcheck disable=SC1090 +source "$SHELL_RC" +echo "🔁 Applied changes. Current PATH:" +echo "$PATH" From dd360fb0e84308c1e3d24f739c2956302022911a Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Wed, 12 Nov 2025 09:07:31 +0530 Subject: [PATCH 20/34] test4 --- solutions/quickstart/scripts/install_tools.sh | 374 +++++++++--------- 1 file changed, 187 insertions(+), 187 deletions(-) diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index 95d3c0c01..ddb1bb0b4 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -1,200 +1,200 @@ -# #!/bin/bash - -# set -euo pipefail - -# echo "🔍 Checking and installing required CLI tools (user-level, no sudo)..." - -# # # --- Setup local bin directory --- -# # LOCAL_BIN="$HOME/bin" -# # mkdir -p "$LOCAL_BIN" -# # export PATH="$LOCAL_BIN:$PATH" - -# # # --- Helper to add PATH persistently --- -# # if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then -# # echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" -# # echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" -# # fi - -# # install_ibm_cli() { -# # # Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) - -# # host="download.clis.cloud.ibm.com" -# # metadata_host="$host/ibm-cloud-cli-metadata" -# # binary_download_host="$host/ibm-cloud-cli" - -# # os_name=$(uname -s | tr '[:upper:]' '[:lower:]') -# # arch=$(uname -m | tr '[:upper:]' '[:lower:]') - -# # if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then -# # platform="linux64" -# # else -# # echo "This installer only supports Linux x86_64 (linux64). Quit installation." -# # exit 1 -# # fi - -# # # fetch version metadata of CLI -# # info_endpoint="https://$metadata_host/info.json" -# # info=$(curl -f -L -s "$info_endpoint") -# # status="$?" - -# # if [ $status -ne 0 ]; then -# # echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." -# # exit 1 -# # fi - -# # # parse latest version from metadata -# # latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') -# # if [ -z "$latest_version" ]; then -# # echo "Unable to parse latest version number. Quit installation." -# # exit 1 -# # fi - -# # # fetch all versions metadata of CLI -# # all_versions_endpoint="https://$metadata_host/all_versions.json" -# # all_versions=$(curl -f -L -s "$all_versions_endpoint") -# # status="$?" -# # if [ $status -ne 0 ]; then -# # echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." -# # exit 1 -# # fi - -# # # extract section of metadata for the desired version -# # metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') -# # if [ -z "$metadata_section" ]; then -# # echo "Unable to parse metadata for CLI version $latest_version. Quit installation." -# # exit 1 -# # fi - -# # # get platform-specific binary info -# # platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') - -# # # extract installer URL and checksum -# # installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') -# # sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') - -# # if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then -# # echo "Unable to parse installer URL or checksum. Quit installation." -# # exit 1 -# # fi - -# # file_name="IBM_Cloud_CLI.tar.gz" -# # tmp_dir="/tmp/ibmcloud_install" - -# # mkdir -p "$tmp_dir" -# # echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." - -# # if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then -# # echo "Download complete. Verifying integrity..." -# # else -# # echo "Download failed. Please check your network connection. Quit installation." -# # exit 1 -# # fi - -# # calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') -# # if [ "$sh1sum" != "$calculated_sha1sum" ]; then -# # echo "Downloaded file is corrupted (checksum mismatch). Quit installation." -# # rm -rf "$tmp_dir" -# # exit 1 -# # fi - -# # echo "Extracting package..." -# # tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 - -# # if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then -# # chmod 755 "${tmp_dir}/Bluemix_CLI/install" -# # fi - -# # echo "Running installer (no sudo)..." -# # "${tmp_dir}/Bluemix_CLI/install" -q -# # install_result=$? - -# # rm -rf "${tmp_dir}" - -# # if [ $install_result -eq 0 ]; then -# # echo "IBM Cloud CLI installation completed successfully." -# # else -# # echo "IBM Cloud CLI installation failed." -# # exit 1 -# # fi - -# # } - -# # --- Function to install jq --- -# install_jq() { -# echo "Installing jq (locally)..." -# JQ_VERSION="1.7" -# ARCH=$(uname -m) -# OS=$(uname | tr '[:upper:]' '[:lower:]') - -# case "$ARCH" in -# x86_64) JQ_ARCH="jq-linux64" ;; -# aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases -# *) -# echo "Unsupported architecture: $ARCH" +#!/bin/bash + +set -euo pipefail + +echo "🔍 Checking and installing required CLI tools (user-level, no sudo)..." + +# # --- Setup local bin directory --- +# LOCAL_BIN="$HOME/bin" +# mkdir -p "$LOCAL_BIN" +# export PATH="$LOCAL_BIN:$PATH" + +# # --- Helper to add PATH persistently --- +# if ! grep -q "$LOCAL_BIN" "$HOME/.bashrc"; then +# echo "export PATH=\"$LOCAL_BIN:\$PATH\"" >>"$HOME/.bashrc" +# echo "✅ Added $LOCAL_BIN to PATH in ~/.bashrc" +# fi + +# install_ibm_cli() { +# # Simplified installer for IBM Cloud CLI (Linux x86_64 only, no sudo) + +# host="download.clis.cloud.ibm.com" +# metadata_host="$host/ibm-cloud-cli-metadata" +# binary_download_host="$host/ibm-cloud-cli" + +# os_name=$(uname -s | tr '[:upper:]' '[:lower:]') +# arch=$(uname -m | tr '[:upper:]' '[:lower:]') + +# if [ "$os_name" = "linux" ] && echo "$arch" | grep -q 'x86_64'; then +# platform="linux64" +# else +# echo "This installer only supports Linux x86_64 (linux64). Quit installation." +# exit 1 +# fi + +# # fetch version metadata of CLI +# info_endpoint="https://$metadata_host/info.json" +# info=$(curl -f -L -s "$info_endpoint") +# status="$?" + +# if [ $status -ne 0 ]; then +# echo "Download latest CLI metadata failed. Please check your network connection. Quit installation." +# exit 1 +# fi + +# # parse latest version from metadata +# latest_version=$(echo "$info" | grep -Eo '"latestVersion"[^,]*' | grep -Eo '[^:]*$' | tr -d '"' | tr -d '[:space:]') +# if [ -z "$latest_version" ]; then +# echo "Unable to parse latest version number. Quit installation." +# exit 1 +# fi + +# # fetch all versions metadata of CLI +# all_versions_endpoint="https://$metadata_host/all_versions.json" +# all_versions=$(curl -f -L -s "$all_versions_endpoint") +# status="$?" +# if [ $status -ne 0 ]; then +# echo "Download latest CLI versions metadata failed. Please check your network connection. Quit installation." +# exit 1 +# fi + +# # extract section of metadata for the desired version +# metadata_section=$(echo "$all_versions" | sed -ne '/'\""$latest_version"\"'/,/'"archives"'/p') +# if [ -z "$metadata_section" ]; then +# echo "Unable to parse metadata for CLI version $latest_version. Quit installation." +# exit 1 +# fi + +# # get platform-specific binary info +# platform_binaries=$(echo "$metadata_section" | sed -ne '/'"$platform"'/,/'"checksum"'/p') + +# # extract installer URL and checksum +# installer_url=$(echo "$platform_binaries" | grep -Eo '"url"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') +# sh1sum=$(echo "$platform_binaries" | grep -Eo '"checksum"[^,]*' | cut -d ":" -f2- | tr -d '"' | tr -d '[:space:]') + +# if [ -z "$installer_url" ] || [ -z "$sh1sum" ]; then +# echo "Unable to parse installer URL or checksum. Quit installation." # exit 1 -# ;; -# esac +# fi + +# file_name="IBM_Cloud_CLI.tar.gz" +# tmp_dir="/tmp/ibmcloud_install" + +# mkdir -p "$tmp_dir" +# echo "Current platform is ${platform}. Downloading IBM Cloud CLI..." + +# if curl -L "$installer_url" -o "${tmp_dir}/${file_name}"; then +# echo "Download complete. Verifying integrity..." +# else +# echo "Download failed. Please check your network connection. Quit installation." +# exit 1 +# fi + +# calculated_sha1sum=$(sha1sum "${tmp_dir}/${file_name}" | awk '{print $1}') +# if [ "$sh1sum" != "$calculated_sha1sum" ]; then +# echo "Downloaded file is corrupted (checksum mismatch). Quit installation." +# rm -rf "$tmp_dir" +# exit 1 +# fi + +# echo "Extracting package..." +# tar -xvf "${tmp_dir}/${file_name}" -C "$tmp_dir" >/dev/null 2>&1 + +# if [ ! -x "${tmp_dir}/Bluemix_CLI/install" ]; then +# chmod 755 "${tmp_dir}/Bluemix_CLI/install" +# fi + +# echo "Running installer (no sudo)..." +# "${tmp_dir}/Bluemix_CLI/install" -q +# install_result=$? + +# rm -rf "${tmp_dir}" + +# if [ $install_result -eq 0 ]; then +# echo "IBM Cloud CLI installation completed successfully." +# else +# echo "IBM Cloud CLI installation failed." +# exit 1 +# fi -# curl -L -o "jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" -# chmod +x "jq" -# echo "✅ jq installed locally at jq" # } -# # --- Check and install kubectl --- -# if ! command -v kubectl >/dev/null 2>&1; then -# echo "kubectl not found. Installing latest stable version locally..." -# OS=$(uname | tr '[:upper:]' '[:lower:]') -# KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) -# curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" -# chmod +x ./kubectl -# # mv ./kubectl "kubectl" -# echo "✅ kubectl installed locally at kubectl" +# --- Function to install jq --- +install_jq() { + echo "Installing jq (locally)..." + JQ_VERSION="1.7" + ARCH=$(uname -m) + OS=$(uname | tr '[:upper:]' '[:lower:]') + + case "$ARCH" in + x86_64) JQ_ARCH="jq-linux64" ;; + aarch64) JQ_ARCH="jq-linux64" ;; # same binary works for ARM64 in most cases + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; + esac + + curl -L -o "jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" + chmod +x "jq" + echo "✅ jq installed locally at jq" +} + +# --- Check and install kubectl --- +if ! command -v kubectl >/dev/null 2>&1; then + echo "kubectl not found. Installing latest stable version locally..." + OS=$(uname | tr '[:upper:]' '[:lower:]') + KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) + curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" + chmod +x ./kubectl + # mv ./kubectl "kubectl" + echo "✅ kubectl installed locally at kubectl" +else + echo "✅ kubectl is already installed. Skipping installation." +fi + +# # --- Check and install IBM Cloud CLI --- +# if ! command -v ibmcloud >/dev/null 2>&1; then +# echo "IBM Cloud CLI not found. Installing locally..." +# install_ibm_cli +# echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" +# else +# echo "✅ IBM Cloud CLI is already installed. Skipping installation." +# fi + +# # --- Ensure IBM Cloud Kubernetes Service CLI plugin --- +# if ! ibmcloud plugin show container-service >/dev/null 2>&1; then +# echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." +# ibmcloud plugin install container-service -f +# echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." # else -# echo "✅ kubectl is already installed. Skipping installation." +# echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." # fi -# # # --- Check and install IBM Cloud CLI --- -# # if ! command -v ibmcloud >/dev/null 2>&1; then -# # echo "IBM Cloud CLI not found. Installing locally..." -# # install_ibm_cli -# # echo "✅ IBM Cloud CLI installed locally at $LOCAL_BIN/ibmcloud" -# # else -# # echo "✅ IBM Cloud CLI is already installed. Skipping installation." -# # fi - -# # # --- Ensure IBM Cloud Kubernetes Service CLI plugin --- -# # if ! ibmcloud plugin show container-service >/dev/null 2>&1; then -# # echo "IBM Cloud Kubernetes Service CLI plugin not found. Installing..." -# # ibmcloud plugin install container-service -f -# # echo "✅ IBM Cloud Kubernetes Service CLI plugin installed successfully." -# # else -# # echo "✅ IBM Cloud Kubernetes Service CLI plugin is already installed. Skipping installation." -# # fi - -# # # --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- -# # if ! ibmcloud plugin show is >/dev/null 2>&1; then -# # echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." -# # ibmcloud plugin install is -f -# # echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." -# # else -# # echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." -# # fi - -# # --- Check and install jq --- -# if ! command -v jq >/dev/null 2>&1; then -# install_jq +# # --- Ensure IBM Cloud VPC Infrastructure Service CLI plugin --- +# if ! ibmcloud plugin show is >/dev/null 2>&1; then +# echo "IBM Cloud VPC Infrastructure Service CLI plugin not found. Installing..." +# ibmcloud plugin install is -f +# echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin installed successfully." # else -# echo "✅ jq is already installed. Skipping installation." +# echo "✅ IBM Cloud VPC Infrastructure Service CLI plugin is already installed. Skipping installation." # fi -# echo "" -# echo "🎉 All required CLI tools are installed locally:" -# # echo " - IBM Cloud CLI" -# # echo " - IBM Cloud Kubernetes Service CLI plugin" -# # echo " - IBM Cloud VPC Infrastructure Service CLI plugin" -# echo " - kubectl" -# echo " - jq" -# echo "" +# --- Check and install jq --- +if ! command -v jq >/dev/null 2>&1; then + install_jq +else + echo "✅ jq is already installed. Skipping installation." +fi + +echo "" +echo "🎉 All required CLI tools are installed locally:" +# echo " - IBM Cloud CLI" +# echo " - IBM Cloud Kubernetes Service CLI plugin" +# echo " - IBM Cloud VPC Infrastructure Service CLI plugin" +echo " - kubectl" +echo " - jq" +echo "" #!/usr/bin/env bash From b20e95444d7d4645bdeaec122355e788f587bdae Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Thu, 13 Nov 2025 14:49:23 +0530 Subject: [PATCH 21/34] test5 --- solutions/quickstart/main.tf | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index 23966b111..a21acbd89 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,21 +1,14 @@ -resource "null_resource" "custom" { - # change trigger to run every time - triggers = { - build_number = "${timestamp()}" - } - - # download kubectl - provisioner "local-exec" { - command = "bash ${path.module}/scripts/install_tools.sh" - } - - # provisioner "local-exec" { - # command = "export PATH=$PATH:$PWD && kubectl" - # } - provisioner "local-exec" { - command = "kubectl" - } -} +# resource "null_resource" "custom" { +# # change trigger to run every time +# triggers = { +# build_number = "${timestamp()}" +# } + +# # download kubectl +# provisioner "local-exec" { +# command = "bash ${path.module}/scripts/install_tools.sh" +# } +# } ####################################################################################################################### # Resource Group @@ -150,7 +143,7 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - depends_on = [null_resource.custom] + # depends_on = [null_resource.custom] source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" # version = "3.71.3" cluster_name = local.cluster_name From 9df28d0aa667eaef05599e08c407932b9b8d7d18 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Thu, 13 Nov 2025 21:10:45 +0530 Subject: [PATCH 22/34] test6 --- solutions/quickstart/main.tf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index a21acbd89..dfc914d84 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -1,14 +1,14 @@ -# resource "null_resource" "custom" { -# # change trigger to run every time -# triggers = { -# build_number = "${timestamp()}" -# } +resource "null_resource" "custom" { + # change trigger to run every time + triggers = { + build_number = "${timestamp()}" + } -# # download kubectl -# provisioner "local-exec" { -# command = "bash ${path.module}/scripts/install_tools.sh" -# } -# } + # download kubectl + provisioner "local-exec" { + command = "ls /tmp" + } +} ####################################################################################################################### # Resource Group From 90fecccffa7ff9c289adee06ae7f3424f8cfa0da Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Thu, 13 Nov 2025 21:15:54 +0530 Subject: [PATCH 23/34] tmp test --- solutions/quickstart/main.tf | 6 +-- solutions/quickstart/scripts/install_tools.sh | 42 +------------------ 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/solutions/quickstart/main.tf b/solutions/quickstart/main.tf index dfc914d84..46ab917bb 100644 --- a/solutions/quickstart/main.tf +++ b/solutions/quickstart/main.tf @@ -6,7 +6,7 @@ resource "null_resource" "custom" { # download kubectl provisioner "local-exec" { - command = "ls /tmp" + command = "${path.module}/scripts/install_tools.sh" } } @@ -143,8 +143,8 @@ locals { # OCP VPC cluster (single zone) ######################################################################################################################## module "ocp_base" { - # depends_on = [null_resource.custom] - source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" + depends_on = [null_resource.custom] + source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=scr" # version = "3.71.3" cluster_name = local.cluster_name resource_group_id = module.resource_group.resource_group_id diff --git a/solutions/quickstart/scripts/install_tools.sh b/solutions/quickstart/scripts/install_tools.sh index ddb1bb0b4..0d8c12016 100755 --- a/solutions/quickstart/scripts/install_tools.sh +++ b/solutions/quickstart/scripts/install_tools.sh @@ -137,6 +137,7 @@ install_jq() { curl -L -o "jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/${JQ_ARCH}" chmod +x "jq" + mv ./jq "/tmp/jq" echo "✅ jq installed locally at jq" } @@ -147,7 +148,7 @@ if ! command -v kubectl >/dev/null 2>&1; then KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) curl -LO "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${OS}/amd64/kubectl" chmod +x ./kubectl - # mv ./kubectl "kubectl" + mv ./kubectl "/tmp/kubectl" echo "✅ kubectl installed locally at kubectl" else echo "✅ kubectl is already installed. Skipping installation." @@ -195,42 +196,3 @@ echo "🎉 All required CLI tools are installed locally:" echo " - kubectl" echo " - jq" echo "" - - -#!/usr/bin/env bash -set -euo pipefail - -TARGET_DIR="$PWD" - -if [[ ! -d "$TARGET_DIR" ]]; then - echo "❌ Error: '$TARGET_DIR' is not a directory." - exit 1 -fi - -# --- Detect shell config file --- -if [[ -n "${ZSH_VERSION-}" ]]; then - SHELL_RC="$HOME/.zshrc" -elif [[ -n "${BASH_VERSION-}" ]]; then - SHELL_RC="$HOME/.bashrc" -else - # Fallback for unknown shells - SHELL_RC="$HOME/.bashrc" -fi - -# --- Check if already added --- -EXPORT_LINE="export PATH=\$PATH:$TARGET_DIR" - -if grep -Fxq "$EXPORT_LINE" "$SHELL_RC"; then - echo "✅ PATH already includes $TARGET_DIR in $SHELL_RC" -else - echo "" >> "$SHELL_RC" - echo "# Added by add-to-path.sh on $(date)" >> "$SHELL_RC" - echo "$EXPORT_LINE" >> "$SHELL_RC" - echo "✅ Added $TARGET_DIR to PATH in $SHELL_RC" -fi - -# --- Apply change immediately --- -# shellcheck disable=SC1090 -source "$SHELL_RC" -echo "🔁 Applied changes. Current PATH:" -echo "$PATH" From 49f4933ef4f2247f7c78b9fc043bcf4961a6f35e Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 18 Nov 2025 20:08:14 +0530 Subject: [PATCH 24/34] test --- examples/basic/main.tf | 156 +++++++++++++++++--------------- examples/basic/outputs.tf | 14 +-- examples/basic/provider.tf | 14 +-- examples/basic/scripts/hello.py | 2 + examples/basic/variables.tf | 106 +++++++++++----------- 5 files changed, 150 insertions(+), 142 deletions(-) create mode 100644 examples/basic/scripts/hello.py diff --git a/examples/basic/main.tf b/examples/basic/main.tf index dfd5cc37a..187af9ec9 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,85 +1,91 @@ -######################################################################################################################## -# Resource Group -######################################################################################################################## +# ######################################################################################################################## +# # Resource Group +# ######################################################################################################################## -module "resource_group" { - source = "terraform-ibm-modules/resource-group/ibm" - version = "1.4.0" - # if an existing resource group is not set (null) create a new one using prefix - resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null - existing_resource_group_name = var.resource_group -} +# module "resource_group" { +# source = "terraform-ibm-modules/resource-group/ibm" +# version = "1.4.0" +# # if an existing resource group is not set (null) create a new one using prefix +# resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null +# existing_resource_group_name = var.resource_group +# } -######################################################################################################################## -# VPC + Subnet + Public Gateway -# -# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow -# all traffic ingress/egress by default. -# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and -# ACLs/Security Groups for network security. -######################################################################################################################## +# ######################################################################################################################## +# # VPC + Subnet + Public Gateway +# # +# # NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow +# # all traffic ingress/egress by default. +# # For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and +# # ACLs/Security Groups for network security. +# ######################################################################################################################## -resource "ibm_is_vpc" "vpc" { - name = "${var.prefix}-vpc" - resource_group = module.resource_group.resource_group_id - address_prefix_management = "auto" - tags = var.resource_tags -} +# resource "ibm_is_vpc" "vpc" { +# name = "${var.prefix}-vpc" +# resource_group = module.resource_group.resource_group_id +# address_prefix_management = "auto" +# tags = var.resource_tags +# } -resource "ibm_is_public_gateway" "gateway" { - name = "${var.prefix}-gateway-1" - vpc = ibm_is_vpc.vpc.id - resource_group = module.resource_group.resource_group_id - zone = "${var.region}-1" -} +# resource "ibm_is_public_gateway" "gateway" { +# name = "${var.prefix}-gateway-1" +# vpc = ibm_is_vpc.vpc.id +# resource_group = module.resource_group.resource_group_id +# zone = "${var.region}-1" +# } -resource "ibm_is_subnet" "subnet_zone_1" { - name = "${var.prefix}-subnet-1" - vpc = ibm_is_vpc.vpc.id - resource_group = module.resource_group.resource_group_id - zone = "${var.region}-1" - total_ipv4_address_count = 256 - public_gateway = ibm_is_public_gateway.gateway.id -} +# resource "ibm_is_subnet" "subnet_zone_1" { +# name = "${var.prefix}-subnet-1" +# vpc = ibm_is_vpc.vpc.id +# resource_group = module.resource_group.resource_group_id +# zone = "${var.region}-1" +# total_ipv4_address_count = 256 +# public_gateway = ibm_is_public_gateway.gateway.id +# } -######################################################################################################################## -# OCP VPC cluster (single zone) -######################################################################################################################## +# ######################################################################################################################## +# # OCP VPC cluster (single zone) +# ######################################################################################################################## -locals { - cluster_vpc_subnets = { - default = [ - { - id = ibm_is_subnet.subnet_zone_1.id - cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block - zone = ibm_is_subnet.subnet_zone_1.zone - } - ] - } +# locals { +# cluster_vpc_subnets = { +# default = [ +# { +# id = ibm_is_subnet.subnet_zone_1.id +# cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block +# zone = ibm_is_subnet.subnet_zone_1.zone +# } +# ] +# } - worker_pools = [ - { - subnet_prefix = "default" - pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) - machine_type = "bx2.4x16" - workers_per_zone = 2 # minimum of 2 is allowed when using single zone - operating_system = "RHCOS" - } - ] -} +# worker_pools = [ +# { +# subnet_prefix = "default" +# pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) +# machine_type = "bx2.4x16" +# workers_per_zone = 2 # minimum of 2 is allowed when using single zone +# operating_system = "RHCOS" +# } +# ] +# } -module "ocp_base" { - source = "../.." - resource_group_id = module.resource_group.resource_group_id - region = var.region - tags = var.resource_tags - cluster_name = var.prefix - force_delete_storage = true - vpc_id = ibm_is_vpc.vpc.id - vpc_subnets = local.cluster_vpc_subnets - ocp_version = var.ocp_version - worker_pools = local.worker_pools - access_tags = var.access_tags - ocp_entitlement = var.ocp_entitlement - disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. +# module "ocp_base" { +# source = "../.." +# resource_group_id = module.resource_group.resource_group_id +# region = var.region +# tags = var.resource_tags +# cluster_name = var.prefix +# force_delete_storage = true +# vpc_id = ibm_is_vpc.vpc.id +# vpc_subnets = local.cluster_vpc_subnets +# ocp_version = var.ocp_version +# worker_pools = local.worker_pools +# access_tags = var.access_tags +# ocp_entitlement = var.ocp_entitlement +# disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. +# } + +resource "null_resource" "run_python" { + provisioner "local-exec" { + command = "python3 hello.py" + } } diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 8fc0f174c..21e039a35 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,8 +1,8 @@ -######################################################################################################################## -# Outputs -######################################################################################################################## +# ######################################################################################################################## +# # Outputs +# ######################################################################################################################## -output "cluster_name" { - value = module.ocp_base.cluster_name - description = "The name of the provisioned cluster." -} +# output "cluster_name" { +# value = module.ocp_base.cluster_name +# description = "The name of the provisioned cluster." +# } diff --git a/examples/basic/provider.tf b/examples/basic/provider.tf index 84b698505..0a17a4357 100644 --- a/examples/basic/provider.tf +++ b/examples/basic/provider.tf @@ -1,8 +1,8 @@ -######################################################################################################################## -# Provider config -######################################################################################################################## +# ######################################################################################################################## +# # Provider config +# ######################################################################################################################## -provider "ibm" { - ibmcloud_api_key = var.ibmcloud_api_key - region = var.region -} +# provider "ibm" { +# ibmcloud_api_key = var.ibmcloud_api_key +# region = var.region +# } diff --git a/examples/basic/scripts/hello.py b/examples/basic/scripts/hello.py new file mode 100644 index 000000000..47c6289a6 --- /dev/null +++ b/examples/basic/scripts/hello.py @@ -0,0 +1,2 @@ +# hello.py +print("Hello from Python inside Terraform!") diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index 1d1ff5cff..a5c76f62c 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -1,53 +1,53 @@ -######################################################################################################################## -# Input variables -######################################################################################################################## - -variable "ibmcloud_api_key" { - type = string - description = "The IBM Cloud api token" - sensitive = true -} - -variable "prefix" { - type = string - description = "Prefix for name of all resource created by this example" - validation { - error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." - condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) - } -} - -variable "region" { - type = string - description = "Region where resources are created" -} - -variable "resource_group" { - type = string - description = "An existing resource group name to use for this example, if unset a new resource group will be created" - default = null -} - -variable "resource_tags" { - type = list(string) - description = "Optional list of tags to be added to created resources" - default = [] -} - -variable "ocp_version" { - type = string - description = "Version of the OCP cluster to provision" - default = null -} - -variable "access_tags" { - type = list(string) - description = "A list of access tags to apply to the resources created by the module." - default = [] -} - -variable "ocp_entitlement" { - type = string - description = "Value that is applied to the entitlements for OCP cluster provisioning" - default = null -} +# ######################################################################################################################## +# # Input variables +# ######################################################################################################################## + +# variable "ibmcloud_api_key" { +# type = string +# description = "The IBM Cloud api token" +# sensitive = true +# } + +# variable "prefix" { +# type = string +# description = "Prefix for name of all resource created by this example" +# validation { +# error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." +# condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) +# } +# } + +# variable "region" { +# type = string +# description = "Region where resources are created" +# } + +# variable "resource_group" { +# type = string +# description = "An existing resource group name to use for this example, if unset a new resource group will be created" +# default = null +# } + +# variable "resource_tags" { +# type = list(string) +# description = "Optional list of tags to be added to created resources" +# default = [] +# } + +# variable "ocp_version" { +# type = string +# description = "Version of the OCP cluster to provision" +# default = null +# } + +# variable "access_tags" { +# type = list(string) +# description = "A list of access tags to apply to the resources created by the module." +# default = [] +# } + +# variable "ocp_entitlement" { +# type = string +# description = "Value that is applied to the entitlements for OCP cluster provisioning" +# default = null +# } From 6f7ca7d1c5d645392a48ff1c7b1483daff95b382 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 18 Nov 2025 20:09:59 +0530 Subject: [PATCH 25/34] update path --- examples/basic/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 187af9ec9..5674bd60a 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -86,6 +86,6 @@ resource "null_resource" "run_python" { provisioner "local-exec" { - command = "python3 hello.py" + command = "python3 ${path.module}/hello.py" } } From 36e5758cd036f88389e2acecc10b0ed0ec94a379 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 18 Nov 2025 20:11:43 +0530 Subject: [PATCH 26/34] path --- common-dev-assets | 2 +- examples/basic/{scripts => }/hello.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename examples/basic/{scripts => }/hello.py (100%) diff --git a/common-dev-assets b/common-dev-assets index 99aee7db0..6a351e62a 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 99aee7db0020ceb8de379eaee5d50021710656eb +Subproject commit 6a351e62a04ea8bf074d4933c86cd28671154d3b diff --git a/examples/basic/scripts/hello.py b/examples/basic/hello.py similarity index 100% rename from examples/basic/scripts/hello.py rename to examples/basic/hello.py From 07a9755f0a8278ebd3053d441853ce7d3e9620d6 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 18 Nov 2025 20:14:16 +0530 Subject: [PATCH 27/34] test --- examples/basic/hello.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/examples/basic/hello.py b/examples/basic/hello.py index 47c6289a6..b1dd64f2e 100644 --- a/examples/basic/hello.py +++ b/examples/basic/hello.py @@ -1,2 +1,19 @@ -# hello.py -print("Hello from Python inside Terraform!") +import requests +import json + +url = "https://httpbin.org/post" # Example test endpoint +payload = { + "message": "Hello from Python!" +} + +response = requests.post(url, json=payload) + +# Print HTTP status code +print("Status:", response.status_code) + +# Print JSON response (pretty formatted) +try: + data = response.json() + print(json.dumps(data, indent=4)) +except ValueError: + print("Response was not JSON.") From 17296164919775a63fae3ed0dae97790b3c6af54 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 18 Nov 2025 20:17:25 +0530 Subject: [PATCH 28/34] test4 --- examples/basic/main.tf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 5674bd60a..9919d442b 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -85,6 +85,9 @@ # } resource "null_resource" "run_python" { + triggers = { + build_number = "${timestamp()}" + } provisioner "local-exec" { command = "python3 ${path.module}/hello.py" } From bd6bfff10695d03263c33d9a3b06026655b134b1 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Tue, 18 Nov 2025 20:19:59 +0530 Subject: [PATCH 29/34] test --- examples/basic/hello.py | 46 +++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/examples/basic/hello.py b/examples/basic/hello.py index b1dd64f2e..a308513f9 100644 --- a/examples/basic/hello.py +++ b/examples/basic/hello.py @@ -1,19 +1,43 @@ -import requests +import http.client import json -url = "https://httpbin.org/post" # Example test endpoint +# Target host (no https:// prefix) +host = "httpbin.org" + +# POST path +path = "/post" + +# JSON payload payload = { - "message": "Hello from Python!" + "message": "Hello from http.client!" } -response = requests.post(url, json=payload) +# Convert payload to JSON string +body = json.dumps(payload) + +# Set headers +headers = { + "Content-Type": "application/json", + "Content-Length": str(len(body)) +} + +# Create HTTPS connection +conn = http.client.HTTPSConnection(host) + +# Send POST request +conn.request("POST", path, body, headers) + +# Get response +response = conn.getresponse() +raw_data = response.read().decode() -# Print HTTP status code -print("Status:", response.status_code) +print("Status:", response.status) +print("Raw Response:", raw_data) -# Print JSON response (pretty formatted) +# Try to parse JSON try: - data = response.json() - print(json.dumps(data, indent=4)) -except ValueError: - print("Response was not JSON.") + parsed = json.loads(raw_data) + print("\nPretty JSON:") + print(json.dumps(parsed, indent=4)) +except json.JSONDecodeError: + print("Response was not valid JSON.") From f4f37ae389d8cda7be7a150ee70993278ff5b3a4 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Wed, 26 Nov 2025 17:34:39 +0530 Subject: [PATCH 30/34] test submodule --- .gitmodules | 4 ++++ examples/basic/hello.py | 43 ----------------------------------------- examples/basic/hello.sh | 3 +++ examples/basic/main.tf | 4 ++-- examples/basic/test | 1 + 5 files changed, 10 insertions(+), 45 deletions(-) delete mode 100644 examples/basic/hello.py create mode 100755 examples/basic/hello.sh create mode 160000 examples/basic/test diff --git a/.gitmodules b/.gitmodules index 6fbc5c942..366c49c2a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,7 @@ path = common-dev-assets url = https://github.com/terraform-ibm-modules/common-dev-assets branch = main + +[submodule "examples/basic/test"] + path = examples/basic/test + url = https://github.com/Aashiq-J/test.git diff --git a/examples/basic/hello.py b/examples/basic/hello.py deleted file mode 100644 index a308513f9..000000000 --- a/examples/basic/hello.py +++ /dev/null @@ -1,43 +0,0 @@ -import http.client -import json - -# Target host (no https:// prefix) -host = "httpbin.org" - -# POST path -path = "/post" - -# JSON payload -payload = { - "message": "Hello from http.client!" -} - -# Convert payload to JSON string -body = json.dumps(payload) - -# Set headers -headers = { - "Content-Type": "application/json", - "Content-Length": str(len(body)) -} - -# Create HTTPS connection -conn = http.client.HTTPSConnection(host) - -# Send POST request -conn.request("POST", path, body, headers) - -# Get response -response = conn.getresponse() -raw_data = response.read().decode() - -print("Status:", response.status) -print("Raw Response:", raw_data) - -# Try to parse JSON -try: - parsed = json.loads(raw_data) - print("\nPretty JSON:") - print(json.dumps(parsed, indent=4)) -except json.JSONDecodeError: - print("Response was not valid JSON.") diff --git a/examples/basic/hello.sh b/examples/basic/hello.sh new file mode 100755 index 000000000..cbfffdb46 --- /dev/null +++ b/examples/basic/hello.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +source ./test/test.sh diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 9919d442b..65a4a148b 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -84,11 +84,11 @@ # disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. # } -resource "null_resource" "run_python" { +resource "null_resource" "run_bash" { triggers = { build_number = "${timestamp()}" } provisioner "local-exec" { - command = "python3 ${path.module}/hello.py" + command = "${path.module}/hello.sh" } } diff --git a/examples/basic/test b/examples/basic/test new file mode 160000 index 000000000..1668d081a --- /dev/null +++ b/examples/basic/test @@ -0,0 +1 @@ +Subproject commit 1668d081a2397ea2f5e109e6a01719d2c5d02c9e From f5132f59dbe472202e2121c975383f9bbe09532e Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Fri, 28 Nov 2025 11:03:23 +0530 Subject: [PATCH 31/34] test --- examples/basic/main.tf | 159 +++++++++++++++++------------------- examples/basic/outputs.tf | 14 ++-- examples/basic/provider.tf | 14 ++-- examples/basic/variables.tf | 106 ++++++++++++------------ 4 files changed, 142 insertions(+), 151 deletions(-) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 65a4a148b..35d02e92f 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,94 +1,85 @@ -# ######################################################################################################################## -# # Resource Group -# ######################################################################################################################## +######################################################################################################################## +# Resource Group +######################################################################################################################## -# module "resource_group" { -# source = "terraform-ibm-modules/resource-group/ibm" -# version = "1.4.0" -# # if an existing resource group is not set (null) create a new one using prefix -# resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null -# existing_resource_group_name = var.resource_group -# } - -# ######################################################################################################################## -# # VPC + Subnet + Public Gateway -# # -# # NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow -# # all traffic ingress/egress by default. -# # For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and -# # ACLs/Security Groups for network security. -# ######################################################################################################################## +module "resource_group" { + source = "terraform-ibm-modules/resource-group/ibm" + version = "1.4.0" + # if an existing resource group is not set (null) create a new one using prefix + resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null + existing_resource_group_name = var.resource_group +} -# resource "ibm_is_vpc" "vpc" { -# name = "${var.prefix}-vpc" -# resource_group = module.resource_group.resource_group_id -# address_prefix_management = "auto" -# tags = var.resource_tags -# } +######################################################################################################################## +# VPC + Subnet + Public Gateway +# +# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow +# all traffic ingress/egress by default. +# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and +# ACLs/Security Groups for network security. +######################################################################################################################## -# resource "ibm_is_public_gateway" "gateway" { -# name = "${var.prefix}-gateway-1" -# vpc = ibm_is_vpc.vpc.id -# resource_group = module.resource_group.resource_group_id -# zone = "${var.region}-1" -# } +resource "ibm_is_vpc" "vpc" { + name = "${var.prefix}-vpc" + resource_group = module.resource_group.resource_group_id + address_prefix_management = "auto" + tags = var.resource_tags +} -# resource "ibm_is_subnet" "subnet_zone_1" { -# name = "${var.prefix}-subnet-1" -# vpc = ibm_is_vpc.vpc.id -# resource_group = module.resource_group.resource_group_id -# zone = "${var.region}-1" -# total_ipv4_address_count = 256 -# public_gateway = ibm_is_public_gateway.gateway.id -# } +resource "ibm_is_public_gateway" "gateway" { + name = "${var.prefix}-gateway-1" + vpc = ibm_is_vpc.vpc.id + resource_group = module.resource_group.resource_group_id + zone = "${var.region}-1" +} -# ######################################################################################################################## -# # OCP VPC cluster (single zone) -# ######################################################################################################################## +resource "ibm_is_subnet" "subnet_zone_1" { + name = "${var.prefix}-subnet-1" + vpc = ibm_is_vpc.vpc.id + resource_group = module.resource_group.resource_group_id + zone = "${var.region}-1" + total_ipv4_address_count = 256 + public_gateway = ibm_is_public_gateway.gateway.id +} -# locals { -# cluster_vpc_subnets = { -# default = [ -# { -# id = ibm_is_subnet.subnet_zone_1.id -# cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block -# zone = ibm_is_subnet.subnet_zone_1.zone -# } -# ] -# } +######################################################################################################################## +# OCP VPC cluster (single zone) +######################################################################################################################## -# worker_pools = [ -# { -# subnet_prefix = "default" -# pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) -# machine_type = "bx2.4x16" -# workers_per_zone = 2 # minimum of 2 is allowed when using single zone -# operating_system = "RHCOS" -# } -# ] -# } +locals { + cluster_vpc_subnets = { + default = [ + { + id = ibm_is_subnet.subnet_zone_1.id + cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block + zone = ibm_is_subnet.subnet_zone_1.zone + } + ] + } -# module "ocp_base" { -# source = "../.." -# resource_group_id = module.resource_group.resource_group_id -# region = var.region -# tags = var.resource_tags -# cluster_name = var.prefix -# force_delete_storage = true -# vpc_id = ibm_is_vpc.vpc.id -# vpc_subnets = local.cluster_vpc_subnets -# ocp_version = var.ocp_version -# worker_pools = local.worker_pools -# access_tags = var.access_tags -# ocp_entitlement = var.ocp_entitlement -# disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. -# } + worker_pools = [ + { + subnet_prefix = "default" + pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) + machine_type = "bx2.4x16" + workers_per_zone = 2 # minimum of 2 is allowed when using single zone + operating_system = "RHCOS" + } + ] +} -resource "null_resource" "run_bash" { - triggers = { - build_number = "${timestamp()}" - } - provisioner "local-exec" { - command = "${path.module}/hello.sh" - } +module "ocp_base" { + source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=install-deps" + resource_group_id = module.resource_group.resource_group_id + region = var.region + tags = var.resource_tags + cluster_name = var.prefix + force_delete_storage = true + vpc_id = ibm_is_vpc.vpc.id + vpc_subnets = local.cluster_vpc_subnets + ocp_version = var.ocp_version + worker_pools = local.worker_pools + access_tags = var.access_tags + ocp_entitlement = var.ocp_entitlement + disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. } diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 21e039a35..8fc0f174c 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,8 +1,8 @@ -# ######################################################################################################################## -# # Outputs -# ######################################################################################################################## +######################################################################################################################## +# Outputs +######################################################################################################################## -# output "cluster_name" { -# value = module.ocp_base.cluster_name -# description = "The name of the provisioned cluster." -# } +output "cluster_name" { + value = module.ocp_base.cluster_name + description = "The name of the provisioned cluster." +} diff --git a/examples/basic/provider.tf b/examples/basic/provider.tf index 0a17a4357..84b698505 100644 --- a/examples/basic/provider.tf +++ b/examples/basic/provider.tf @@ -1,8 +1,8 @@ -# ######################################################################################################################## -# # Provider config -# ######################################################################################################################## +######################################################################################################################## +# Provider config +######################################################################################################################## -# provider "ibm" { -# ibmcloud_api_key = var.ibmcloud_api_key -# region = var.region -# } +provider "ibm" { + ibmcloud_api_key = var.ibmcloud_api_key + region = var.region +} diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index a5c76f62c..1d1ff5cff 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -1,53 +1,53 @@ -# ######################################################################################################################## -# # Input variables -# ######################################################################################################################## - -# variable "ibmcloud_api_key" { -# type = string -# description = "The IBM Cloud api token" -# sensitive = true -# } - -# variable "prefix" { -# type = string -# description = "Prefix for name of all resource created by this example" -# validation { -# error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." -# condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) -# } -# } - -# variable "region" { -# type = string -# description = "Region where resources are created" -# } - -# variable "resource_group" { -# type = string -# description = "An existing resource group name to use for this example, if unset a new resource group will be created" -# default = null -# } - -# variable "resource_tags" { -# type = list(string) -# description = "Optional list of tags to be added to created resources" -# default = [] -# } - -# variable "ocp_version" { -# type = string -# description = "Version of the OCP cluster to provision" -# default = null -# } - -# variable "access_tags" { -# type = list(string) -# description = "A list of access tags to apply to the resources created by the module." -# default = [] -# } - -# variable "ocp_entitlement" { -# type = string -# description = "Value that is applied to the entitlements for OCP cluster provisioning" -# default = null -# } +######################################################################################################################## +# Input variables +######################################################################################################################## + +variable "ibmcloud_api_key" { + type = string + description = "The IBM Cloud api token" + sensitive = true +} + +variable "prefix" { + type = string + description = "Prefix for name of all resource created by this example" + validation { + error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." + condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) + } +} + +variable "region" { + type = string + description = "Region where resources are created" +} + +variable "resource_group" { + type = string + description = "An existing resource group name to use for this example, if unset a new resource group will be created" + default = null +} + +variable "resource_tags" { + type = list(string) + description = "Optional list of tags to be added to created resources" + default = [] +} + +variable "ocp_version" { + type = string + description = "Version of the OCP cluster to provision" + default = null +} + +variable "access_tags" { + type = list(string) + description = "A list of access tags to apply to the resources created by the module." + default = [] +} + +variable "ocp_entitlement" { + type = string + description = "Value that is applied to the entitlements for OCP cluster provisioning" + default = null +} From beeca2e13d0a6151884f743020f90f588d91d8ce Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Fri, 28 Nov 2025 15:06:33 +0530 Subject: [PATCH 32/34] test2 --- common-dev-assets | 2 +- examples/basic/main.tf | 159 +++++++++++++++++++----------------- examples/basic/outputs.tf | 14 ++-- examples/basic/provider.tf | 14 ++-- examples/basic/test | 1 - examples/basic/variables.tf | 106 ++++++++++++------------ 6 files changed, 152 insertions(+), 144 deletions(-) delete mode 160000 examples/basic/test diff --git a/common-dev-assets b/common-dev-assets index 6a351e62a..fa67327af 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 6a351e62a04ea8bf074d4933c86cd28671154d3b +Subproject commit fa67327af1a57a7a9094adb0432e44b1478f25b0 diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 35d02e92f..4bcace111 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,85 +1,94 @@ -######################################################################################################################## -# Resource Group -######################################################################################################################## +# ######################################################################################################################## +# # Resource Group +# ######################################################################################################################## -module "resource_group" { - source = "terraform-ibm-modules/resource-group/ibm" - version = "1.4.0" - # if an existing resource group is not set (null) create a new one using prefix - resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null - existing_resource_group_name = var.resource_group -} +# module "resource_group" { +# source = "terraform-ibm-modules/resource-group/ibm" +# version = "1.4.0" +# # if an existing resource group is not set (null) create a new one using prefix +# resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null +# existing_resource_group_name = var.resource_group +# } -######################################################################################################################## -# VPC + Subnet + Public Gateway -# -# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow -# all traffic ingress/egress by default. -# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and -# ACLs/Security Groups for network security. -######################################################################################################################## +# ######################################################################################################################## +# # VPC + Subnet + Public Gateway +# # +# # NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow +# # all traffic ingress/egress by default. +# # For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and +# # ACLs/Security Groups for network security. +# ######################################################################################################################## -resource "ibm_is_vpc" "vpc" { - name = "${var.prefix}-vpc" - resource_group = module.resource_group.resource_group_id - address_prefix_management = "auto" - tags = var.resource_tags -} +# resource "ibm_is_vpc" "vpc" { +# name = "${var.prefix}-vpc" +# resource_group = module.resource_group.resource_group_id +# address_prefix_management = "auto" +# tags = var.resource_tags +# } -resource "ibm_is_public_gateway" "gateway" { - name = "${var.prefix}-gateway-1" - vpc = ibm_is_vpc.vpc.id - resource_group = module.resource_group.resource_group_id - zone = "${var.region}-1" -} +# resource "ibm_is_public_gateway" "gateway" { +# name = "${var.prefix}-gateway-1" +# vpc = ibm_is_vpc.vpc.id +# resource_group = module.resource_group.resource_group_id +# zone = "${var.region}-1" +# } -resource "ibm_is_subnet" "subnet_zone_1" { - name = "${var.prefix}-subnet-1" - vpc = ibm_is_vpc.vpc.id - resource_group = module.resource_group.resource_group_id - zone = "${var.region}-1" - total_ipv4_address_count = 256 - public_gateway = ibm_is_public_gateway.gateway.id -} +# resource "ibm_is_subnet" "subnet_zone_1" { +# name = "${var.prefix}-subnet-1" +# vpc = ibm_is_vpc.vpc.id +# resource_group = module.resource_group.resource_group_id +# zone = "${var.region}-1" +# total_ipv4_address_count = 256 +# public_gateway = ibm_is_public_gateway.gateway.id +# } -######################################################################################################################## -# OCP VPC cluster (single zone) -######################################################################################################################## +# ######################################################################################################################## +# # OCP VPC cluster (single zone) +# ######################################################################################################################## -locals { - cluster_vpc_subnets = { - default = [ - { - id = ibm_is_subnet.subnet_zone_1.id - cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block - zone = ibm_is_subnet.subnet_zone_1.zone - } - ] - } +# locals { +# cluster_vpc_subnets = { +# default = [ +# { +# id = ibm_is_subnet.subnet_zone_1.id +# cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block +# zone = ibm_is_subnet.subnet_zone_1.zone +# } +# ] +# } - worker_pools = [ - { - subnet_prefix = "default" - pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) - machine_type = "bx2.4x16" - workers_per_zone = 2 # minimum of 2 is allowed when using single zone - operating_system = "RHCOS" - } - ] -} +# worker_pools = [ +# { +# subnet_prefix = "default" +# pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849) +# machine_type = "bx2.4x16" +# workers_per_zone = 2 # minimum of 2 is allowed when using single zone +# operating_system = "RHCOS" +# } +# ] +# } + +# module "ocp_base" { +# source = "../.." +# resource_group_id = module.resource_group.resource_group_id +# region = var.region +# tags = var.resource_tags +# cluster_name = var.prefix +# force_delete_storage = true +# vpc_id = ibm_is_vpc.vpc.id +# vpc_subnets = local.cluster_vpc_subnets +# ocp_version = var.ocp_version +# worker_pools = local.worker_pools +# access_tags = var.access_tags +# ocp_entitlement = var.ocp_entitlement +# disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. +# } -module "ocp_base" { - source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc.git?ref=install-deps" - resource_group_id = module.resource_group.resource_group_id - region = var.region - tags = var.resource_tags - cluster_name = var.prefix - force_delete_storage = true - vpc_id = ibm_is_vpc.vpc.id - vpc_subnets = local.cluster_vpc_subnets - ocp_version = var.ocp_version - worker_pools = local.worker_pools - access_tags = var.access_tags - ocp_entitlement = var.ocp_entitlement - disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console. +resource "null_resource" "run_python" { + triggers = { + build_number = "${timestamp()}" + } + provisioner "local-exec" { + command = "compgen -c | sort -V" + } } diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 8fc0f174c..21e039a35 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,8 +1,8 @@ -######################################################################################################################## -# Outputs -######################################################################################################################## +# ######################################################################################################################## +# # Outputs +# ######################################################################################################################## -output "cluster_name" { - value = module.ocp_base.cluster_name - description = "The name of the provisioned cluster." -} +# output "cluster_name" { +# value = module.ocp_base.cluster_name +# description = "The name of the provisioned cluster." +# } diff --git a/examples/basic/provider.tf b/examples/basic/provider.tf index 84b698505..0a17a4357 100644 --- a/examples/basic/provider.tf +++ b/examples/basic/provider.tf @@ -1,8 +1,8 @@ -######################################################################################################################## -# Provider config -######################################################################################################################## +# ######################################################################################################################## +# # Provider config +# ######################################################################################################################## -provider "ibm" { - ibmcloud_api_key = var.ibmcloud_api_key - region = var.region -} +# provider "ibm" { +# ibmcloud_api_key = var.ibmcloud_api_key +# region = var.region +# } diff --git a/examples/basic/test b/examples/basic/test deleted file mode 160000 index 1668d081a..000000000 --- a/examples/basic/test +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1668d081a2397ea2f5e109e6a01719d2c5d02c9e diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index 1d1ff5cff..a5c76f62c 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -1,53 +1,53 @@ -######################################################################################################################## -# Input variables -######################################################################################################################## - -variable "ibmcloud_api_key" { - type = string - description = "The IBM Cloud api token" - sensitive = true -} - -variable "prefix" { - type = string - description = "Prefix for name of all resource created by this example" - validation { - error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." - condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) - } -} - -variable "region" { - type = string - description = "Region where resources are created" -} - -variable "resource_group" { - type = string - description = "An existing resource group name to use for this example, if unset a new resource group will be created" - default = null -} - -variable "resource_tags" { - type = list(string) - description = "Optional list of tags to be added to created resources" - default = [] -} - -variable "ocp_version" { - type = string - description = "Version of the OCP cluster to provision" - default = null -} - -variable "access_tags" { - type = list(string) - description = "A list of access tags to apply to the resources created by the module." - default = [] -} - -variable "ocp_entitlement" { - type = string - description = "Value that is applied to the entitlements for OCP cluster provisioning" - default = null -} +# ######################################################################################################################## +# # Input variables +# ######################################################################################################################## + +# variable "ibmcloud_api_key" { +# type = string +# description = "The IBM Cloud api token" +# sensitive = true +# } + +# variable "prefix" { +# type = string +# description = "Prefix for name of all resource created by this example" +# validation { +# error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters." +# condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix)) +# } +# } + +# variable "region" { +# type = string +# description = "Region where resources are created" +# } + +# variable "resource_group" { +# type = string +# description = "An existing resource group name to use for this example, if unset a new resource group will be created" +# default = null +# } + +# variable "resource_tags" { +# type = list(string) +# description = "Optional list of tags to be added to created resources" +# default = [] +# } + +# variable "ocp_version" { +# type = string +# description = "Version of the OCP cluster to provision" +# default = null +# } + +# variable "access_tags" { +# type = list(string) +# description = "A list of access tags to apply to the resources created by the module." +# default = [] +# } + +# variable "ocp_entitlement" { +# type = string +# description = "Value that is applied to the entitlements for OCP cluster provisioning" +# default = null +# } From a0c408e625333655f4bf883e5fcc1271d023fc67 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Fri, 28 Nov 2025 15:12:15 +0530 Subject: [PATCH 33/34] test3 --- examples/basic/provider.tf | 7 +++---- examples/basic/variables.tf | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/basic/provider.tf b/examples/basic/provider.tf index 0a17a4357..dc98350ce 100644 --- a/examples/basic/provider.tf +++ b/examples/basic/provider.tf @@ -2,7 +2,6 @@ # # Provider config # ######################################################################################################################## -# provider "ibm" { -# ibmcloud_api_key = var.ibmcloud_api_key -# region = var.region -# } +provider "ibm" { + ibmcloud_api_key = var.ibmcloud_api_key +} diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index a5c76f62c..64f9ce613 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -2,11 +2,11 @@ # # Input variables # ######################################################################################################################## -# variable "ibmcloud_api_key" { -# type = string -# description = "The IBM Cloud api token" -# sensitive = true -# } +variable "ibmcloud_api_key" { + type = string + description = "The IBM Cloud api token" + sensitive = true +} # variable "prefix" { # type = string From d9cd9b809142087ced5ca3f0f7cc281bb5095d50 Mon Sep 17 00:00:00 2001 From: "aashiq.jacob@ibm.com" Date: Fri, 28 Nov 2025 15:13:56 +0530 Subject: [PATCH 34/34] test4 --- examples/basic/outputs.tf | 14 +++++++------- scripts/common-bash-library | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) create mode 160000 scripts/common-bash-library diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 21e039a35..0b979a41a 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,8 +1,8 @@ -# ######################################################################################################################## -# # Outputs -# ######################################################################################################################## +######################################################################################################################## +# Outputs +######################################################################################################################## -# output "cluster_name" { -# value = module.ocp_base.cluster_name -# description = "The name of the provisioned cluster." -# } +output "cluster_name" { + value = null_resource.run_python.id + description = "The name of the provisioned cluster." +} diff --git a/scripts/common-bash-library b/scripts/common-bash-library new file mode 160000 index 000000000..cb81dbaa9 --- /dev/null +++ b/scripts/common-bash-library @@ -0,0 +1 @@ +Subproject commit cb81dbaa9886bbf23e1482f6b9b6529af54e5b5d