diff --git a/deploy/README.md b/deploy/README.md index f910805..44c886d 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -106,6 +106,60 @@ $ make force-stop $ make destroy ``` +### Managing Multiple AWS Metal Machines + +The tooling supports deploying and managing multiple AWS metal machines simultaneously. This is useful for testing different configurations or running multiple clusters in parallel. + +#### How It Works + +Two key variables in `aws-hypervisor/instance.env` control which machine you're working with: +- **`SHARED_DIR`**: The directory where instance data is stored (e.g., `instance-data-machine1`) +- **`STACK_NAME`**: The CloudFormation stack name (e.g., `machine1`) + +Each unique combination of these variables represents a separate AWS metal machine deployment. + +#### Workflow for Multiple Machines + +**Initial deployment of a machine:** +```bash +# Edit instance.env to set your first deployment +export SHARED_DIR=instance-data-machine1 +export STACK_NAME=machine1 + +# Deploy the machine +$ make deploy +``` + +**Deploy a second machine:** +```bash +# Edit instance.env with new values +export SHARED_DIR=instance-data-machine2 +export STACK_NAME=machine2 + +# Deploy the second machine +$ make deploy +``` + +**Switch between machines:** + +To switch which machine you're working with, simply update the two variables in `instance.env` and update the inventory: + +```bash +# Edit instance.env to point to the machine you want +export SHARED_DIR=instance-data-machine1 +export STACK_NAME=machine1 + +# Update SSH configuration to point to this machine +$ make inventory + +# Now use any command normally (it will operate on machine1) +$ make fencing-ipi +$ make ssh +$ make stop +``` + +This allows you to seamlessly switch between different AWS metal machines without any additional configuration changes. + ### OpenShift Cluster Management When running OpenShift clusters on the instance (using dev-scripts), you have several options for managing cluster lifecycle: diff --git a/deploy/aws-hypervisor/.gitignore b/deploy/aws-hypervisor/.gitignore index 8b0059a..a91077b 100644 --- a/deploy/aws-hypervisor/.gitignore +++ b/deploy/aws-hypervisor/.gitignore @@ -1,3 +1,3 @@ instance.env -instance-data +instance-data*/ pull_secret.json \ No newline at end of file diff --git a/deploy/openshift-clusters/roles/dev-scripts/install-dev/vars/main.yml b/deploy/openshift-clusters/roles/dev-scripts/install-dev/vars/main.yml index 4379017..bd01bf3 100644 --- a/deploy/openshift-clusters/roles/dev-scripts/install-dev/vars/main.yml +++ b/deploy/openshift-clusters/roles/dev-scripts/install-dev/vars/main.yml @@ -14,5 +14,5 @@ make_target: ipi: "all" agent: "agent" # Cluster state management variables -cluster_state_dir: "../aws-hypervisor/instance-data" +cluster_state_dir: "../aws-hypervisor/{{ lookup('env', 'SHARED_DIR') }}" cluster_state_filename: "cluster-vm-state.json" diff --git a/deploy/openshift-clusters/scripts/clean.sh b/deploy/openshift-clusters/scripts/clean.sh index 783845b..a905fca 100755 --- a/deploy/openshift-clusters/scripts/clean.sh +++ b/deploy/openshift-clusters/scripts/clean.sh @@ -9,8 +9,11 @@ set -o nounset set -o errexit set -o pipefail +# shellcheck source=/dev/null +source "${DEPLOY_DIR}/aws-hypervisor/instance.env" + # Check if instance data exists -if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/instance-data/aws-instance-id" ]]; then +if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/${SHARED_DIR}/aws-instance-id" ]]; then echo "Error: No instance found. Please run 'make deploy' first." exit 1 fi diff --git a/deploy/openshift-clusters/scripts/deploy-arbiter-agent.sh b/deploy/openshift-clusters/scripts/deploy-arbiter-agent.sh index 65b8474..c5d3545 100755 --- a/deploy/openshift-clusters/scripts/deploy-arbiter-agent.sh +++ b/deploy/openshift-clusters/scripts/deploy-arbiter-agent.sh @@ -9,8 +9,11 @@ set -o nounset set -o errexit set -o pipefail +# shellcheck source=/dev/null +source "${DEPLOY_DIR}/aws-hypervisor/instance.env" + # Check if instance data exists -if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/instance-data/aws-instance-id" ]]; then +if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/${SHARED_DIR}/aws-instance-id" ]]; then echo "Error: No instance found. Please run 'make deploy' first." exit 1 fi diff --git a/deploy/openshift-clusters/scripts/deploy-arbiter-ipi.sh b/deploy/openshift-clusters/scripts/deploy-arbiter-ipi.sh index 50b9fe2..7b44175 100755 --- a/deploy/openshift-clusters/scripts/deploy-arbiter-ipi.sh +++ b/deploy/openshift-clusters/scripts/deploy-arbiter-ipi.sh @@ -9,8 +9,11 @@ set -o nounset set -o errexit set -o pipefail +# shellcheck source=/dev/null +source "${DEPLOY_DIR}/aws-hypervisor/instance.env" + # Check if instance data exists -if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/instance-data/aws-instance-id" ]]; then +if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/${SHARED_DIR}/aws-instance-id" ]]; then echo "Error: No instance found. Please run 'make deploy' first." exit 1 fi diff --git a/deploy/openshift-clusters/scripts/deploy-fencing-agent.sh b/deploy/openshift-clusters/scripts/deploy-fencing-agent.sh index bb60257..1322bab 100755 --- a/deploy/openshift-clusters/scripts/deploy-fencing-agent.sh +++ b/deploy/openshift-clusters/scripts/deploy-fencing-agent.sh @@ -9,8 +9,11 @@ set -o nounset set -o errexit set -o pipefail +# shellcheck source=/dev/null +source "${DEPLOY_DIR}/aws-hypervisor/instance.env" + # Check if instance data exists -if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/instance-data/aws-instance-id" ]]; then +if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/${SHARED_DIR}/aws-instance-id" ]]; then echo "Error: No instance found. Please run 'make deploy' first." exit 1 fi diff --git a/deploy/openshift-clusters/scripts/deploy-fencing-ipi.sh b/deploy/openshift-clusters/scripts/deploy-fencing-ipi.sh index 967da8c..30b09d4 100755 --- a/deploy/openshift-clusters/scripts/deploy-fencing-ipi.sh +++ b/deploy/openshift-clusters/scripts/deploy-fencing-ipi.sh @@ -9,8 +9,11 @@ set -o nounset set -o errexit set -o pipefail +# shellcheck source=/dev/null +source "${DEPLOY_DIR}/aws-hypervisor/instance.env" + # Check if instance data exists -if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/instance-data/aws-instance-id" ]]; then +if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/${SHARED_DIR}/aws-instance-id" ]]; then echo "Error: No instance found. Please run 'make deploy' first." exit 1 fi diff --git a/deploy/openshift-clusters/scripts/full-clean.sh b/deploy/openshift-clusters/scripts/full-clean.sh index c630b96..afbf075 100755 --- a/deploy/openshift-clusters/scripts/full-clean.sh +++ b/deploy/openshift-clusters/scripts/full-clean.sh @@ -9,8 +9,11 @@ set -o nounset set -o errexit set -o pipefail +# shellcheck source=/dev/null +source "${DEPLOY_DIR}/aws-hypervisor/instance.env" + # Check if instance data exists -if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/instance-data/aws-instance-id" ]]; then +if [[ ! -f "${DEPLOY_DIR}/aws-hypervisor/${SHARED_DIR}/aws-instance-id" ]]; then echo "Error: No instance found. Please run 'make deploy' first." exit 1 fi