=============================================================================== 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: | Ubuntu Server - BMTI

Linux Ubuntu Server - Otomatisasi BMTI

dest: /var/www/html/index.html mode: '0644' - name: Pastikan Service Nginx Running service: name: nginx state: started enabled: yes ------------------------------------------------------------------------------- 4. PLAYBOOK OTOMATISASI WINDOWS SERVER (setup_windows.yaml) ------------------------------------------------------------------------------- # File: setup_windows.yaml --- - name: Konfigurasi Otomatisasi Windows Server BMTI hosts: winserv gather_facts: no tasks: # 1. Install IIS Web Server - name: Install Fitur Web-Server (IIS) win_feature: name: Web-Server state: present include_management_tools: yes # 2. Buat User Lokal Baru - name: Tambah User Lokal Operator win_user: name: operator_bmti password: "UserSecurePass123!" groups: Users state: present # 3. Deploy Landing Page IIS - name: Deploy Custom Page IIS win_copy: content: "

Windows Server IIS - Otomatisasi BMTI

" dest: C:\inetpub\wwwroot\index.html ------------------------------------------------------------------------------- 5. COMMAND EKSEKUSI DAN VERIFIKASI (TERMINAL WSL UBUNTU) ------------------------------------------------------------------------------- # Test Konektivitas Dasar (Ping) ansible winserv -m win_ping -i hosts_servers.yaml ansible ubuntu_srv -m ping -i hosts_servers.yaml # Eksekusi Playbook Windows Server ansible-playbook -i hosts_servers.yaml setup_windows.yaml # Eksekusi Playbook Linux Server ansible-playbook -i hosts_servers.yaml setup_linux.yaml # Verifikasi Hasil via Browser / CURL curl http://192.168.101.xx:8081 curl http://192.168.101.xx:8080