| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- ---
- - name: Update apt cache
- apt:
- update_cache: yes
- cache_valid_time: 3600
- when: ansible_os_family == "Debian"
- - name: Install required system packages
- apt:
- name: "{{ item }}"
- state: present
- loop:
- - apt-transport-https
- - ca-certificates
- - curl
- - software-properties-common
- - python3-pip
- - git
- - fail2ban
- - ufw
- - acl
- - name: Configure timezone
- timezone:
- name: "{{ timezone }}"
- - name: Configure fail2ban
- template:
- src: jail.local.j2
- dest: /etc/fail2ban/jail.local
- notify: restart fail2ban
- - name: Configure UFW
- ufw:
- rule: "{{ item.rule }}"
- port: "{{ item.port }}"
- proto: "{{ item.proto }}"
- loop:
- - { rule: 'allow', port: '22', proto: 'tcp' }
- - { rule: 'allow', port: '80', proto: 'tcp' }
- - { rule: 'allow', port: '443', proto: 'tcp' }
- - name: Enable UFW
- ufw:
- state: enabled
- policy: deny
|