Three seeding tasks used copy without force: false, so every run replaced the real file with the starter one: - personal-blog: the placeholder index.html over the deployed site. - lnbits: .env.example over .env - a new AUTH_SECRET_KEY, logging every user out, and it would have clobbered a restored .env. - forgejo: a two-line app.ini stub over the real config, losing INTERNAL_TOKEN, the JWT secrets, the DB path and ROOT_URL. All three now seed a fresh install only. Found while restoring each from backup on 2026-10-17. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
96 lines
2.6 KiB
YAML
96 lines
2.6 KiB
YAML
- name: Install Forgejo on Debian 12 with Caddy reverse proxy
|
|
hosts: edge
|
|
become: yes
|
|
vars_files:
|
|
- ./forgejo_vars.yml
|
|
vars:
|
|
forgejo_subdomain: "{{ subdomains.forgejo }}"
|
|
forgejo_domain: "{{ forgejo_subdomain }}.{{ root_domain }}"
|
|
|
|
tasks:
|
|
- name: Ensure required packages are installed
|
|
apt:
|
|
name:
|
|
- git
|
|
- git-lfs
|
|
- wget
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Download Forgejo binary
|
|
get_url:
|
|
url: "{{ forgejo_url }}"
|
|
dest: "/tmp/forgejo"
|
|
mode: '0755'
|
|
|
|
- name: Move Forgejo binary to /usr/local/bin
|
|
copy:
|
|
src: "/tmp/forgejo"
|
|
dest: "{{ forgejo_bin_path }}"
|
|
remote_src: yes
|
|
mode: '0755'
|
|
|
|
- name: Create git system user
|
|
user:
|
|
name: "{{ forgejo_user }}"
|
|
system: yes
|
|
shell: /bin/bash
|
|
home: "/home/{{ forgejo_user }}"
|
|
create_home: yes
|
|
comment: 'Git Version Control'
|
|
|
|
- name: Create Forgejo data directory
|
|
file:
|
|
path: "{{ forgejo_data_dir }}"
|
|
state: directory
|
|
owner: "{{ forgejo_user }}"
|
|
group: "{{ forgejo_user }}"
|
|
mode: '0750'
|
|
|
|
- name: Create Forgejo config directory
|
|
file:
|
|
path: "{{ forgejo_config_dir }}"
|
|
state: directory
|
|
owner: "{{ forgejo_user }}"
|
|
group: "{{ forgejo_user }}"
|
|
mode: '0770'
|
|
|
|
- name: Create Forgejo config file
|
|
ansible.builtin.copy:
|
|
dest: "{{ forgejo_config_dir }}/app.ini"
|
|
content: |
|
|
APP_NAME = ; Countergit
|
|
|
|
[server]
|
|
HTTP_PORT = {{ forgejo_port }}
|
|
owner: "{{ forgejo_user }}"
|
|
group: "{{ forgejo_user }}"
|
|
mode: '0644'
|
|
# Fresh install only: the web installer then writes the real config
|
|
# (INTERNAL_TOKEN, JWT secrets, DB path, ROOT_URL) into this file.
|
|
# Without force: false every re-run replaced it with this stub.
|
|
force: false
|
|
|
|
- name: Download Forgejo systemd service file
|
|
get_url:
|
|
url: "{{ forgejo_service_url }}"
|
|
dest: "/etc/systemd/system/forgejo.service"
|
|
mode: '0644'
|
|
|
|
- name: Reload systemd
|
|
systemd:
|
|
daemon_reload: yes
|
|
|
|
- name: Enable and start Forgejo service
|
|
systemd:
|
|
name: forgejo
|
|
enabled: yes
|
|
state: started
|
|
|
|
- name: Publish Forgejo through Caddy
|
|
ansible.builtin.include_role:
|
|
name: caddy_site
|
|
vars:
|
|
caddy_site_name: forgejo
|
|
caddy_site_domain: "{{ forgejo_domain }}"
|
|
caddy_site_upstream: "localhost:{{ forgejo_port }}"
|