Commit 4fbc998a authored by Nguyễn Văn Vũ's avatar Nguyễn Văn Vũ

Week3 - Configure Security Standards for Ubuntu by Ansible Script And...

Week3 - Configure Security Standards for Ubuntu by Ansible Script And Configure ssh access on remote host
parent 38ccd012
---
- name: Configure Security Standards for Ubuntu
hosts: all
become: yes
tasks:
- name: Update package cache and upgrade packages
apt:
update_cache: yes
upgrade: dist
- name: Install fail2ban
apt:
name: fail2ban
state: present
- name: Configure fail2ban
template:
src: templates/fail2ban.j2
dest: /etc/fail2ban/jail.local
notify: restart fail2ban
- name: Enable firewall (ufw) and allow SSH
ufw:
state: enabled
policy: deny
rules:
- allow:
proto: tcp
port: 22
comment: "Allow SSH"
before: "ufw-reload"
- name: Enable automatic security updates
apt:
name: unattended-upgrades
state: present
notify: restart unattended-upgrades
handlers:
- name: restart fail2ban
service:
name: fail2ban
state: restarted
- name: restart unattended-upgrades
service:
name: unattended-upgrades
state: restarted
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment