Initial working configuration.

Next step to refactor so its easier to read.
This commit is contained in:
Matt Spencer committed 2026-09-02 23:31:23 +01:00
1 parent 5aac7eebb8
commit 9531b42cdb
8 files changed
+185 -160

No files matched your search

@@ -34,7 +34,7 @@ server {
} }
location / { location / {
proxy_pass http://website:3000; proxy_pass http://m5p3nc3r:3000;
} }
} }
@@ -49,8 +49,16 @@ server {
add_header Strict-Transport-Security "max-age=31536000" always; add_header Strict-Transport-Security "max-age=31536000" always;
# Allow large pushes / LFS uploads (default is 1m!)
client_max_body_size 512m;
location / { location / {
proxy_pass http://gitea:3000; proxy_pass http://gitea:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
} }
} }
@@ -70,40 +78,6 @@ server {
} }
location / { location / {
proxy_pass http://apptabulous_website:3000; proxy_pass http://apptabulous:3000;
} }
} }
# Container registry
# server {
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name hub.apptabulous.co.uk;
# ssl_certificate /etc/letsencrypt/live/apptabulous.co.uk/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/apptabulous.co.uk/privkey.pem;
# # disable any limits to avoid HTTP 413 for large image uploads
# client_max_body_size 0;
# # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
# chunked_transfer_encoding on;
# location / {
# proxy_pass http://rpi4-2:5000;
# }
# }
# Watchtower
# server {
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name watchtower.apptabulous.co.uk;
# ssl_certificate /etc/letsencrypt/live/apptabulous.co.uk/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/apptabulous.co.uk/privkey.pem;
# location / {
# proxy_pass http://rpi4-2:8080;
# }
# }
+24
View File
@@ -102,6 +102,30 @@
state: present state: present
- name: Create certaccess group for letsencrypt certificate access
become: true
ansible.builtin.group:
name: certaccess
state: present
- name: Set certaccess group ownership on letsencrypt directories
become: true
ansible.builtin.file:
path: /etc/letsencrypt
group: certaccess
recurse: true
- name: Grant certaccess group read+execute access to letsencrypt
become: true
ansible.posix.acl:
path: /etc/letsencrypt
entity: certaccess
etype: group
permissions: rX
recursive: true
default: true
state: present
- name: Grant {{ username }} read access to letsencrypt certificates - name: Grant {{ username }} read access to letsencrypt certificates
become: true become: true
ansible.posix.acl: ansible.posix.acl:
+111 -74
View File
@@ -1,56 +1,101 @@
--- ---
# - import_playbook: reverse-proxy.yaml
- name: Frontend setup - name: Frontend setup
hosts: frontend hosts: frontend
vars: vars:
username: matt username: matt
#certbot_auto_renew_user: "{{ ansible_user | default(lookup('env', 'USER')) }}"
certbot_auto_renew_user: "root"
certbot_auto_renew_hour: "3"
certbot_auto_renew_minute: "30"
certbot_create_if_missing: true
certbot_admin_email: matthew@thespencers.me.uk
certbot_certs:
- domains:
- "apptabulous.co.uk"
- "www.apptabulous.co.uk"
- "hub.apptabulous.co.uk"
- "watchtower.apptabulous.co.uk"
webroot: "/var/www/html"
- domains:
- "m5p3nc3r.co.uk"
- "www.m5p3nc3r.co.uk"
- "gitea.m5p3nc3r.co.uk"
webroot: "/var/www/html"
certbot_repo: https://github.com/certbot/certbot.git
certbot_version: master
certbot_keep_updated: true
certbot_dir: /opt/certbot
certbot_create_extra_args: ""
docker_add_repo: true
docker_users:
- "{{ username }}"
roles: roles:
- role: geerlingguy.git - role: geerlingguy.git
become: true become: true
- role: geerlingguy.docker
become: true
- role: geerlingguy.certbot
become: true
tasks: tasks:
- name: Override default certbot start/stop jobs - name: Ensure SELinux configuration is set to enforcing
ansible.posix.selinux:
policy: targeted
state: enforcing
become: true become: true
- name: Allow container runtimes to use NFS shares (virt_use_nfs)
ansible.posix.seboolean:
name: virt_use_nfs
state: true
persistent: true
become: true
- name: Ensure target directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0700"
loop:
- "{{ certbot_dir }}"
- "{{ certbot_config_dir }}"
- "{{ certbot_config_dir }}/work"
- "{{ certbot_config_dir }}/logs"
- name: Deploy Cloudflare API credentials file
ansible.builtin.copy: ansible.builtin.copy:
src: letsencrypt dest: "{{ certbot_config_dir }}/cloudflare.ini"
dest: /etc content: |
dns_cloudflare_api_token = {{ cloudflare_api_token }}
mode: "0600"
- name: Install Certbot and Cloudflare plugin via Pip inside virtualenv
ansible.builtin.pip:
name:
- certbot
- certbot-dns-cloudflare
virtualenv: "{{ certbot_dir }}"
virtualenv_command: "python3 -m venv" # Forces Ansible to use Python's built-in module
state: present
- name: Generate Certificate Bundle 1 (apptabulous.co.uk)
ansible.builtin.command:
cmd: >
{{ certbot_dir }}/bin/certbot certonly --non-interactive --agree-tos
--config-dir {{ certbot_config_dir }}
--work-dir {{ certbot_config_dir }}/work
--logs-dir {{ certbot_config_dir }}/logs
--email {{ certbot_admin_email }}
--dns-cloudflare
--dns-cloudflare-credentials {{ certbot_config_dir }}/cloudflare.ini
--dns-cloudflare-propagation-seconds 20
-d apptabulous.co.uk
-d www.apptabulous.co.uk
-d hub.apptabulous.co.uk
-d watchtower.apptabulous.co.uk
creates: "{{ certbot_config_dir }}/live/apptabulous.co.uk/fullchain.pem"
- name: Generate Certificate Bundle 2 (m5p3nc3r.co.uk)
ansible.builtin.command:
cmd: >
{{ certbot_dir }}/bin/certbot certonly --non-interactive --agree-tos
--config-dir {{ certbot_config_dir }}
--work-dir {{ certbot_config_dir }}/work
--logs-dir {{ certbot_config_dir }}/logs
--email {{ certbot_admin_email }}
--dns-cloudflare
--dns-cloudflare-credentials {{ certbot_config_dir }}/cloudflare.ini
--dns-cloudflare-propagation-seconds 60
-d m5p3nc3r.co.uk
-d www.m5p3nc3r.co.uk
-d gitea.m5p3nc3r.co.uk
creates: "{{ certbot_config_dir }}/live/m5p3nc3r.co.uk/fullchain.pem"
- name: Setup User-level Cron for automated renewal
ansible.builtin.cron:
name: "User-space Certbot Renewal"
minute: "30"
hour: "3"
job: >
{{ certbot_dir }}/bin/certbot renew --non-interactive
--config-dir {{ certbot_config_dir }}
--work-dir {{ certbot_config_dir }}/work
--logs-dir {{ certbot_config_dir }}/logs
--post-hook "podman unshare restorecon -R {{ certbot_config_dir }}/live {{ certbot_config_dir }}/archive && podman kill --signal HUP reverse_proxy"
- name: Copy reverse proxy configuration to host - name: Copy reverse proxy configuration to host
become: true become: true
@@ -58,29 +103,36 @@
src: apptabulous/reverseproxy src: apptabulous/reverseproxy
dest: /etc dest: /etc
- name: Create webservices network
containers.podman.podman_network:
name: webservices
state: present
- name: Ensure /etc/reverseproxy/certs directory exists
become: true
ansible.builtin.file:
path: /etc/reverseproxy/certs
state: directory
owner: "{{ username }}"
group: "{{ username }}"
mode: "0755"
- name: Start reverse proxy container - name: Start reverse proxy container
community.docker.docker_container: containers.podman.podman_container:
name: reverse_proxy name: reverse_proxy
image: nginx:alpine image: nginx:alpine
restart_policy: always restart_policy: always
network: [webservices]
volumes: volumes:
- /etc/reverseproxy/nginx.conf:/etc/nginx/nginx.conf - /etc/reverseproxy/nginx.conf:/etc/nginx/nginx.conf
- /etc/reverseproxy/conf.d:/etc/nginx/conf.d - /etc/reverseproxy/conf.d:/etc/nginx/conf.d
- /etc/reverseproxy/stream.d:/etc/nginx/stream.d - /etc/reverseproxy/stream.d:/etc/nginx/stream.d
- /etc/letsencrypt:/etc/letsencrypt - /home/matt/.config/letsencrypt:/etc/letsencrypt:ro,z
ports: ports:
- "80:80" - "8080:80"
- "443:443" - "8443:443"
- "2222:2222" # No longer streaming ssh - so can remove this
state: started # - "2222:2222"
- name: Start docker registry
community.docker.docker_container:
name: registry
image: registry:2
restart_policy: always
ports:
- "5000:5000"
state: started state: started
- name: Log into ghcf.io registry - name: Log into ghcf.io registry
@@ -90,10 +142,11 @@
password: "{{ secrets.GITHUB_TOKEN }}" password: "{{ secrets.GITHUB_TOKEN }}"
- name: Start m5p3nc3r website - name: Start m5p3nc3r website
community.docker.docker_container: containers.podman.podman_container:
name: website name: m5p3nc3r
image: ghcr.io/m5p3nc3r/website:main image: ghcr.io/m5p3nc3r/website:main
restart_policy: always restart_policy: always
network: [webservices]
volumes: volumes:
- /home/matt/public/apps:/app/public/apps - /home/matt/public/apps:/app/public/apps
ports: ports:
@@ -103,27 +156,11 @@
state: started state: started
- name: Start Apptabulous website - name: Start Apptabulous website
community.docker.docker_container: containers.podman.podman_container:
name: apptabulous_website name: apptabulous
image: ghcr.io/m5p3nc3r/apptabulous_website:main image: ghcr.io/m5p3nc3r/apptabulous_website:main
restart_policy: always restart_policy: always
network: [webservices]
ports: ports:
- "3001:3000" - "3001:3000"
state: started state: started
- name: Start watchtower
community.docker.docker_container:
name: watchtower
image: nickfedor/watchtower
restart_policy: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/matt/.docker/config.json:/config.json
command:
- --cleanup
- --http-api-update
- --http-api-token={{ secrets.WATCHTOWER_HTTP_API_TOKEN }}
- --http-api-periodic-polls
ports:
- "8080:8080"
state: started
+3 -1
View File
@@ -37,6 +37,7 @@
name: virt_use_nfs name: virt_use_nfs
state: true state: true
persistent: true persistent: true
when: ansible_selinux.status == "enabled"
- name: Unmount NFS volumes before creating mountpoint directories - name: Unmount NFS volumes before creating mountpoint directories
become: true become: true
@@ -93,7 +94,8 @@
TZ: Europe/London TZ: Europe/London
volumes: volumes:
- /srv/gitea/data:/data:z - /srv/gitea/data:/data:z
- /mnt/gitea_repos:/data/git/repositories:z # No SELinux context modification for this volume (no :z)
- /mnt/gitea_repos:/data/git/repositories
ports: ports:
- "3002:3000" - "3002:3000"
- "2222:22" - "2222:22"
+12 -14
View File
@@ -11,28 +11,26 @@ all:
ryzen7: ryzen7:
ansible_host: ryzen7-1.local ansible_host: ryzen7-1.local
children: children:
monitored: # monitored:
hosts: # hosts:
rpi4-2: {} # rpi4-2: {}
# rpi5-1: {} # # rpi5-1: {}
rpi5-2: {} # rpi5-2: {}
monitoring_server: # monitoring_server:
hosts: # hosts:
rpi4-2: {} # rpi4-2: {}
frontend: frontend:
hosts: hosts:
rpi4-2: {} ryzen7: {}
frontend-cockpit: frontend-cockpit:
hosts: hosts:
ryzen7: {} ryzen7: {}
github-runners: github-runners:
hosts: hosts:
# rpi5-2: {}
ryzen7: {} ryzen7: {}
gitea: gitea:
hosts: hosts:
# rpi5-2: {}
ryzen7: {} ryzen7: {}
apt-cacher-ng: # apt-cacher-ng:
hosts: # hosts:
rpi4-2: {} # rpi4-2: {}
@@ -1,8 +0,0 @@
#!/bin/bash
# Ansible managed
#echo "starting service nginx"
#systemctl start nginx
echo "Restarting reverse_proxy container"
docker restart reverse_proxy
@@ -1,6 +0,0 @@
#!/bin/bash
# Ansible managed
#echo "stopping service nginx"
#systemctl stop nginx
docker stop reverse_proxy
+25 -21
View File
@@ -1,22 +1,26 @@
$ANSIBLE_VAULT;1.1;AES256 $ANSIBLE_VAULT;1.1;AES256
30373739346533376636623934363634373734316230386233333066666662656566613834643062 65313762326632623631633431386432373431373761633131383764323161623162373764383566
3234313933626566663563646539393132323466643564350a303932373831386564613738663865 6135663063356539656436303035633363623166643564330a326262353337336562396131643032
30393439643239316639303933376536353230393966373234336231306438386338663464333439 33363037363262313033643965636162316365343562316366656132363661333166636265383062
3831353636323437650a333837366433396236383333303738363862623730636539616330666663 6565326532316437350a393533323735643932353234663966376565343431646333646531386163
62623839616131623837336537636434353237666434386437633066346365646437366363356333 61393664666261346666366632633564653035653238306630373066623835646536633439363333
32356135613062366566323637383730343230623937646661666464343436666533643838333664 61666537373934353566363231643834343964663634633438623865396239626363316633646362
38303039633435366334613934653639386661663065386334383765393237386663353865383830 32653364323066383930636534643735653431303365346134633763366538643564663638303631
31366138383834643438303535383134306430383739326233643438383432366539393539386637 34366234653534363237393237623265646136353734333934386139656132633034373233386164
32313635383661303435643936363633326662306235303764643163323965303165353065313530 31393435623633613738333439343430656664363432383865633537366266663334333535336131
39613766343736653163366434383832303539646633636134313134383733303632633130376131 33373832343038623336616662343261396637303531303137336239393461393061346435313332
65313862653437313534663164383561653033313663383637363865386365663639306137626465 37646538393139316531383265623231636232346634366231303764373739653861376338316537
63653266636433333362356261653965313261666338323333393339353530356466653463303634 63386432343165353734646335346164373761326264383261633536343539373663646336333165
38313836663465643361316363363364343665356565303836356433363461383331336237376561 63303130303934663534623533633762303263316539316464323763373566623833653432633638
37316431396364626431313530306466663238303736623335336132663236353864663066383639 32306338623236666135643739333734633261366237326335363137653633653565353662656334
34386261353664336332363032333130613963613539623965303261363339633064663739326532 33383762616439316636636639326462633064373461363239323539393564313332393439396533
66323338346134303762646134663336356666326135346264343931653035323136333031323331 65613033663630356631356433666332633661313435333031636436373937613464643933333839
38393861383136653866666138626639613837616264633031343639323036653563383661633434 65353836303666316539313835313964353465613163613430356337326431363331643764623937
30343136636632613838333538393466316664316261343766343635353132666233633936363931 30633363386339623237396239346131313964343632663637656234633962656431666661333937
62313430323230616138643463643239373465313435663430343433643335363362303264366464 36633630336431393064646232383439303432353739306466663261393038653964636136663563
61663034353165323237636465303131346366626361643531616266633435303065613434396633 39663866626162623938633462616262623137353234626537313639343439366434666439376261
6663 36396131633836306636396337626663356533363637383632613630333864613136366366633439
37633235326562366563346438343133633165393931306336356665343234636436616134333161
39396231643832643034663831646165636463323333373233336363613437623665653030353363
61303334363166653161316662623930633837373866613935646339636566613432623334626365
6261