--- # ========================================== # PHASE 1: END-SERVER CLEANUP # ========================================== - name: "Phase 1A: Teardown Windows Server" hosts: windows_servers gather_facts: no tasks: - name: Uninstall Fitur Web-Server (IIS) ansible.windows.win_feature: name: Web-Server state: absent - name: Hapus User Lokal operator_bmti ansible.windows.win_user: name: operator_bmti state: absent - name: Hapus File Web IIS (index.html) ansible.windows.win_file: path: C:\inetpub\wwwroot\index.html state: absent # Menggunakan InterfaceAlias "Ethernet" secara eksplisit - name: Ubah IP Address Windows Server ke VLAN 20 (192.168.20.2) ansible.windows.win_shell: | Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.10.2 -Confirm:$false -ErrorAction SilentlyContinue New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.20.2 -PrefixLength 24 -DefaultGateway 192.168.20.1 async: 10 poll: 0 ignore_errors: yes - name: "Phase 1B: Teardown Ubuntu Server" hosts: ubuntu_srv become: yes tasks: - name: Purge Paket Nginx dan Konfigurasi ansible.builtin.apt: name: - nginx - nginx-common - nginx-core state: absent purge: yes - name: Autoremove Paket Sisa ansible.builtin.apt: autoremove: yes - name: Hapus File Index HTML & Direktori Web ansible.builtin.file: path: "{{ item }}" state: absent loop: - /var/www/html/index.html - /etc/nginx # Menggunakan nama interface ens3 dan menulis ke 50-cloud-init.yaml - name: Tulis Konfigurasi Netplan IP Baru (192.168.10.2 pada ens3) ansible.builtin.copy: dest: /etc/netplan/50-cloud-init.yaml content: | network: version: 2 renderer: networkd ethernets: ens3: dhcp4: no addresses: - 192.168.10.2/24 routes: - to: default via: 192.168.10.1 nameservers: addresses: [8.8.8.8, 1.1.1.1] - name: Terapkan Netplan (netplan apply) ansible.builtin.shell: "netplan apply" async: 10 poll: 0 ignore_errors: yes # ========================================== # PHASE 2: SWITCH LAYER 2 CLEANUP (CISCO) # ========================================== - name: "Phase 2: Reset Switch Cisco Catalyst" hosts: cisco_switches gather_facts: no tasks: # 1. Hapus OSPF - name: Hapus OSPF Global & Interface cisco.ios.ios_config: lines: - no router ospf 1 # 2. Reset Port Access biasa (G0/1 - G0/3) - name: Reset Port Access (G0/1 - G0/3) ke VLAN 1 cisco.ios.ios_config: parents: interface range GigabitEthernet0/1 - 3 lines: - switchport mode access - switchport access vlan 1 # 3. Hapus VLAN Tambahan DULU (Selagi Trunk G0/0 Masih Aktif) - name: Hapus VLAN 10, 20, dan 99 cisco.ios.ios_config: lines: - no vlan 10,20,99 # 4. Reset Port G0/0 (Sesi SSH akan putus di sini) - name: Reset Port G0/0 dari Trunk ke Access (VLAN 1) cisco.ios.ios_config: parents: interface GigabitEthernet0/0 lines: - switchport mode access - switchport access vlan 1 ignore_errors: yes # 5. Simpan Konfigurasi (Write Memory) - name: Simpan Konfigurasi Cisco (Write Memory) cisco.ios.ios_config: save_when: always ignore_errors: yes # ========================================== # PHASE 3: GATEWAY ROUTER CLEANUP (MIKROTIK) # ========================================== - name: "Phase 3: Reset Router MikroTik CHR" hosts: mikrotik gather_facts: no tasks: - name: Hapus Konfigurasi Routing OSPF (ROSv7) community.routeros.command: commands: - /routing/ospf/interface-template/remove [find] - /routing/ospf/area/remove [find name!="backbone"] - /routing/ospf/instance/remove [find] - name: Hapus DHCP Server dan IP Pool community.routeros.command: commands: - /ip dhcp-server remove [find] - /ip pool remove [find] - name: Hapus IP Address Statis (Menyisakan ether1) community.routeros.command: commands: - /ip address remove [find where interface!="ether1" and dynamic=no] - name: Hapus All Sub-Interface VLAN (vlan10-data, vlan99-transit) community.routeros.command: commands: - /interface vlan remove [find] - name: Perbarui Target IP pada NAT Rules community.routeros.command: commands: - /ip firewall nat set [find to-addresses=192.168.1.2] to-addresses=192.168.10.2 - /ip firewall nat set [find to-addresses=192.168.10.2] to-addresses=192.168.20.2