sync
This commit is contained in:
82
ansible/scripts/migrate-dns-references.sh
Normal file
82
ansible/scripts/migrate-dns-references.sh
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Migration script to update DNS entry references
|
||||
# This script helps migrate from the old add_technitium_dns_entry.yml to the new modular approach
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
print_status() {
|
||||
local status=$1
|
||||
local message=$2
|
||||
case $status in
|
||||
"INFO")
|
||||
echo -e "${BLUE}ℹ️ INFO${NC}: $message"
|
||||
;;
|
||||
"SUCCESS")
|
||||
echo -e "${GREEN}✅ SUCCESS${NC}: $message"
|
||||
;;
|
||||
"ERROR")
|
||||
echo -e "${RED}❌ ERROR${NC}: $message"
|
||||
;;
|
||||
"WARN")
|
||||
echo -e "${YELLOW}⚠️ WARN${NC}: $message"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
print_status "INFO" "Migrating DNS entry references to modular approach..."
|
||||
|
||||
# Search for references to the old playbook
|
||||
OLD_PLAYBOOK="add_technitium_dns_entry.yml"
|
||||
NEW_PLAYBOOK="add_dns_entry.yml"
|
||||
|
||||
# Find all YAML files that might reference the old playbook
|
||||
YAML_FILES=$(find . -name "*.yml" -type f | grep -v ".git")
|
||||
|
||||
FOUND_REFERENCES=0
|
||||
|
||||
for file in $YAML_FILES; do
|
||||
if grep -q "$OLD_PLAYBOOK" "$file" 2>/dev/null; then
|
||||
print_status "WARN" "Found reference in: $file"
|
||||
FOUND_REFERENCES=$((FOUND_REFERENCES + 1))
|
||||
|
||||
# Show the context
|
||||
echo " Context:"
|
||||
grep -n -B2 -A2 "$OLD_PLAYBOOK" "$file" | sed 's/^/ /'
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $FOUND_REFERENCES -eq 0 ]; then
|
||||
print_status "SUCCESS" "No references to $OLD_PLAYBOOK found"
|
||||
else
|
||||
print_status "INFO" "Found $FOUND_REFERENCES references to migrate"
|
||||
print_status "INFO" "Migration options:"
|
||||
echo ""
|
||||
echo "1. Replace playbook imports:"
|
||||
echo " OLD: - import_playbook: $OLD_PLAYBOOK"
|
||||
echo " NEW: - import_playbook: $NEW_PLAYBOOK"
|
||||
echo ""
|
||||
echo "2. Use task includes in roles:"
|
||||
echo " - ansible.builtin.include_tasks: tasks/add_technitium_dns_entry.yml"
|
||||
echo ""
|
||||
echo "3. Use the dns-manager role:"
|
||||
echo " - ansible.builtin.include_role:"
|
||||
echo " name: dns-manager"
|
||||
fi
|
||||
|
||||
# Check if the old playbook exists and suggest backup
|
||||
if [ -f "playbooks/$OLD_PLAYBOOK" ]; then
|
||||
print_status "INFO" "Old playbook exists at: playbooks/$OLD_PLAYBOOK"
|
||||
print_status "INFO" "Consider backing it up before removing:"
|
||||
echo " mv playbooks/$OLD_PLAYBOOK playbooks/${OLD_PLAYBOOK}.backup"
|
||||
fi
|
||||
|
||||
print_status "SUCCESS" "Migration analysis complete"
|
||||
114
ansible/scripts/setup-cluster-network.sh
Normal file
114
ansible/scripts/setup-cluster-network.sh
Normal file
@@ -0,0 +1,114 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FastPass Homelab - Cluster Network Setup Script
|
||||
# This script sets up DNS (via Technitium) and load balancer configuration for any Kubernetes cluster
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
local status=$1
|
||||
local message=$2
|
||||
case $status in
|
||||
"INFO")
|
||||
echo -e "${BLUE}ℹ️ INFO${NC}: $message"
|
||||
;;
|
||||
"SUCCESS")
|
||||
echo -e "${GREEN}✅ SUCCESS${NC}: $message"
|
||||
;;
|
||||
"ERROR")
|
||||
echo -e "${RED}❌ ERROR${NC}: $message"
|
||||
;;
|
||||
"WARN")
|
||||
echo -e "${YELLOW}⚠️ WARN${NC}: $message"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Usage function
|
||||
usage() {
|
||||
echo "Usage: $0 <cluster_name> <cluster_endpoint> <control_plane_group>"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 fastpass fastpass.local.mk-labs.cloud fastpass_control_plane"
|
||||
echo " $0 hub hub.local.mk-labs.cloud hub_cluster"
|
||||
echo " $0 internal internal.local.mk-labs.cloud internal_cluster"
|
||||
echo ""
|
||||
echo "This script will:"
|
||||
echo " 1. Create DNS entry for the cluster endpoint"
|
||||
echo " 2. Configure Traefik load balancer"
|
||||
echo " 3. Test connectivity"
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check arguments
|
||||
if [ $# -ne 3 ]; then
|
||||
print_status "ERROR" "Invalid number of arguments"
|
||||
usage
|
||||
fi
|
||||
|
||||
CLUSTER_NAME=$1
|
||||
CLUSTER_ENDPOINT=$2
|
||||
CONTROL_PLANE_GROUP=$3
|
||||
|
||||
print_status "INFO" "Setting up network for cluster: $CLUSTER_NAME"
|
||||
print_status "INFO" "Endpoint: $CLUSTER_ENDPOINT"
|
||||
print_status "INFO" "Control plane group: $CONTROL_PLANE_GROUP"
|
||||
|
||||
# Check if inventory file exists
|
||||
if [ ! -f "inventory.yml" ]; then
|
||||
print_status "ERROR" "inventory.yml not found. Please run from ansible directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temporary playbook
|
||||
TEMP_PLAYBOOK=$(mktemp /tmp/cluster-network-setup-XXXXXX.yml)
|
||||
cat > "$TEMP_PLAYBOOK" << EOF
|
||||
---
|
||||
- name: Setup network infrastructure for $CLUSTER_NAME
|
||||
hosts: ${CONTROL_PLANE_GROUP}[0]
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Setup cluster network infrastructure
|
||||
ansible.builtin.include_role:
|
||||
name: cluster-network-setup
|
||||
vars:
|
||||
cluster_name: "$CLUSTER_NAME"
|
||||
cluster_endpoint: "$CLUSTER_ENDPOINT"
|
||||
cluster_vip: "{{ ansible_default_ipv4.address }}"
|
||||
control_plane_nodes: "{{ groups['$CONTROL_PLANE_GROUP'] }}"
|
||||
EOF
|
||||
|
||||
print_status "INFO" "Running network setup playbook..."
|
||||
|
||||
# Run the network setup
|
||||
if ansible-playbook -i inventory.yml "$TEMP_PLAYBOOK"; then
|
||||
print_status "SUCCESS" "Network setup completed for $CLUSTER_NAME"
|
||||
|
||||
# Test connectivity
|
||||
print_status "INFO" "Testing connectivity to $CLUSTER_ENDPOINT:6443..."
|
||||
if timeout 10 bash -c "</dev/tcp/$CLUSTER_ENDPOINT/6443"; then
|
||||
print_status "SUCCESS" "Connectivity test passed"
|
||||
else
|
||||
print_status "WARN" "Connectivity test failed - may need time to propagate"
|
||||
fi
|
||||
|
||||
print_status "INFO" "Network setup complete. You can now:"
|
||||
echo " 1. Deploy your cluster"
|
||||
echo " 2. Test with: kubectl --server=https://$CLUSTER_ENDPOINT:6443 cluster-info"
|
||||
|
||||
else
|
||||
print_status "ERROR" "Network setup failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
rm -f "$TEMP_PLAYBOOK"
|
||||
91
ansible/scripts/setup-kubeconfig.sh
Normal file
91
ansible/scripts/setup-kubeconfig.sh
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
# FastPass Homelab - Kubeconfig Setup Script
|
||||
# This script makes it easy to add any cluster's kubeconfig to your local config
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
local status=$1
|
||||
local message=$2
|
||||
case $status in
|
||||
"INFO")
|
||||
echo -e "${BLUE}ℹ️ INFO${NC}: $message"
|
||||
;;
|
||||
"SUCCESS")
|
||||
echo -e "${GREEN}✅ SUCCESS${NC}: $message"
|
||||
;;
|
||||
"ERROR")
|
||||
echo -e "${RED}❌ ERROR${NC}: $message"
|
||||
;;
|
||||
"WARN")
|
||||
echo -e "${YELLOW}⚠️ WARN${NC}: $message"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Usage function
|
||||
usage() {
|
||||
echo "Usage: $0 <cluster_name> <host_group>"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 fastpass fastpass_control_plane[0]"
|
||||
echo " $0 hub hub_cluster"
|
||||
echo " $0 internal internal_cluster[0]"
|
||||
echo ""
|
||||
echo "Available clusters in your homelab:"
|
||||
echo " - fastpass (FastPass Kubernetes cluster)"
|
||||
echo " - hub (OpenShift Hub cluster)"
|
||||
echo " - internal (Internal OpenShift cluster)"
|
||||
echo ""
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check arguments
|
||||
if [ $# -ne 2 ]; then
|
||||
print_status "ERROR" "Invalid number of arguments"
|
||||
usage
|
||||
fi
|
||||
|
||||
CLUSTER_NAME=$1
|
||||
HOST_GROUP=$2
|
||||
|
||||
print_status "INFO" "Setting up kubeconfig for cluster: $CLUSTER_NAME"
|
||||
print_status "INFO" "Target hosts: $HOST_GROUP"
|
||||
|
||||
# Check if inventory file exists
|
||||
if [ ! -f "inventory.yml" ]; then
|
||||
print_status "ERROR" "inventory.yml not found. Please run from ansible directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run the kubeconfig setup
|
||||
print_status "INFO" "Running Ansible playbook..."
|
||||
|
||||
ansible-playbook -i inventory.yml \
|
||||
playbooks/examples/multi-cluster-kubeconfig.yml \
|
||||
--limit "$HOST_GROUP" \
|
||||
-e "target_cluster_hosts=$HOST_GROUP" \
|
||||
-e "target_cluster_name=$CLUSTER_NAME" \
|
||||
--tags kubeconfig
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "SUCCESS" "Kubeconfig setup completed for $CLUSTER_NAME"
|
||||
print_status "INFO" "You can now use: kubectl config use-context ${CLUSTER_NAME}-admin"
|
||||
|
||||
# Show available contexts
|
||||
echo ""
|
||||
print_status "INFO" "Available contexts:"
|
||||
kubectl config get-contexts 2>/dev/null || print_status "WARN" "kubectl not found or kubeconfig not accessible"
|
||||
else
|
||||
print_status "ERROR" "Kubeconfig setup failed"
|
||||
exit 1
|
||||
fi
|
||||
0
ansible/scripts/test-fastpass-deployment.sh
Executable file → Normal file
0
ansible/scripts/test-fastpass-deployment.sh
Executable file → Normal file
Reference in New Issue
Block a user