infra/playbooks/roles/common/tasks/main.yml

70 lines
1.3 KiB
YAML
Raw Normal View History

2024-03-17 18:21:46 -04:00
---
- name: Apt upgrade, update
ansible.builtin.apt:
update_cache: true
upgrade: "dist"
- name: Set a hostname specifying strategy
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
use: systemd
- name: Install dependencies
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- systemd-timesyncd
- systemd-resolved
- vim
- git
2024-03-23 17:43:50 -04:00
- rsync
2024-03-17 18:21:46 -04:00
state: latest
update_cache: true
notify:
- Enable systemd-timesyncd
2024-03-23 17:43:50 -04:00
## DNS
- name: Configure systemd-resolved
ansible.builtin.include_tasks:
file: "systemd-resolved.yml"
2024-03-17 18:21:46 -04:00
## SSH
- name: Copy sshd_config
ansible.builtin.copy:
src: files/sshd_config
dest: /etc/ssh/sshd_config
owner: root
group: root
mode: u=rw,g=r,o=r
notify:
- Restart sshd
## FAIL2BAN
- name: Install Fail2Ban
ansible.builtin.apt:
name: fail2ban
state: present
notify:
- Enable fail2ban
## FIREWALL
- name: Install ufw
ansible.builtin.apt:
name: ufw
state: present
- name: Allow ssh from rfc1918 networks
loop: "{{ rfc1918_networks }}"
community.general.ufw:
rule: allow
name: "OpenSSH"
from: "{{ item }}"
2024-03-17 18:55:51 -04:00
state: "enabled"
2024-03-17 18:21:46 -04:00
notify:
2024-03-17 18:55:51 -04:00
- Reload ufw