Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
195
infrastructure/gitops/azure-devops-agent.sh
Executable file
195
infrastructure/gitops/azure-devops-agent.sh
Executable file
@@ -0,0 +1,195 @@
|
||||
#!/bin/bash
|
||||
# Azure DevOps Self-Hosted Agent Setup Script
|
||||
# Installs and configures Azure DevOps agent on a Proxmox VM
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Azure DevOps configuration
|
||||
AZP_URL="${AZP_URL:-}"
|
||||
AZP_TOKEN="${AZP_TOKEN:-}"
|
||||
AZP_AGENT_NAME="${AZP_AGENT_NAME:-$(hostname)}"
|
||||
AZP_POOL="${AZP_POOL:-Default}"
|
||||
AZP_WORK="${AZP_WORK:-_work}"
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
check_root() {
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
log_error "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_config() {
|
||||
if [ -z "$AZP_URL" ] || [ -z "$AZP_TOKEN" ]; then
|
||||
log_error "Required Azure DevOps configuration missing"
|
||||
log_info "Required environment variables:"
|
||||
log_info " AZP_URL - Azure DevOps organization URL (e.g., https://dev.azure.com/yourorg)"
|
||||
log_info " AZP_TOKEN - Personal Access Token with Agent Pools (Read & Manage) permission"
|
||||
log_info ""
|
||||
log_info "Optional:"
|
||||
log_info " AZP_AGENT_NAME - Agent name (default: hostname)"
|
||||
log_info " AZP_POOL - Agent pool name (default: Default)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
detect_os() {
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
VERSION=$VERSION_ID
|
||||
log_info "Detected OS: $OS $VERSION"
|
||||
else
|
||||
log_error "Cannot detect operating system"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_dependencies() {
|
||||
log_info "Installing dependencies..."
|
||||
|
||||
case "$OS" in
|
||||
ubuntu|debian)
|
||||
apt-get update
|
||||
apt-get install -y curl jq git
|
||||
;;
|
||||
rhel|centos|fedora)
|
||||
yum install -y curl jq git
|
||||
;;
|
||||
*)
|
||||
log_warn "Unknown OS. Please install: curl, jq, git"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
download_agent() {
|
||||
log_info "Downloading Azure DevOps agent..."
|
||||
|
||||
AGENT_DIR="/opt/azp-agent"
|
||||
mkdir -p "$AGENT_DIR"
|
||||
cd "$AGENT_DIR"
|
||||
|
||||
# Download agent package
|
||||
case "$(uname -m)" in
|
||||
x86_64)
|
||||
AGENT_URL="https://vstsagentpackage.azureedge.net/agent/2.220.0/vsts-agent-linux-x64-2.220.0.tar.gz"
|
||||
;;
|
||||
arm64|aarch64)
|
||||
AGENT_URL="https://vstsagentpackage.azureedge.net/agent/2.220.0/vsts-agent-linux-arm64-2.220.0.tar.gz"
|
||||
;;
|
||||
*)
|
||||
log_error "Unsupported architecture: $(uname -m)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
curl -LsS "$AGENT_URL" | tar -xz
|
||||
log_info "Agent downloaded to $AGENT_DIR"
|
||||
}
|
||||
|
||||
configure_agent() {
|
||||
log_info "Configuring Azure DevOps agent..."
|
||||
|
||||
cd "$AGENT_DIR"
|
||||
|
||||
./config.sh \
|
||||
--unattended \
|
||||
--url "$AZP_URL" \
|
||||
--auth pat \
|
||||
--token "$AZP_TOKEN" \
|
||||
--pool "$AZP_POOL" \
|
||||
--agent "$AZP_AGENT_NAME" \
|
||||
--work "$AZP_WORK" \
|
||||
--replace \
|
||||
--acceptTeeEula
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log_info "Agent configured successfully"
|
||||
else
|
||||
log_error "Agent configuration failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_service() {
|
||||
log_info "Installing Azure DevOps agent as a systemd service..."
|
||||
|
||||
cd "$AGENT_DIR"
|
||||
./svc.sh install
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log_info "Service installed successfully"
|
||||
else
|
||||
log_error "Service installation failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
log_info "Starting Azure DevOps agent service..."
|
||||
|
||||
./svc.sh start
|
||||
|
||||
sleep 5
|
||||
|
||||
if systemctl is-active --quiet azp-agent; then
|
||||
log_info "Agent service is running"
|
||||
systemctl status azp-agent --no-pager
|
||||
else
|
||||
log_error "Agent service failed to start"
|
||||
systemctl status azp-agent --no-pager
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
show_info() {
|
||||
log_info "Azure DevOps agent setup completed!"
|
||||
log_info ""
|
||||
log_info "Agent details:"
|
||||
log_info " Name: $AZP_AGENT_NAME"
|
||||
log_info " Pool: $AZP_POOL"
|
||||
log_info " Work directory: $AGENT_DIR/$AZP_WORK"
|
||||
log_info ""
|
||||
log_info "Useful commands:"
|
||||
log_info " Status: systemctl status azp-agent"
|
||||
log_info " Stop: systemctl stop azp-agent"
|
||||
log_info " Start: systemctl start azp-agent"
|
||||
log_info " Restart: systemctl restart azp-agent"
|
||||
log_info " Logs: journalctl -u azp-agent -f"
|
||||
log_info ""
|
||||
log_info "View agent in Azure DevOps:"
|
||||
log_info " $AZP_URL/_settings/agentpools"
|
||||
}
|
||||
|
||||
main() {
|
||||
log_info "Starting Azure DevOps agent setup..."
|
||||
check_root
|
||||
validate_config
|
||||
detect_os
|
||||
install_dependencies
|
||||
download_agent
|
||||
configure_agent
|
||||
install_service
|
||||
start_service
|
||||
show_info
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
119
infrastructure/gitops/gitea-deploy.sh
Executable file
119
infrastructure/gitops/gitea-deploy.sh
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
# Gitea Deployment Script
|
||||
# Deploys Gitea Git repository server using Docker Compose
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Configuration
|
||||
GITEA_DOMAIN="${GITEA_DOMAIN:-git.local}"
|
||||
GITEA_PORT="${GITEA_PORT:-3000}"
|
||||
SSH_PORT="${SSH_PORT:-2222}"
|
||||
COMPOSE_FILE="${COMPOSE_FILE:-$(dirname "$0")/../../docker-compose/gitea.yml}"
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
check_docker() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log_error "Docker not found. Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker ps &>/dev/null; then
|
||||
log_error "Docker daemon not running. Please start Docker."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker-compose &> /dev/null && ! docker compose version &>/dev/null; then
|
||||
log_error "Docker Compose not found. Please install Docker Compose."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
update_compose_file() {
|
||||
log_info "Updating Docker Compose configuration..."
|
||||
|
||||
# Update domain in compose file if needed
|
||||
if [ -f "$COMPOSE_FILE" ]; then
|
||||
sed -i "s/git.local/$GITEA_DOMAIN/g" "$COMPOSE_FILE" || true
|
||||
log_info "Docker Compose file configured"
|
||||
fi
|
||||
}
|
||||
|
||||
deploy_gitea() {
|
||||
log_info "Deploying Gitea using Docker Compose..."
|
||||
|
||||
# Determine compose command
|
||||
if docker compose version &>/dev/null; then
|
||||
COMPOSE_CMD="docker compose"
|
||||
else
|
||||
COMPOSE_CMD="docker-compose"
|
||||
fi
|
||||
|
||||
# Deploy
|
||||
cd "$(dirname "$COMPOSE_FILE")"
|
||||
$COMPOSE_CMD -f "$(basename "$COMPOSE_FILE")" up -d
|
||||
|
||||
log_info "Waiting for Gitea to be ready..."
|
||||
sleep 10
|
||||
|
||||
# Wait for service to be healthy
|
||||
MAX_WAIT=120
|
||||
ELAPSED=0
|
||||
|
||||
while [ $ELAPSED -lt $MAX_WAIT ]; do
|
||||
if curl -s "http://localhost:$GITEA_PORT" &>/dev/null; then
|
||||
log_info "Gitea is ready!"
|
||||
return 0
|
||||
fi
|
||||
log_info "Waiting for Gitea to start... ($ELAPSED/$MAX_WAIT seconds)"
|
||||
sleep 5
|
||||
ELAPSED=$((ELAPSED + 5))
|
||||
done
|
||||
|
||||
log_warn "Gitea may not be fully ready yet. Check logs with:"
|
||||
log_info " docker logs gitea"
|
||||
}
|
||||
|
||||
show_info() {
|
||||
log_info "Gitea deployment completed!"
|
||||
log_info ""
|
||||
log_info "Access Gitea at:"
|
||||
log_info " Web UI: http://$GITEA_DOMAIN:$GITEA_PORT"
|
||||
log_info " SSH: ssh://git@$GITEA_DOMAIN:$SSH_PORT"
|
||||
log_info ""
|
||||
log_info "Default credentials (change on first login):"
|
||||
log_info " Username: root"
|
||||
log_info " Password: (set during first-time setup)"
|
||||
log_info ""
|
||||
log_info "Useful commands:"
|
||||
log_info " View logs: docker logs gitea"
|
||||
log_info " Stop: docker-compose -f $COMPOSE_FILE down"
|
||||
log_info " Restart: docker-compose -f $COMPOSE_FILE restart"
|
||||
}
|
||||
|
||||
main() {
|
||||
log_info "Starting Gitea deployment..."
|
||||
check_docker
|
||||
update_compose_file
|
||||
deploy_gitea
|
||||
show_info
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
148
infrastructure/gitops/gitlab-deploy.sh
Executable file
148
infrastructure/gitops/gitlab-deploy.sh
Executable file
@@ -0,0 +1,148 @@
|
||||
#!/bin/bash
|
||||
# GitLab CE Deployment Script
|
||||
# Deploys GitLab Community Edition using Docker Compose
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Configuration
|
||||
GITLAB_DOMAIN="${GITLAB_DOMAIN:-gitlab.local}"
|
||||
GITLAB_PORT="${GITLAB_PORT:-8080}"
|
||||
SSH_PORT="${SSH_PORT:-2222}"
|
||||
COMPOSE_FILE="${COMPOSE_FILE:-$(dirname "$0")/../../docker-compose/gitlab.yml}"
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
check_docker() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log_error "Docker not found. Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker ps &>/dev/null; then
|
||||
log_error "Docker daemon not running. Please start Docker."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker-compose &> /dev/null && ! docker compose version &>/dev/null; then
|
||||
log_error "Docker Compose not found. Please install Docker Compose."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_resources() {
|
||||
log_info "Checking system resources..."
|
||||
|
||||
TOTAL_MEM=$(free -g | awk '/^Mem:/{print $2}')
|
||||
if [ "$TOTAL_MEM" -lt 8 ]; then
|
||||
log_warn "GitLab requires at least 8GB RAM. You have ${TOTAL_MEM}GB."
|
||||
log_warn "GitLab may not run optimally with less than 8GB."
|
||||
read -p "Continue anyway? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
update_compose_file() {
|
||||
log_info "Updating Docker Compose configuration..."
|
||||
|
||||
if [ -f "$COMPOSE_FILE" ]; then
|
||||
sed -i "s/gitlab.local/$GITLAB_DOMAIN/g" "$COMPOSE_FILE" || true
|
||||
log_info "Docker Compose file configured"
|
||||
fi
|
||||
}
|
||||
|
||||
deploy_gitlab() {
|
||||
log_info "Deploying GitLab CE using Docker Compose..."
|
||||
log_warn "GitLab requires significant resources and may take 5-10 minutes to start"
|
||||
|
||||
# Determine compose command
|
||||
if docker compose version &>/dev/null; then
|
||||
COMPOSE_CMD="docker compose"
|
||||
else
|
||||
COMPOSE_CMD="docker-compose"
|
||||
fi
|
||||
|
||||
# Deploy
|
||||
cd "$(dirname "$COMPOSE_FILE")"
|
||||
$COMPOSE_CMD -f "$(basename "$COMPOSE_FILE")" up -d
|
||||
|
||||
log_info "Waiting for GitLab to initialize (this may take several minutes)..."
|
||||
log_info "You can monitor progress with: docker logs -f gitlab"
|
||||
|
||||
# Wait for service to be healthy
|
||||
MAX_WAIT=600 # 10 minutes
|
||||
ELAPSED=0
|
||||
|
||||
while [ $ELAPSED -lt $MAX_WAIT ]; do
|
||||
if curl -s "http://localhost:$GITLAB_PORT" &>/dev/null; then
|
||||
log_info "GitLab is ready!"
|
||||
return 0
|
||||
fi
|
||||
log_info "Waiting for GitLab to start... ($ELAPSED/$MAX_WAIT seconds)"
|
||||
sleep 10
|
||||
ELAPSED=$((ELAPSED + 10))
|
||||
done
|
||||
|
||||
log_warn "GitLab may still be initializing. Check logs with:"
|
||||
log_info " docker logs gitlab"
|
||||
}
|
||||
|
||||
get_initial_password() {
|
||||
log_info "Retrieving initial root password..."
|
||||
|
||||
if docker exec gitlab grep 'Password:' /etc/gitlab/initial_root_password &>/dev/null; then
|
||||
INITIAL_PASSWORD=$(docker exec gitlab grep 'Password:' /etc/gitlab/initial_root_password | awk '{print $2}')
|
||||
log_info "Initial root password: $INITIAL_PASSWORD"
|
||||
log_warn "Change this password on first login!"
|
||||
else
|
||||
log_warn "Initial password file not found. Password may have been changed."
|
||||
fi
|
||||
}
|
||||
|
||||
show_info() {
|
||||
log_info "GitLab deployment completed!"
|
||||
log_info ""
|
||||
log_info "Access GitLab at:"
|
||||
log_info " Web UI: http://$GITLAB_DOMAIN:$GITLAB_PORT"
|
||||
log_info " SSH: ssh://git@$GITLAB_DOMAIN:$SSH_PORT"
|
||||
log_info ""
|
||||
log_info "Default credentials:"
|
||||
log_info " Username: root"
|
||||
get_initial_password
|
||||
log_info ""
|
||||
log_info "Useful commands:"
|
||||
log_info " View logs: docker logs gitlab"
|
||||
log_info " Stop: docker-compose -f $COMPOSE_FILE down"
|
||||
log_info " Restart: docker-compose -f $COMPOSE_FILE restart"
|
||||
log_info " Check status: docker exec gitlab gitlab-ctl status"
|
||||
}
|
||||
|
||||
main() {
|
||||
log_info "Starting GitLab CE deployment..."
|
||||
check_docker
|
||||
check_resources
|
||||
update_compose_file
|
||||
deploy_gitlab
|
||||
show_info
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user