Bingung juga pemula belajar ansible dari mana.. Diputuskan saat itu saya kudu belajar ansible, minimal perintah sederhana saja.
Sampai ketemulah sama masalah server yang kena serang orang luar. Mau nge-block IP nya, tapi cuma berlaku di server itu aja. Biar lebih gampang saya coba pake ansible, biar tiap block 1 IP, semua server ikut block IP itu juga. Berikut caranya:
- Buat file baru, saya namakan hosts
[ubuntuservers]
192.168.1.2
192.168.1.3
- Buat rule ansible, yang ini saya namakan ufw.yml
##### how to use this
#### you just need to change src: & comment:
### then type: "ansible-playbook -i hosts ufw.yml"
## it will apply ufw deny rule to all server (check hosts variable)
---
- hosts: digitalocean
tasks:
- name: install ufw
apt: package=ufw state=present
- name: enable ufw
ufw: state=enabled
- name: add new rule to all server
ufw:
rule: deny
#if you want block specific port
#proto: tcp
#if you want specific port
#port: '20'
insert: 1
src: 42.41.41.41/24
comment: add new rule
- Jalankan command
ansible-playbook -i hosts ufw.yml
. Good luck