=============================================================================== KUMPULAN SCRIPT MODUL 5: OTOMATISASI MANAJEMEN SERVER CROSS-PLATFORM BBPPMPV BMTI - DEPARTEMEN ELEKTRONIKA DAN INFORMATIKA =============================================================================== ------------------------------------------------------------------------------- 1. PEMBUATAN VIRTUAL ENVIRONMENT & INSTALASI ANSIBLE (DI WSL UBUNTU) ------------------------------------------------------------------------------- # Update paket & install python venv sudo apt update && sudo apt install -y python3-pip python3-venv # Buat folder workspace modul 5 mkdir -p ~/ansible-automation/modul5-servers cd ~/ansible-automation/modul5-servers # Buat virtual environment & aktifkan python3 -m venv venv source venv/bin/activate # Install Ansible & pywinrm pip install ansible pywinrm ------------------------- #NAT/Port Forwarding(winRM) /ip firewall nat add chain=dstnat dst-port=5985 protocol=tcp action=dst-nat to-addresses=192.168.10.2 to-ports=5985 comment="NAT WinRM Windows Server" #Pastikan layanan WinRM sudah diaktifkan di Windows Server target dipengan menjalankan perintah PowerShell ini (sebagai Administrator): Enable-PSRemoting -Force Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true Set-Item WSMan:\localhost\Service\AllowUnencrypted -Value $true ------------------------------------------------------------------------------- 2. INVENTORY SERVER CROSS-PLATFORM (hosts_servers.yaml) ------------------------------------------------------------------------------- all: children: linux_servers: hosts: ubuntu_srv: ansible_host: 192.168.101.xx # IP MikroTik Peserta ansible_port: 2222 ansible_user: adminlocal ansible_password: "adminpnet" ansible_ssh_common_args: '-o StrictHostKeyChecking=no' windows_servers: hosts: winserv: ansible_host: 192.168.101.xx # IP MikroTik Peserta ansible_port: 5985 # Port WinRM HTTP (Sesuaikan jika pakai NAT/Port Forwarding) ansible_user: Administrator ansible_password: "Manager@123" ansible_connection: winrm ansible_winrm_transport: ntlm ansible_winrm_server_cert_validation: ignore ------------------------------------------------------------------------------- 3. PLAYBOOK OTOMATISASI LINUX SERVER (setup_linux.yaml) ------------------------------------------------------------------------------- # File: setup_linux.yaml --- - name: Konfigurasi Otomatisasi Linux Server (Ubuntu) hosts: ubuntu_srv become: yes tasks: - name: Update repository dan install Nginx apt: name: nginx state: present update_cache: yes - name: Buat User Lokal Operator Linux user: name: operator_bmti password: "$6$rounds=656000$saltkey123$qP8Z5p.A7N6eL..." # Password terenkripsi shell: /bin/bash state: present - name: Deploy Custom Web Page Nginx copy: content: |