Update gitea so that it uses podman's auto update policy

Plus some a bit of housekeeping
This commit is contained in:
Matt Spencer committed 2026-10-19 14:19:10 +01:00
1 parent 9531b42cdb
commit 19402b8bce
4 files changed
+196 -45

No files matched your search

+5
View File
@@ -7,6 +7,11 @@
vars:
username: matt
certbot_dir: "{{ ansible_env.HOME }}/.local/share/certbot"
certbot_config_dir: "{{ ansible_env.HOME }}/.config/letsencrypt"
cloudflare_api_token: "{{ lookup('env', 'CLOUDFLARE_API_TOKEN') }}"
certbot_admin_email: "{{ lookup('env', 'CERTBOT_ADMIN_EMAIL') }}"
roles:
- role: geerlingguy.git
become: true
+39 -20
View File
@@ -80,26 +80,45 @@
name: webservices
state: present
- name: Start gitea
containers.podman.podman_container:
name: gitea
image: docker.io/gitea/gitea:latest
restart_policy: always
network: webservices
label:
io.containers.autoupdate: registry
env:
USER_UID: "{{ gitea_uid }}"
USER_GID: "{{ gitea_gid }}"
TZ: Europe/London
volumes:
- /srv/gitea/data:/data:z
# No SELinux context modification for this volume (no :z)
- /mnt/gitea_repos:/data/git/repositories
ports:
- "3002:3000"
- "2222:22"
state: started
- name: Create Podman systemd directory for user
ansible.builtin.file:
path: "/home/{{ username }}/.config/containers/systemd"
state: directory
mode: '0755'
owner: "{{ username }}"
group: "{{ username }}"
- name: Deploy Gitea Quadlet configuration
ansible.builtin.copy:
dest: "/home/{{ username }}/.config/containers/systemd/gitea.container"
owner: "{{ username }}"
mode: '0644'
content: |
[Container]
ContainerName=gitea
Image=docker.io/gitea/gitea:latest
Network=webservices
AutoUpdate=registry
Environment=USER_UID={{ gitea_uid }} USER_GID={{ gitea_gid }} TZ=Europe/London
Volume=/srv/gitea/data:/data:z
Volume=/mnt/gitea_repos:/data/git/repositories
PublishPort=3002:3000
PublishPort=2222:22
[Service]
Restart=always
[Install]
WantedBy=default.target
register: gitea_quadlet
- name: Reload user systemd and ensure gitea is started
ansible.builtin.systemd:
daemon_reload: true
name: gitea.service
enabled: true
state: "{{ gitea_quadlet.changed | ternary('restarted', 'started') }}"
scope: user
- name: Enable lingering for {{ username }}
become: true
+127
View File
@@ -0,0 +1,127 @@
- name: Reverse proxy setup
hosts: frontend
vars:
username: matt
# Set standard Certbot parameters
certbot_dir: "{{ ansible_env.HOME }}/.local/share/certbot"
certbot_config_dir: "{{ ansible_env.HOME }}/.config/letsencrypt"
certbot_admin_email: "matthew@thespencers.me.uk"
cloudflare_api_token: "{{ secrets.CLOUDFLARE_API_TOKEN }}"
tasks:
- name: Ensure SELinux configuration is set to enforcing
ansible.posix.selinux:
policy: targeted
state: enforcing
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:
dest: "{{ certbot_config_dir }}/cloudflare.ini"
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
become: true
ansible.builtin.copy:
src: apptabulous/reverseproxy
dest: /etc
- name: Create webservices network
containers.podman.podman_network:
name: webservices
state: present
- name: Start reverse proxy container
containers.podman.podman_container:
name: reverse_proxy
image: nginx:alpine
restart_policy: always
network: [webservices]
volumes:
- /etc/reverseproxy/nginx.conf:/etc/nginx/nginx.conf
- /etc/reverseproxy/conf.d:/etc/nginx/conf.d
- /etc/reverseproxy/stream.d:/etc/nginx/stream.d
- /home/matt/.config/letsencrypt:/etc/letsencrypt:ro,z
ports:
- "8080:80"
- "8443:443"
# No longer streaming ssh - so can remove this
# - "2222:2222"
state: started
+25 -25
View File
@@ -1,26 +1,26 @@
$ANSIBLE_VAULT;1.1;AES256
65313762326632623631633431386432373431373761633131383764323161623162373764383566
6135663063356539656436303035633363623166643564330a326262353337336562396131643032
33363037363262313033643965636162316365343562316366656132363661333166636265383062
6565326532316437350a393533323735643932353234663966376565343431646333646531386163
61393664666261346666366632633564653035653238306630373066623835646536633439363333
61666537373934353566363231643834343964663634633438623865396239626363316633646362
32653364323066383930636534643735653431303365346134633763366538643564663638303631
34366234653534363237393237623265646136353734333934386139656132633034373233386164
31393435623633613738333439343430656664363432383865633537366266663334333535336131
33373832343038623336616662343261396637303531303137336239393461393061346435313332
37646538393139316531383265623231636232346634366231303764373739653861376338316537
63386432343165353734646335346164373761326264383261633536343539373663646336333165
63303130303934663534623533633762303263316539316464323763373566623833653432633638
32306338623236666135643739333734633261366237326335363137653633653565353662656334
33383762616439316636636639326462633064373461363239323539393564313332393439396533
65613033663630356631356433666332633661313435333031636436373937613464643933333839
65353836303666316539313835313964353465613163613430356337326431363331643764623937
30633363386339623237396239346131313964343632663637656234633962656431666661333937
36633630336431393064646232383439303432353739306466663261393038653964636136663563
39663866626162623938633462616262623137353234626537313639343439366434666439376261
36396131633836306636396337626663356533363637383632613630333864613136366366633439
37633235326562366563346438343133633165393931306336356665343234636436616134333161
39396231643832643034663831646165636463323333373233336363613437623665653030353363
61303334363166653161316662623930633837373866613935646339636566613432623334626365
6261
35393163373439633663623964633163363861326565663738663561636330343036333165353430
3530626461336235663263343061313762643234356462620a303162653061393362346230636461
38666238363264653539363763633134366366393963643266376261353437653135643433333964
3730306166373164350a623761376435353064636532376565363966316630376436343330323733
30623061376164396436313934316335326530346238303066643536653935626234623966383230
30306531636137623762343564656336393230356630393130633539646139613139393561396564
30656130616365326662353232623539363732616361626233653330353665393862376262613237
36333037653666623838623066343666306239316561326535643830303966613431326263393730
65303637363937353433646632363132343635313933623130376635656636613631656662663763
37633837306163393431396134366534323133373336376633396561343937333832653338343738
39636637313965316362363437326463386363616338396130353864636439656537363632363130
61303165616637363937396135373634343566663638333266663864623234373738356239616565
38376264613462383339653834666531386432663466306130626135333532386563653739646434
33323462613266343237633533343265336130373161393864366231643739376531393362653234
63316231323435313334363938616130343037346263656165383265373933636636366139333464
61616264393039666563383562393864396131373863616138333361306632626531323633383735
36306539336164663861663738373339643631613666346162376663393166333131663937336434
37353662336438316335303138383266653661363237353066653536373839663031623264346661
65373666663362383432623634393234653464623566346236616537386233346566616266343366
31373638373235626466653166333331643234656361653162366236353439343532366438366561
38303036343266653765353364626338346635373331333762633938353530366635346430386666
38373332316332653632653435353836353537363262313166323231616538363864323230343662
61616366393236353936303231306164646439313537343931653832316563636332643762343662
35383832373436383038623734323639643636636437303831346336386462393635623135393365
6336