2024-01-01 00:36:31 -05:00
|
|
|
---
|
|
|
|
|
2024-01-04 01:40:27 -05:00
|
|
|
# set hostname
|
|
|
|
- name: Set a hostname specifying strategy
|
|
|
|
ansible.builtin.hostname:
|
|
|
|
name: "{{ inventory_hostname }}"
|
|
|
|
use: systemd
|
|
|
|
|
2024-01-03 01:03:22 -05:00
|
|
|
# docker
|
|
|
|
- name: install dependencies
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- apt-transport-https
|
|
|
|
- ca-certificates
|
|
|
|
- curl
|
|
|
|
- gnupg-agent
|
|
|
|
- software-properties-common
|
2024-04-27 23:41:11 -04:00
|
|
|
- sudo
|
2024-02-29 23:37:46 -05:00
|
|
|
- systemd-timesyncd
|
2024-01-03 01:03:22 -05:00
|
|
|
state: latest
|
2024-01-01 00:36:31 -05:00
|
|
|
update_cache: yes
|
2024-06-24 03:35:06 -04:00
|
|
|
|
|
|
|
- name: Update and upgrade apt packages
|
|
|
|
become: true
|
|
|
|
apt:
|
2024-04-27 23:41:11 -04:00
|
|
|
upgrade: yes
|
2024-06-24 03:35:06 -04:00
|
|
|
update_cache: yes
|
|
|
|
cache_valid_time: 86400 #One day
|
2024-01-03 01:03:22 -05:00
|
|
|
|
2024-02-29 23:37:46 -05:00
|
|
|
- name: enable systemd-timesyncd
|
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
name: systemd-timesyncd
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
daemon_reload: true
|
|
|
|
|
|
|
|
- name: purge ntp
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- ntp
|
|
|
|
state: absent
|
|
|
|
|
2024-01-03 01:03:22 -05:00
|
|
|
- name: docker GPG key
|
|
|
|
apt_key:
|
|
|
|
url: https://download.docker.com/linux/debian/gpg
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: repository docker
|
|
|
|
apt_repository:
|
|
|
|
repo: deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: install docker
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- docker-ce
|
|
|
|
- docker-ce-cli
|
|
|
|
- containerd.io
|
|
|
|
state: latest
|
|
|
|
update_cache: yes
|
|
|
|
|
|
|
|
- name: enable docker
|
2024-01-03 01:30:54 -05:00
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
name: docker
|
|
|
|
state: restarted
|
|
|
|
enabled: true
|
|
|
|
daemon_reload: true
|
2024-01-03 01:03:22 -05:00
|
|
|
|
|
|
|
- name: copy docker-compose@.service
|
|
|
|
copy:
|
|
|
|
src: ../files/docker-compose@.service
|
|
|
|
dest: /etc/systemd/system/docker-compose@.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
|
|
|
|
- name: ensure /etc/docker/compose exist
|
|
|
|
file:
|
|
|
|
path: /etc/docker/compose
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0700
|
2024-01-01 00:36:31 -05:00
|
|
|
|
|
|
|
# SSH
|
|
|
|
- name: Copy sshd_config
|
|
|
|
copy:
|
2024-01-03 01:03:22 -05:00
|
|
|
src: ../files/sshd_config
|
2024-01-01 00:36:31 -05:00
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
|
|
|
|
- name: restart sshd
|
2024-01-01 16:55:50 -05:00
|
|
|
service: name=sshd state=restarted enabled=yes
|
2024-01-01 00:36:31 -05:00
|
|
|
|
|
|
|
# FIREWALL
|
|
|
|
- name: install UFW
|
|
|
|
apt: name=ufw state=latest
|
|
|
|
|
2024-01-02 19:05:01 -05:00
|
|
|
- name: allow ssh from everywhere and enable
|
2024-01-01 00:36:31 -05:00
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
name: OpenSSH
|
2024-01-02 19:05:01 -05:00
|
|
|
state: enabled
|
2024-01-01 00:36:31 -05:00
|
|
|
|
|
|
|
- name: restart ufw
|
2024-01-01 16:55:50 -05:00
|
|
|
service: name=ufw state=restarted enabled=yes
|
2024-01-01 00:36:31 -05:00
|
|
|
|
|
|
|
# FAIL2BAN
|
|
|
|
- name: install fail2ban
|
|
|
|
apt: name=fail2ban state=latest
|
|
|
|
|
|
|
|
- name: Copy jail.conf
|
|
|
|
copy:
|
2024-01-03 01:03:22 -05:00
|
|
|
src: ../files/jail.conf
|
2024-01-01 00:36:31 -05:00
|
|
|
dest: /etc/fail2ban/jail.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
|
|
|
|
- name: restart fail2ban
|
2024-01-01 16:55:50 -05:00
|
|
|
service: name=fail2ban state=restarted enabled=yes
|