Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include "root" {
path = find_in_parent_folders()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../000-ibm-fs-account-setup"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../100-ibm-fs-shared-services"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../110-ibm-fs-edge-vpc"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../110-ibm-fs-edge-vpc"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../120-ibm-fs-management-vpc"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../130-ibm-fs-management-vpc-openshift"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../130-ibm-fs-management-vpc-openshift"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include "root" {
path = find_in_parent_folders()
}

dependencies {
paths = ["../150-ibm-fs-workload-vpc-openshift"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Add the values for the Credentials to access the IBM Cloud
# Instructions to access this information can be found in the README.MD
# This is a template file and the ./launch.sh script looks for a file based on this template named credentials.properties
ibmcloud.api.key=""
# NOTE: Do not use quotes around the values
TF_VAR_ibmcloud_api_key=
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ fi
# Help Scripts for applying and destroying
cp "${SCRIPT_DIR}/apply-all.sh" "${WORKSPACE_DIR}/apply-all.sh"
cp "${SCRIPT_DIR}/destroy-all.sh" "${WORKSPACE_DIR}/destroy-all.sh"
cp "${SCRIPT_DIR}/terragrunt.hcl" "${WORKSPACE_DIR}/terragrunt.hcl"
cp "${SCRIPT_DIR}/check-vpn.sh" "${WORKSPACE_DIR}/check-vpn.sh"

if [[ -f "${SCRIPT_DIR}/terragrunt.hcl" ]]; then
cp "${SCRIPT_DIR}/terragrunt.hcl" "${WORKSPACE_DIR}/terragrunt.hcl"
fi

ALL_ARCH="000|100|110|120|130|140|150|160|165"

Expand Down
10 changes: 10 additions & 0 deletions boms/infrastructure/ibmcloud/openshift-fs/files/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
skip = true

terraform {
source = "."

before_hook "vpn" {
commands = ["apply", "plan", "destroy"]
execute = ["${get_parent_terragrunt_dir()}/check-vpn.sh"]
}
}
43 changes: 12 additions & 31 deletions boms/infrastructure/ibmcloud/openshift-fs/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# IBM Ecosystem Lab Team
# Install iascable and run this script to produce an target public source repository

GENERATE_TARGET="$1"
GENERATE_DESTINATION="$2"
GENERATE_DESTINATION="$1"

if ! command -v iascable 1> /dev/null 2> /dev/null; then
echo "iascable cli not found" >&2
Expand All @@ -21,41 +20,23 @@ if [[ "${IASCABLE_MAJOR_VERSION}" -le 2 ]] && [[ "${IASCABLE_MINOR_VERSION}" -le
exit 1
fi

if [[ -z "$GENERATE_TARGET" ]]
then
GENERATE_TARGET="all"
fi

if [[ -z "${GENERATE_DESTINATION}" ]]; then
GENERATE_DESTINATION="../../../../automation-fscloud"
fi

mkdir -p "${GENERATE_DESTINATION}"

case "$GENERATE_TARGET" in
"all" | "infra" | "infrastructure" | "i")
iascable build \
-i ./000-ibm-fs-account-setup.yaml \
-i ./100-ibm-fs-shared-services.yaml \
-i ./110-ibm-fs-edge-vpc.yaml \
-i ./120-ibm-fs-management-vpc.yaml \
-i ./130-ibm-fs-management-vpc-openshift.yaml \
-i ./140-ibm-fs-workload-vpc.yaml \
-i ./150-ibm-fs-workload-vpc-openshift.yaml \
-o "${GENERATE_DESTINATION}"
;;
esac


case "$GENERATE_TARGET" in
"all" | "software" | "s")
iascable build \
-i ./160-ibm-fs-openshift-dev-tools.yaml \
-i ./165-ibm-fs-openshift-workload.yaml \
-i ./170-ibm-fs-openshift-gitops.yaml \
-o "${GENERATE_DESTINATION}"
;;
esac
iascable build \
-i ./000-ibm-fs-account-setup.yaml \
-i ./100-ibm-fs-shared-services.yaml \
-i ./110-ibm-fs-edge-vpc.yaml \
-i ./120-ibm-fs-management-vpc.yaml \
-i ./130-ibm-fs-management-vpc-openshift.yaml \
-i ./140-ibm-fs-workload-vpc.yaml \
-i ./150-ibm-fs-workload-vpc-openshift.yaml \
-i ./160-ibm-fs-openshift-dev-tools.yaml \
-i ./165-ibm-fs-openshift-workload.yaml \
-o "${GENERATE_DESTINATION}"

cp -R -L ./files/* "${GENERATE_DESTINATION}"

41 changes: 9 additions & 32 deletions common-files/apply-all.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,26 @@
#!/usr/bin/env bash

#if command -v terragrunt 1> /dev/null 2> /dev/null; then
# echo "y" | terragrunt run-all apply || exit 1
# exit
#fi
SCRIPT_DIR=$(cd $(dirname $0); pwd -P)

CI="$1"
if command -v terragrunt 1> /dev/null 2> /dev/null; then
echo "y" | terragrunt run-all apply || exit 1
exit
fi

find . -type d -maxdepth 1 | grep -vE "[.]/[.].*" | grep -vE "^[.]$" | grep -v workspace | sort | \
while read dir;
do
name=$(echo "$dir" | sed -E "s~[.]/(.*)~\1~g")

VPN_REQUIRED=$(grep "vpn/required" ./${name}/bom.yaml | sed -E "s~[^:]+: [\"'](.*)[\"']~\1~g")
cd "${name}"

if [[ "${VPN_REQUIRED}" == "true" ]]; then
RUNNING_PROCESSES=$(ps -ef)
VPN_RUNNING=$(echo "${RUNNING_PROCESSES}" | grep "openvpn --config")

if [[ -n "${VPN_RUNNING}" ]]; then
echo "VPN required but it is already running"
elif command -v openvpn 1> /dev/null 2> /dev/null; then
OVPN_FILE=$(find . -name "*.ovpn" | head -1)

if [[ -z "${OVPN_FILE}" ]]; then
echo "VPN profile not found. Skipping ${name}"
continue
fi

echo "Connecting to vpn with profile: ${OVPN_FILE}"
sudo openvpn --config "${OVPN_FILE}" &
elif [[ -n "${CI}" ]]; then
echo "VPN connection required but unable to create the connection. Skipping..."
continue
else
echo "Please connect to your vpn instance using the .ovpn profile within the 110-ibm-fs-edge-vpc directory and press ENTER to proceed."
read throwaway
fi
if [[ -f "${SCRIPT_DIR}/check-vpn.sh" ]]; then
"${SCRIPT_DIR}/check-vpn.sh"
fi

echo "***** Applying ${name} *****"

cd "${name}" && \
terraform init && \
terraform init && \
terraform apply -auto-approve && \
cd - 1> /dev/null || \
exit 1
done
34 changes: 34 additions & 0 deletions common-files/check-vpn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

ROOT_DIRECTORY=$(cd $(dirname "$0"); pwd -P)
BOM_DIRECTORY="${PWD}"

VPN_REQUIRED=$(grep "vpn/required" "${BOM_DIRECTORY}/bom.yaml" | sed -E "s~[^:]+: [\"'](.*)[\"']~\1~g")

if [[ "${VPN_REQUIRED}" == "true" ]]; then
RUNNING_PROCESSES=$(ps -ef)
VPN_RUNNING=$(echo "${RUNNING_PROCESSES}" | grep "openvpn --config")

if [[ -n "${VPN_RUNNING}" ]]; then
echo "VPN required but it is already running"
elif command -v openvpn 1> /dev/null 2> /dev/null; then
OVPN_FILE=$(find "${ROOT_DIRECTORY}" -name "*.ovpn" | head -1)

if [[ -z "${OVPN_FILE}" ]]; then
echo "VPN profile not found."
exit 1
fi

echo "Connecting to vpn with profile: ${OVPN_FILE}"
if [[ "${UID}" -eq 0 ]]; then
openvpn --config "${OVPN_FILE}" &
else
sudo openvpn --config "${OVPN_FILE}" &
fi
else
echo "VPN connection required but unable to create the connection automatically. Please connect to your vpn instance using the .ovpn profile within the 110-ibm-fs-edge-vpc directory and re-run apply-all.sh."
exit 1
fi
else
echo "VPN not required"
fi
27 changes: 6 additions & 21 deletions common-files/destroy-all.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash

#if command -v terragrunt 1> /dev/null 2> /dev/null; then
# echo "y" | terragrunt run-all destroy || exit 1
# exit
#fi
SCRIPT_DIR=$(cd $(dirname $0); pwd -P)

CI="$1"
if command -v terragrunt 1> /dev/null 2> /dev/null; then
echo "y" | terragrunt run-all destroy || exit 1
exit
fi

find . -type d -maxdepth 1 | grep -vE "[.]/[.].*" | grep -vE "^[.]$" | grep -v workspace | sort -r | \
while read dir;
Expand All @@ -20,22 +20,7 @@ do
VPN_REQUIRED=$(grep "vpn/required" ./${name}/bom.yaml | sed -E "s~[^:]+: \"(.*)\"~\1~g")

if [[ "${VPN_REQUIRED}" == "true" ]]; then
RUNNING_PROCESSES=$(ps -ef)
VPN_RUNNING=$(echo "${RUNNING_PROCESSES}" | grep "openvpn --config")

if [[ -n "${VPN_RUNNING}" ]]; then
echo "VPN required but it is already running"
elif command -v openvpn 1> /dev/null 2> /dev/null; then
OVPN_FILE=$(find . -name "*.ovpn" | head -1)
echo "Connecting to vpn with profile: ${OVPN_FILE}"
sudo openvpn --config "${OVPN_FILE}" &
elif [[ -n "${CI}" ]]; then
echo "VPN connection required but unable to create the connection. Skipping..."
continue
else
echo "Please connect to your vpn instance using the .ovpn profile within the 110-ibm-fs-edge-vpc directory and press ENTER to proceed."
read throwaway
fi
"${SCRIPT_DIR}/start-vpn.sh"
fi

echo "***** Destroying ${name} *****"
Expand Down
2 changes: 1 addition & 1 deletion common-files/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ then
fi
fi

DOCKER_IMAGE="quay.io/cloudnativetoolkit/cli-tools:v1.1-v1.8.1"
DOCKER_IMAGE="quay.io/cloudnativetoolkit/cli-tools:v1.1-v1.8.2"

SUFFIX=$(echo $(basename ${SCRIPT_DIR}) | base64 | sed -E "s/[^a-zA-Z0-9_.-]//g" | sed -E "s/.*(.{5})/\1/g")
CONTAINER_NAME="cli-tools-${SUFFIX}"
Expand Down