Nutanix_Home_Lab_HLD_2_Automasjon - itnett/FTD02H-N GitHub Wiki
For å sette opp Nutanix Blueprints og oppstartsskript som automatisk oppretter og konfigurerer VM-er med minimal distribusjon og ønsket funksjonalitet, vil vi bruke Nutanix Calm, som er en del av Nutanix Prism Central. Her er en veiledning på hvordan du kan lage Blueprints og startup-skripts for hver VM.
-
Installer Nutanix Calm:
- Sørg for at Nutanix Prism Central er installert og konfigurer Nutanix Calm.
- Aktivér Calm i Prism Central under Apps > Calm.
-
Forbered Basis-Image:
- Last ned og legg til basis Linux/Windows images i Prism Central Image Configuration.
- Opprett VM Templates for de ulike OS-versjonene som skal brukes som grunnlag (f.eks. minimal Ubuntu, minimal CentOS, Windows Server Core).
Blueprint Details:
-
Name:
Windows_Server_HyperV_AD_DNS_DHCP
- Base Image: Windows Server Core (Template)
- Scripts:
# Startup Script: configure_windows.ps1
# Set Hostname
Rename-Computer -NewName "WIN-SRV-01" -Force -Restart
# Set IP Address
New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress "10.0.0.10" -PrefixLength 24 -DefaultGateway "10.0.0.1"
Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses "10.0.0.10"
# Install AD, DNS, and DHCP roles
Install-WindowsFeature -Name AD-Domain-Services, DNS, DHCP -IncludeManagementTools
# Promote server to domain controller
Install-ADDSForest -DomainName "main.local" -InstallDNS -CreateDnsDelegation:$false -DatabasePath "C:\Windows\NTDS" -LogPath "C:\Windows\NTDS" -SysvolPath "C:\Windows\SYSVOL" -Force -NoRebootOnCompletion
# Configure DHCP
netsh dhcp server install
netsh dhcp server scope 10.0.0.0 add scope 10.0.0.50 10.0.0.100 "Main Scope"
netsh dhcp server scope 10.0.0.0 set optionvalue 003 ipaddress 10.0.0.1
Blueprint Details:
-
Name:
Linux_Docker_Kubernetes
- Base Image: Minimal Ubuntu or CentOS (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_linux.sh
# Set Hostname
hostnamectl set-hostname "LINUX-DOCKER-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.0.0.20/24" ipv4.gateway "10.0.0.1" ipv4.dns "10.0.0.10" ipv4.method manual
nmcli con up "System eth0"
# Update and install Docker
apt-get update -y
apt-get install -y docker.io
# Enable Docker service
systemctl start docker
systemctl enable docker
# Optional: Install Kubernetes (kubeadm, kubelet, kubectl)
apt-get install -y apt-transport-https ca-certificates curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update -y
apt-get install -y kubelet kubeadm kubectl
Blueprint Details:
-
Name:
Kali_Linux_Pentesting
- Base Image: Minimal Kali Linux (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_kali.sh
# Set Hostname
hostnamectl set-hostname "KALI-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.0.0.30/24" ipv4.gateway "10.0.0.1" ipv4.dns "10.0.0.10" ipv4.method manual
nmcli con up "System eth0"
# Update and install necessary pentesting tools
apt-get update -y
apt-get install -y metasploit-framework nmap wireshark burpsuite
Blueprint Details:
-
Name:
Metasploitable_Target
- Base Image: Minimal Ubuntu (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_metasploitable.sh
# Set Hostname
hostnamectl set-hostname "META-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.0.0.40/24" ipv4.gateway "10.0.0.1" ipv4.dns "10.0.0.10" ipv4.method manual
nmcli con up "System eth0"
# Install vulnerable services
apt-get update -y
apt-get install -y openssh-server vsftpd apache2 mysql-server
# Configure MySQL with default credentials
mysql -e "CREATE USER 'root'@'localhost' IDENTIFIED BY 'root';"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';"
Blueprint Details:
-
Name:
TrueNAS_Storage
- Base Image: TrueNAS Core (Template)
- Scripts:
# No additional startup script needed for TrueNAS. Configuration happens post-installation via web UI.
Blueprint Details:
-
Name:
Zabbix_Monitoring
- Base Image: Minimal Ubuntu or CentOS (Template)
- Scripts:
#!/bin/bash
# Startup Script: configure_zabbix.sh
# Set Hostname
hostnamectl set-hostname "ZABBIX-01"
# Set IP Address
nmcli con mod "System eth0" ipv4.addresses "10.0.0.60/24" ipv4.gateway "10.0.0.1" ipv4.dns "10.0.0.10" ipv4.method manual
nmcli con up "System eth0"
# Install Zabbix server
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_5.0-1+ubuntu20.04_all.deb
apt-get update -y
apt-get install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent
# Set up database for Zabbix
mysql -uroot -p -e "CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;"
mysql -uroot -p -e "CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';"
mysql -uroot -p -e "GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';"
mysql -uroot -p -e "FLUSH PRIVILEGES;"
-
Opprett en ny Blueprint:
- Gå til Calm i Prism Central.
- Velg "Blueprints" og klikk "Create Blueprint".
- Gi din Blueprint et navn, som f.eks. "Windows_Server_HyperV_AD_DNS_DHCP".
-
Konfigurer VM og Applikasjonsprofiler:
- Legg til en VM fra ditt valg av baseimage.
- Sett inn startup skriptet under "Service" fanen, som en "Install Task".
- Under "Packages", legg til nødvendige programvarepakker.
-
Definer variabler og parametere:
- Legg til variabler som IP-adresse, subnet, gateway, etc. slik at de kan konfigureres dynamisk.
-
Kjør Blueprinten:
- Når alt er satt opp, lagre Blueprinten.
- Velg Blueprinten og klikk "Launch" for å opprette VM-en med alle nødvendige konfigurasjoner.
-
Testing og Justering:
- Test opprettelsen av VM-en for å sikre at alle konfigurasjoner og skripter kjører som forventet.
- Juster skriptene og Blueprinten etter behov.
Dette oppsettet gir deg en effektiv måte å raskt distribuere og konfigurere spesialiserte labbmiljøer på din Nutanix CE rigg. Med Blueprints og automatisering kan du enkelt ta opp og ned ulike miljøer, mens kritiske tjenester som pfSense, Zabbix og TrueNAS forblir online.