Update gitea so that it uses podman's auto update policy
Plus some a bit of housekeeping
This commit is contained in:
1 parent
9531b42cdb
commit
19402b8bce
4 files changed
+196
-45
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user