Initial commit

This commit is contained in:
Julian Rother 2025-01-09 20:39:34 +01:00
commit 9235c2011e
Signed by: julian
GPG key ID: C19B924C0CD13341
5 changed files with 125 additions and 0 deletions

43
defaults/main.yml Normal file
View file

@ -0,0 +1,43 @@
forgejo_version: "7.0.12"
# See https://forgejo.org/docs/latest/admin/config-cheat-sheet/
forgejo_config:
DEFAULT:
WORK_PATH: /var/lib/forgejo
server:
# DOMAIN: localhost # Set this to your domain!
# ROOT_URL: https://localhost/ # Set this to your root url!
# SSH_DOMAIN: localhost
# LFS_JWT_SECRET: ... # Generate with `forgejo generate secret JWT_SECRET`
PROTOCOL: http
HTTP_ADDR: 127.0.0.1
HTTP_PORT: 3000
UNIX_SOCKET_PERMISSION: "660"
repository:
ROOT: /var/lib/forgejo/data/repos
DEFAULT_PRIVATE: "true"
database:
DB_TYPE: sqlite3
openid:
ENABLE_OPENID_SIGNIN: "false"
ENABLE_OPENID_SIGNUP: "false"
oauth2:
# JWT_SECRET: ... # Generate with `forgejo generate secret JWT_SECRET`
security:
INSTALL_LOCK: "true"
# SECRET_KEY: ... # Generate with `forgejo generate secret SECRET_KEY`
# INTERNAL_TOKEN: ... # Generate with `forgejo generate secret INTERNAL_TOKEN`
PASSWORD_HASH_ALGO: argon2
service:
# First registered user become admin, so we disable registration per default (at least initially)
# Create first user via CLI:
# sudo -u git forgejo --config /etc/forgejo/app.ini admin user create --admin --username forgejo-admin --password ... --email admin@localhost
DISABLE_REGISTRATION: "true"
DEFAULT_KEEP_EMAIL_PRIVATE: "true"
DEFAULT_USER_VISIBILITY: "limited"
DEFAULT_ORG_VISIBILITY: "limited"
ui:
SHOW_USER_EMAIL: "false"
other:
SHOW_FOOTER_VERSION: "false"
SHOW_FOOTER_TEMPLATE_LOAD_TIME: "false"

18
files/forgejo.service Normal file
View file

@ -0,0 +1,18 @@
[Unit]
Description=Forgejo
After=syslog.target
After=network.target
# TODO: After=DB/redis/...
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=~
ExecStart=/usr/local/sbin/forgejo web --config /etc/forgejo/app.ini
Restart=always
[Install]
WantedBy=multi-user.target

5
handlers/main.yml Normal file
View file

@ -0,0 +1,5 @@
- name: Restart forgejo
ansible.builtin.systemd_service:
name: forgejo
daemon_reload: true
state: restarted

50
tasks/main.yml Normal file
View file

@ -0,0 +1,50 @@
- name: Download forgejo binary
ansible.builtin.get_url:
url: "https://codeberg.org/forgejo/forgejo/releases/download/v{{ forgejo_version }}/forgejo-{{ forgejo_version }}-linux-amd64"
dest: "/usr/local/sbin/forgejo"
mode: "0755"
notify: Restart forgejo
- name: Create git group
ansible.builtin.group:
name: git
system: true
- name: Create git user
ansible.builtin.user:
name: git
group: git
home: /var/lib/forgejo
create_home: false
system: true
- name: Create data directory
ansible.builtin.file:
path: /var/lib/forgejo
owner: git
group: git
state: directory
mode: "0750"
- name: Create config directory
ansible.builtin.file:
path: /etc/forgejo
owner: root
group: git
state: directory
mode: "0750"
- name: Update config
ansible.builtin.template:
src: forgejo_app.ini.j2
dest: /etc/forgejo/app.ini
owner: root
group: git
mode: "0640"
notify: Restart forgejo
- name: Create systemd unit
ansible.builtin.copy:
src: forgejo.service
dest: /etc/systemd/system/forgejo.service
notify: Restart forgejo

View file

@ -0,0 +1,9 @@
{% for section_name, section in forgejo_config.items() %}
{% if section_name != 'DEFAULT' %}
[{{section_name}}]
{% endif %}
{% for key, value in section.items() %}
{{key}} = {{value}}
{% endfor %}
{% endfor %}