Compare commits
No commits in common. "b52ccabd222708d9d5753ae0b78f15eb46b48e2e" and "d7838563a1749f0f4980985583d51758b497067f" have entirely different histories.
b52ccabd22
...
d7838563a1
@ -10,9 +10,3 @@
|
|||||||
name: wg-quick@wg0
|
name: wg-quick@wg0
|
||||||
state: restarted
|
state: restarted
|
||||||
listen: restart_wireguard
|
listen: restart_wireguard
|
||||||
|
|
||||||
- name: Restart Fail2ban
|
|
||||||
service:
|
|
||||||
name: fail2ban
|
|
||||||
state: restarted
|
|
||||||
listen: restart_fail2ban
|
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
- name: Install the Uncomplicated Firewall
|
|
||||||
apt:
|
|
||||||
name: ufw
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Install Fail2ban
|
|
||||||
apt:
|
|
||||||
name: fail2ban
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Deny incoming traffic by default
|
|
||||||
ufw:
|
|
||||||
default: deny
|
|
||||||
direction: incoming
|
|
||||||
|
|
||||||
- name: Allow outgoing traffic by default
|
|
||||||
ufw:
|
|
||||||
default: allow
|
|
||||||
direction: outgoing
|
|
||||||
|
|
||||||
- name: Allow OpenSSH with rate limiting
|
|
||||||
ufw:
|
|
||||||
name: ssh
|
|
||||||
rule: limit
|
|
||||||
|
|
||||||
- name: Enable firewall
|
|
||||||
ufw:
|
|
||||||
state: enabled
|
|
@ -4,9 +4,6 @@
|
|||||||
- import_tasks: system.yml
|
- import_tasks: system.yml
|
||||||
tags: system
|
tags: system
|
||||||
|
|
||||||
- import_tasks: firewall.yml
|
|
||||||
tags: firewall
|
|
||||||
|
|
||||||
- import_tasks: network.yml
|
- import_tasks: network.yml
|
||||||
tags: network
|
tags: network
|
||||||
when: manage_network
|
when: manage_network
|
||||||
|
@ -12,3 +12,8 @@
|
|||||||
dest: "/etc/network/interfaces.d/{{ item.name }}"
|
dest: "/etc/network/interfaces.d/{{ item.name }}"
|
||||||
loop: "{{ interfaces }}"
|
loop: "{{ interfaces }}"
|
||||||
notify: reboot_host
|
notify: reboot_host
|
||||||
|
|
||||||
|
- name: Install bridge utilities
|
||||||
|
apt:
|
||||||
|
name: bridge-utils
|
||||||
|
state: present
|
||||||
|
@ -10,6 +10,12 @@
|
|||||||
dest: /root/.ssh/authorized_keys
|
dest: /root/.ssh/authorized_keys
|
||||||
when: authorized_keys is defined
|
when: authorized_keys is defined
|
||||||
|
|
||||||
|
- name: Install btrfs-tools
|
||||||
|
apt:
|
||||||
|
name: btrfs-tools
|
||||||
|
state: present
|
||||||
|
when: btrfs_support is defined and btrfs_support | bool == true
|
||||||
|
|
||||||
- name: Manage filesystem mounts
|
- name: Manage filesystem mounts
|
||||||
mount:
|
mount:
|
||||||
path: "{{ item.path }}"
|
path: "{{ item.path }}"
|
||||||
|
@ -1,3 +1,25 @@
|
|||||||
|
# Copyright (C) 2021 Kris Lamoureux
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
- name: Add Debian Buster backports
|
||||||
|
copy:
|
||||||
|
src: buster-backports.list
|
||||||
|
dest: /etc/apt/sources.list.d/buster-backports.list
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
- name: Install WireGuard
|
- name: Install WireGuard
|
||||||
apt:
|
apt:
|
||||||
name: wireguard
|
name: wireguard
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
bitwarden_name: bitwarden
|
bitwarden_name: bitwarden
|
||||||
bitwarden_root: "/var/lib/{{ bitwarden_name }}"
|
bitwarden_root: "{{ docker_root }}/{{ bitwarden_name }}"
|
||||||
bitwarden_database: "{{ bitwarden_name }}"
|
bitwarden_database: "{{ bitwarden_name }}"
|
||||||
bitwarden_realips: "172.16.0.0/12"
|
|
||||||
bitwarden_standalone: false
|
bitwarden_standalone: false
|
||||||
bitwarden_production: false
|
bitwarden_production: false
|
||||||
|
@ -65,12 +65,6 @@
|
|||||||
when: not bitwarden_standalone
|
when: not bitwarden_standalone
|
||||||
notify: rebuild_bitwarden
|
notify: rebuild_bitwarden
|
||||||
|
|
||||||
- name: Define reverse proxy servers
|
|
||||||
lineinfile:
|
|
||||||
path: "{{ bitwarden_root }}/bwdata/config.yml"
|
|
||||||
line: "- {{ bitwarden_realips }}"
|
|
||||||
insertafter: "^real_ips"
|
|
||||||
|
|
||||||
- name: Install Bitwarden systemd service
|
- name: Install Bitwarden systemd service
|
||||||
template:
|
template:
|
||||||
src: bitwarden.service.j2
|
src: bitwarden.service.j2
|
||||||
@ -78,12 +72,6 @@
|
|||||||
register: bitwarden_systemd
|
register: bitwarden_systemd
|
||||||
notify: rebuild_bitwarden
|
notify: rebuild_bitwarden
|
||||||
|
|
||||||
- name: Install Bitwarden's Fail2ban jail
|
|
||||||
template:
|
|
||||||
src: fail2ban-jail.conf.j2
|
|
||||||
dest: /etc/fail2ban/jail.d/bitwarden.conf
|
|
||||||
notify: restart_fail2ban
|
|
||||||
|
|
||||||
- name: Reload systemd manager configuration
|
- name: Reload systemd manager configuration
|
||||||
systemd:
|
systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
[bitwarden]
|
|
||||||
enabled = true
|
|
||||||
filter = bitwarden
|
|
||||||
logpath = /var/lib/bitwarden/bwdata/logs/identity/Identity/*
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports
|
|
@ -1,3 +1,3 @@
|
|||||||
docker_compose_root: /var/lib/compose
|
docker_root: /var/lib/docker-compose
|
||||||
docker_compose: /usr/bin/docker-compose
|
docker_compose: /usr/bin/docker-compose
|
||||||
docker_compose_service: compose
|
docker_compose_service: compose
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- name: Create docker-compose root
|
- name: Create docker-compose root
|
||||||
file:
|
file:
|
||||||
path: "{{ docker_compose_root }}"
|
path: "{{ docker_root }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Install docker-compose systemd service
|
- name: Install docker-compose systemd service
|
||||||
|
@ -6,7 +6,7 @@ After=docker.service
|
|||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
RemainAfterExit=true
|
RemainAfterExit=true
|
||||||
WorkingDirectory={{ docker_compose_root }}/%i
|
WorkingDirectory={{ docker_root }}/%i
|
||||||
ExecStart={{ docker_compose }} up -d --remove-orphans
|
ExecStart={{ docker_compose }} up -d --remove-orphans
|
||||||
ExecStop={{ docker_compose }} down
|
ExecStop={{ docker_compose }} down
|
||||||
|
|
||||||
|
@ -14,9 +14,5 @@ gitea_dbhost: host.docker.internal
|
|||||||
gitea_dbname: "{{ gitea_name }}"
|
gitea_dbname: "{{ gitea_name }}"
|
||||||
gitea_dbuser: "{{ gitea_name }}"
|
gitea_dbuser: "{{ gitea_name }}"
|
||||||
|
|
||||||
# proxy settings
|
|
||||||
gitea_proxy_limit: "1"
|
|
||||||
gitea_trusted_proxies: "172.16.0.0/12"
|
|
||||||
|
|
||||||
# host
|
# host
|
||||||
gitea_root: "{{ docker_compose_root }}/{{ gitea_name }}"
|
gitea_root: "{{ docker_root }}/{{ gitea_name }}"
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
- name: Restart Gitea
|
|
||||||
service:
|
|
||||||
name: "{{ docker_compose_service }}@{{ gitea_name }}"
|
|
||||||
state: restarted
|
|
||||||
listen: restart_gitea
|
|
@ -46,22 +46,16 @@
|
|||||||
src: /home/git/.ssh/id_rsa.pub
|
src: /home/git/.ssh/id_rsa.pub
|
||||||
register: git_rsapub
|
register: git_rsapub
|
||||||
|
|
||||||
- name: Get stats on git's authorized_keys file
|
|
||||||
stat:
|
|
||||||
path: /home/git/.ssh/authorized_keys
|
|
||||||
register: git_authkeys
|
|
||||||
|
|
||||||
- name: Create git's authorized_keys file
|
- name: Create git's authorized_keys file
|
||||||
file:
|
file:
|
||||||
path: /home/git/.ssh/authorized_keys
|
path: /home/git/.ssh/authorized_keys
|
||||||
state: touch
|
state: touch
|
||||||
when: not git_authkeys.stat.exists
|
|
||||||
|
|
||||||
- name: Add git's public SSH key to authorized_keys
|
- name: Add git's public SSH key to authorized_keys
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /home/git/.ssh/authorized_keys
|
path: /home/git/.ssh/authorized_keys
|
||||||
regex: "^ssh-rsa"
|
|
||||||
line: "{{ git_rsapub['content'] | b64decode }}"
|
line: "{{ git_rsapub['content'] | b64decode }}"
|
||||||
|
insertbefore: BOF
|
||||||
|
|
||||||
- name: Create Gitea host script for SSH
|
- name: Create Gitea host script for SSH
|
||||||
template:
|
template:
|
||||||
@ -73,25 +67,11 @@
|
|||||||
template:
|
template:
|
||||||
src: docker-compose.yml.j2
|
src: docker-compose.yml.j2
|
||||||
dest: "{{ gitea_root }}/docker-compose.yml"
|
dest: "{{ gitea_root }}/docker-compose.yml"
|
||||||
notify: restart_gitea
|
|
||||||
|
|
||||||
- name: Install Gitea's docker-compose variables
|
- name: Install Gitea's docker-compose variables
|
||||||
template:
|
template:
|
||||||
src: compose-env.j2
|
src: compose-env.j2
|
||||||
dest: "{{ gitea_root }}/.env"
|
dest: "{{ gitea_root }}/.env"
|
||||||
notify: restart_gitea
|
|
||||||
|
|
||||||
- name: Install Gitea's Fail2ban filter
|
|
||||||
template:
|
|
||||||
src: fail2ban-filter.conf.j2
|
|
||||||
dest: /etc/fail2ban/filter.d/gitea.conf
|
|
||||||
notify: restart_fail2ban
|
|
||||||
|
|
||||||
- name: Install Gitea's Fail2ban jail
|
|
||||||
template:
|
|
||||||
src: fail2ban-jail.conf.j2
|
|
||||||
dest: /etc/fail2ban/jail.d/gitea.conf
|
|
||||||
notify: restart_fail2ban
|
|
||||||
|
|
||||||
- name: Start and enable Gitea service
|
- name: Start and enable Gitea service
|
||||||
service:
|
service:
|
||||||
|
@ -10,8 +10,6 @@ gitea_dbhost={{ gitea_dbhost }}
|
|||||||
gitea_dbname={{ gitea_dbname }}
|
gitea_dbname={{ gitea_dbname }}
|
||||||
gitea_dbuser={{ gitea_dbuser }}
|
gitea_dbuser={{ gitea_dbuser }}
|
||||||
gitea_dbpass={{ gitea_dbpass }}
|
gitea_dbpass={{ gitea_dbpass }}
|
||||||
gitea_proxy_limit={{ gitea_proxy_limit }}
|
|
||||||
gitea_trusted_proxies={{ gitea_trusted_proxies }}
|
|
||||||
{% if not gitea_signup %}
|
{% if not gitea_signup %}
|
||||||
gitea_disable_registration=true
|
gitea_disable_registration=true
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -12,7 +12,6 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- USER_UID={{ getent_passwd.git[1] }}
|
- USER_UID={{ getent_passwd.git[1] }}
|
||||||
- USER_GID={{ getent_group.git[1] }}
|
- USER_GID={{ getent_group.git[1] }}
|
||||||
- GITEA__log__MODE=file
|
|
||||||
- GITEA__server__ROOT_URL=${gitea_rooturl}
|
- GITEA__server__ROOT_URL=${gitea_rooturl}
|
||||||
- GITEA__server__DOMAIN=${gitea_domain}
|
- GITEA__server__DOMAIN=${gitea_domain}
|
||||||
- GITEA__server__SSH_DOMAIN=${gitea_domain}
|
- GITEA__server__SSH_DOMAIN=${gitea_domain}
|
||||||
@ -21,13 +20,10 @@ services:
|
|||||||
- GITEA__database__NAME=${gitea_dbname}
|
- GITEA__database__NAME=${gitea_dbname}
|
||||||
- GITEA__database__USER=${gitea_dbuser}
|
- GITEA__database__USER=${gitea_dbuser}
|
||||||
- GITEA__database__PASSWD=${gitea_dbpass}
|
- GITEA__database__PASSWD=${gitea_dbpass}
|
||||||
- GITEA__security__REVERSE_PROXY_LIMIT=${gitea_proxy_limit}
|
|
||||||
- GITEA__security__REVERSE_PROXY_TRUSTED_PROXIES=${gitea_trusted_proxies}
|
|
||||||
- GITEA__service__DISABLE_REGISTRATION=${gitea_disable_registration}
|
- GITEA__service__DISABLE_REGISTRATION=${gitea_disable_registration}
|
||||||
volumes:
|
volumes:
|
||||||
- {{ gitea_volume }}:/data
|
- {{ gitea_volume }}:/data
|
||||||
- /home/git/.ssh:/data/git/.ssh
|
- /home/git/.ssh/:/data/git/.ssh
|
||||||
- /var/log/gitea:/data/gitea/log
|
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
[Definition]
|
|
||||||
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
|
|
||||||
ignoreregex =
|
|
@ -1,18 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
[gitea]
|
|
||||||
enabled = true
|
|
||||||
filter = gitea
|
|
||||||
logpath = /var/log/gitea/gitea.log
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports
|
|
||||||
|
|
||||||
[gitea-docker]
|
|
||||||
enabled = true
|
|
||||||
filter = gitea
|
|
||||||
logpath = /var/log/gitea/gitea.log
|
|
||||||
maxretry = 10
|
|
||||||
findtime = 3600
|
|
||||||
bantime = 900
|
|
||||||
action = iptables-allports[chain="FORWARD"]
|
|
@ -32,10 +32,3 @@
|
|||||||
name: postgresql
|
name: postgresql
|
||||||
state: restarted
|
state: restarted
|
||||||
when: postgresql_config.changed
|
when: postgresql_config.changed
|
||||||
|
|
||||||
- name: Allow database connections from Docker
|
|
||||||
ufw:
|
|
||||||
rule: allow
|
|
||||||
port: "5432"
|
|
||||||
proto: tcp
|
|
||||||
src: "172.16.0.0/12"
|
|
||||||
|
@ -84,12 +84,3 @@
|
|||||||
loop: "{{ proxy.dns_cloudflare.wildcard_domains }}"
|
loop: "{{ proxy.dns_cloudflare.wildcard_domains }}"
|
||||||
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
|
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
|
||||||
notify: reload_nginx
|
notify: reload_nginx
|
||||||
|
|
||||||
- name: Add HTTP and HTTPS firewall rule
|
|
||||||
ufw:
|
|
||||||
rule: allow
|
|
||||||
port: "{{ item }}"
|
|
||||||
proto: tcp
|
|
||||||
loop:
|
|
||||||
- "80"
|
|
||||||
- "443"
|
|
||||||
|
@ -30,7 +30,6 @@ server {
|
|||||||
location / {
|
location / {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_pass {{ item.proxy_pass }};
|
proxy_pass {{ item.proxy_pass }};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user