Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Improve Debian 12 compatibility, bump Adguard, Alpine and Unbound versions #288

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d052417
Explicitly install iptables
notthebee Oct 15, 2023
0e06245
Adjust ansible-lint, attempt to fix syntax error when password contai…
notthebee Oct 15, 2023
89e64af
Merge remote-tracking branch 'origin/main' into dev
notthebee Dec 10, 2023
48df9cd
Improve iptables compatibility, add Debian 12 testing
notthebee Dec 10, 2023
9df334b
Add watchtower to automatically update Docker containers
notthebee Dec 10, 2023
9bb4140
Disable Adguard logs and anonymize client IPs by default
notthebee Dec 10, 2023
ab8428e
Redirect to the Wireguard host by default after succesfull auth
notthebee Dec 10, 2023
9aef468
Fixup
notthebee Dec 10, 2023
cc1997a
Fixup
notthebee Dec 10, 2023
9935b1b
Fixup
notthebee Dec 10, 2023
23503e6
Add missing matrix for debian 12
notthebee Dec 10, 2023
0a43ac3
Roll back the redirection URI
notthebee Dec 10, 2023
a47c05e
Switch to GH releases for the wg-easy docker image
notthebee Dec 31, 2023
e133a25
Upload selenium screenshots as artifacts
notthebee Dec 31, 2023
d56ef71
Fixup
notthebee Dec 31, 2023
668ad99
Fixup
notthebee Dec 31, 2023
c1bb290
Fixup
notthebee Dec 31, 2023
89bc72c
Revert bunkerweb to 1.4.2
notthebee Dec 31, 2023
dce9db5
Fixup
notthebee Dec 31, 2023
3924f07
Merge remote-tracking branch 'origin/main' into dev
notthebee Apr 2, 2024
7239a9e
Modify testing workflow, bump unbound, alpine and adguard versions, f…
notthebee Apr 2, 2024
09643cd
Fix the cloudflare record deletion shell script
notthebee Apr 2, 2024
e261d0e
Debug the WebUI testing
notthebee Apr 3, 2024
ca57113
Add more sleep
notthebee Apr 3, 2024
f89c291
Remove hardcoded ssh key
notthebee Apr 3, 2024
a64199d
Modify healthcheck for bunkerweb, fix testing script
notthebee Apr 3, 2024
c706ec2
Fix tests, attempt to fix fail2ban
notthebee Apr 3, 2024
da8316c
Debug fail2ban
notthebee Apr 3, 2024
7b0ac8e
Debug fail2ban
notthebee Apr 3, 2024
63059e9
Modify debug step for GH actions
notthebee Apr 4, 2024
1bac250
Modify debug step for GH actions
notthebee Apr 4, 2024
6561fa9
Debug fail2ban
notthebee Apr 4, 2024
e82e784
Debug fail2ban
notthebee Apr 4, 2024
42734bd
[skip ci] Debug fail2ban
notthebee Apr 4, 2024
4bdb19c
[skip ci] Debug fail2ban
notthebee Apr 4, 2024
dc9b556
Add missing fail2ban dependency
notthebee Apr 4, 2024
c38928d
Remove f2b checks
notthebee Apr 4, 2024
33c9b2e
Debug ci/cd testing
notthebee Apr 4, 2024
5db3a20
Fix adguard Dockerfile template
notthebee Apr 4, 2024
f4b5e10
Fix personal SSH key
notthebee Apr 5, 2024
5d674d0
Modify testing
notthebee Apr 5, 2024
1811b2e
Fixup
notthebee Apr 5, 2024
3fdd71e
Fixup
notthebee Apr 5, 2024
5d79257
Fixup
notthebee Apr 5, 2024
3a2fbcd
Fix screenshot path
notthebee Apr 5, 2024
76594b4
Try to debug missing secret field on ubuntu
notthebee Apr 5, 2024
b9ffcbe
Fixup
notthebee Apr 5, 2024
ed5e3a8
Debug the secret uri again...
notthebee Apr 5, 2024
e9d6c6d
Set DNS to Cloudflare during Docker build
notthebee Apr 5, 2024
cec942a
Debug testing
notthebee Apr 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 44 additions & 98 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,8 @@ jobs:
- name: Set the username and password outputs
id: random_username
run: |
case $INDEX in
"1")
echo "EASYVPN_USERNAME_1=$EASYVPN_USERNAME" >> $GITHUB_OUTPUT
echo "EASYVPN_PASSWORD_1=$EASYVPN_PASSWORD" >> $GITHUB_OUTPUT
;;
"2")
echo "EASYVPN_USERNAME_2=$EASYVPN_USERNAME" >> $GITHUB_OUTPUT
echo "EASYVPN_PASSWORD_2=$EASYVPN_PASSWORD" >> $GITHUB_OUTPUT
;;
"3")
echo "EASYVPN_USERNAME_3=$EASYVPN_USERNAME" >> $GITHUB_OUTPUT
echo "EASYVPN_PASSWORD_3=$EASYVPN_PASSWORD" >> $GITHUB_OUTPUT
;;
"4")
echo "EASYVPN_USERNAME_4=$EASYVPN_USERNAME" >> $GITHUB_OUTPUT
echo "EASYVPN_PASSWORD_4=$EASYVPN_PASSWORD" >> $GITHUB_OUTPUT
;;
*)
exit 1
;;
esac
echo "EASYVPN_USERNAME_$INDEX=$EASYVPN_USERNAME" >> $GITHUB_OUTPUT
echo "EASYVPN_PASSWORD_$INDEX=$EASYVPN_PASSWORD" >> $GITHUB_OUTPUT
env:
INDEX: ${{ matrix.index }}

Expand All @@ -161,8 +142,6 @@ jobs:
- name: Install git and expect (Debian-based)
run: ssh root@$SERVER_IPV4 apt install -y git expect wamerican



- uses: infraway/[email protected]
with:
type: "A"
Expand Down Expand Up @@ -229,8 +208,6 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}



- name: Regsiter the private key with the ssh-agent
run: expect -c "spawn ssh-add $HOME/.ssh/id_vpn; expect -re \"Enter passphrase.*\"; send -- \"$EASYVPN_PASSWORD\r\"; expect -re \"Identity added.*\""

Expand All @@ -251,46 +228,17 @@ jobs:
env:
LETSENCRYPT_STAGING: ${{ needs.matrix_prep.outputs.letsencrypt_staging }}

- name: Sleep forever
run: sleep infinity
if: inputs.manual_mode

- name: Archive the private SSH key (Matrix 1)
if: ${{ matrix.index == '1' }}
uses: actions/upload-artifact@v3
with:
name: "private-ssh-key-1"
path: "id_vpn"

- name: Archive the private SSH key (Matrix 2)
if: ${{ matrix.index == '2' }}
uses: actions/upload-artifact@v3
with:
name: "private-ssh-key-2"
path: "id_vpn"

- name: Archive the private SSH key (Matrix 3)
if: ${{ matrix.index == '3' }}
uses: actions/upload-artifact@v3
with:
name: "private-ssh-key-3"
path: "id_vpn"
- name: Add the personal SSH key for debugging
run: >-
curl https://github.com/notthebee.keys > notthebee.pub &&
ssh-copy-id -f -i notthebee.pub $EASYVPN_USERNAME@$SERVER_IPV4

- name: Archive the private SSH key (Matrix 4)
if: ${{ matrix.index == '4' }}
- name: Archive the private SSH key
uses: actions/upload-artifact@v3
with:
name: "private-ssh-key-4"
name: "private-ssh-key-${{ matrix.index }}"
path: "id_vpn"









outputs:
EASYVPN_USERNAME_1: "${{ steps.random_username.outputs.EASYVPN_USERNAME_1 }}"
EASYVPN_USERNAME_2: "${{ steps.random_username.outputs.EASYVPN_USERNAME_2 }}"
Expand All @@ -301,6 +249,22 @@ jobs:
EASYVPN_PASSWORD_3: "${{ steps.random_username.outputs.EASYVPN_PASSWORD_3 }}"
EASYVPN_PASSWORD_4: "${{ steps.random_username.outputs.EASYVPN_PASSWORD_4 }}"


debug:
runs-on: ubuntu-latest
environment: cicd
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
needs:
- matrix_prep
- build
steps:
- name: Wait for the server to reboot
if: inputs.manual_mode
run: >-
sleep infinity

fetch_config:
runs-on: ubuntu-latest
environment: cicd
Expand All @@ -309,6 +273,7 @@ jobs:
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
needs:
- matrix_prep
- debug
- build
steps:
- name: Check out this repo
Expand All @@ -327,36 +292,12 @@ jobs:
run: >-
mkdir /home/runner/.ssh

- name: Get the private SSH key artifact (Matrix 1)
if: matrix.index == '1'
- name: Get the private SSH key artifact
uses: actions/download-artifact@v3
with:
name: "private-ssh-key-1"
name: "private-ssh-key-${{ matrix.index }}"
path: /home/runner/.ssh

- name: Get the private SSH key artifact (Matrix 2)
if: matrix.index == '2'
uses: actions/download-artifact@v3
with:
name: "private-ssh-key-2"
path: /home/runner/.ssh

- name: Get the private SSH key artifact (Matrix 3)
if: matrix.index == '3'
uses: actions/download-artifact@v3
with:
name: "private-ssh-key-3"
path: /home/runner/.ssh

- name: Get the private SSH key artifact (Matrix 4)
if: matrix.index == '4'
uses: actions/download-artifact@v3
with:
name: "private-ssh-key-4"
path: /home/runner/.ssh



- name: Set the correct permissions for the SSH key
run: |
chmod 700 $HOME/.ssh
Expand Down Expand Up @@ -401,8 +342,14 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: "Screenshots"
path: "screenshots/"
name: "Screenshots-${{ matrix.index }}"
path: "/home/runner/screenshots/*"

- name: Archive the Wireguard config
uses: actions/upload-artifact@v3
with:
name: "wireguard-${{ matrix.index }}.conf"
path: "*.conf"

destroy:
runs-on: ubuntu-latest
Expand All @@ -414,6 +361,7 @@ jobs:
needs:
- matrix_prep
- build
- debug
- fetch_config
steps:
- name: Destroy the Hetzner instances
Expand All @@ -428,16 +376,14 @@ jobs:
SERVER_NAME: ansible-easy-vpn-${{ needs.build.outputs[format('EASYVPN_USERNAME_{0}', matrix.index)] }}

- name: Delete all Cloudflare domains
run: >-
curl -s -X GET https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records?per_page=500
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
-H "Content-Type: application/json" |
jq .result[].id |
tr -d '"' |
( while read id; do curl -s -X DELETE
https://api.cloudflare.com/client/v4/zones/5420f91fefac252d89d9495a8d35ae73/dns_records/${id}
-H "Authorization: Bearer $CLOUDFLARE_TOKEN"
-H "Content-Type: application/json"; done; )
run: |
curl --silent "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?per_page=50000" \
--header "Authorization: Bearer $CLOUDFLARE_TOKEN" \
| jq --raw-output '.result[].id' | while read id
do
curl --silent --request DELETE "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$id" \
--header "Authorization: Bearer $CLOUDFLARE_TOKEN"
done
env:
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ secret.yml
.vscode
.venv
.ansible
venv*
2 changes: 1 addition & 1 deletion roles/bunkerweb/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
name: "bunkerweb"
image: "bunkerity/bunkerweb:{{ bunkerweb_version }}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
test: ["CMD", "curl", "-f", "http://localhost:80"]
start_period: 10s
networks:
- name: wg_network
Expand Down
34 changes: 0 additions & 34 deletions roles/dns/files/adguard-unbound/Dockerfile

This file was deleted.

10 changes: 9 additions & 1 deletion roles/dns/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
state: directory
owner: "{{ username }}"
group: "{{ username }}"
mode: 0755
mode: "0755"
loop:
- adguard-unbound-doh
- adguard-unbound-doh/adguard
Expand All @@ -22,6 +22,14 @@
rsync_opts:
- "--ignore-existing"

- name: Template the Adguard Dockerfile
ansible.builtin.template:
src: Dockerfile
dest: "{{ docker_dir }}/adguard-unbound-doh/build/Dockerfile"
owner: "{{ username }}"
group: "{{ username }}"
mode: "0775"

- name: Build the adguard-unbound Docker image
community.docker.docker_image:
name: adguard-unbound-doh
Expand Down
9 changes: 5 additions & 4 deletions roles/dns/templates/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@

FROM alpine:3.15
FROM alpine:3.18

RUN apk add --no-cache \
libcap \
unbound=1.13.2-r2 \
unbound=1.19.3-r0 \
dnscrypt-proxy

WORKDIR /tmp

RUN wget https://www.internic.net/domain/named.root -qO- >> /etc/unbound/root.hints
RUN echo "nameserver 1.1.1.1" > /etc/resolv.conf && \
wget https://www.internic.net/domain/named.root -qO- >> /etc/unbound/root.hints

COPY files/ /opt/

# AdGuardHome
RUN wget https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.16/AdGuardHome_linux_{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}.tar.gz >/dev/null 2>&1 \
RUN wget https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.46/AdGuardHome_linux_{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}.tar.gz >/dev/null 2>&1 \
&& mkdir -p /opt/adguardhome/conf /opt/adguardhome/work \
&& tar xf AdGuardHome_linux_{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}.tar.gz ./AdGuardHome/AdGuardHome --strip-components=2 -C /opt/adguardhome \
&& /bin/ash /opt/adguardhome \
Expand Down
7 changes: 4 additions & 3 deletions roles/fail2ban/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
- name: Install fail2ban
ansible.builtin.package:
name: fail2ban
state: present
ansible.builtin.apt:
name:
- fail2ban
- python3-systemd

- name: Disable e-mail notifications on jail stop and start
ansible.builtin.copy:
Expand Down
23 changes: 12 additions & 11 deletions roles/fail2ban/templates/jail.local.j2
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[DEFAULT]
banaction = iptables-allports
bantime = -1
findtime = 600
maxretry = 5
ignoreip = 127.0.0.1/8 ::1
action = %(action_mwl)s
destemail = {{ email }}
sender = {{ email }}
banaction=iptables-allports
bantime=-1
findtime=600
maxretry=5
ignoreip=127.0.0.1/8 ::1
action=%(action_mwl)s
destemail={{ email }}
sender={{ email }}

[sshd]
enabled = true
port = {{ ssh_port }}
filter = sshd
backend=systemd
enabled=true
port={{ ssh_port }}
filter=sshd
5 changes: 5 additions & 0 deletions roles/system/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Restart iptables
ansible.builtin.service:
name: iptables
state: restarted
1 change: 1 addition & 0 deletions roles/system/tasks/firewall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
cmd: "which iptables-restore"

- name: Template the iptables systemd service
notify: Restart iptables
ansible.builtin.template:
src: systemd/iptables.service.j2
dest: /etc/systemd/system/iptables.service
Expand Down
Loading
Loading