From 1cb903924a120d94953111c16a86a7b12765ae5b Mon Sep 17 00:00:00 2001
From: L3D <l3d@c3woc.de>
Date: Sun, 21 Mar 2021 17:29:04 +0100
Subject: [PATCH] reorder gitea server variables

---
 README.md              | 16 ++++++++++-----
 defaults/main.yml      | 13 +++++++-----
 templates/gitea.ini.j2 | 45 ++++++++++++++++++------------------------
 3 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/README.md b/README.md
index e42ac2e..0e11f33 100644
--- a/README.md
+++ b/README.md
@@ -95,7 +95,7 @@ Here is a deeper insight into the variables of this gitea role. For the exact fu
 | `gitea_themes` | `gitea,arc-green` | List of enabled themes |
 | `gitea_ui_extra_config` | `''` | you can use this variable to pass additional config parameters in the `[ui]` section of the config. |
 
-### Server [server](https://docs.gitea.io/en-us/config-cheat-sheet/#server-server)
+### Server ([server](https://docs.gitea.io/en-us/config-cheat-sheet/#server-server))
 | variable name | default value | description |
 | ------------- | ------------- | ----------- |
 | `gitea_protocol`| `http` | Listening protocol [http, https, fcgi, unix, fcgi+unix] |
@@ -108,6 +108,16 @@ Here is a deeper insight into the variables of this gitea role. For the exact fu
 | `gitea_ssh_domain` | `{{ gitea_http_domain ` |  Domain name of this server, used for displayed clone URL |
 | `gitea_ssh_port` | `2222` | SSH port displayed in clone URL. |
 | `gitea_ssh_listen` | `0.0.0.0` | Listen address for the built-in SSH server. |
+| `gitea_offline_mode` | `true` | Disables use of CDN for static files and Gravatar for profile pictures. (true/false) |
+| `gitea_lfs_enabled` | `false` | Enable GIT-LFS Support *(git large file storeage: [git-lfs](https://git-lfs.github.com/))*. |
+| `gitea_lfs_content_path` | `{{ gitea_home }}/data/lfs` |  LFS content path. *(if it is on local storage.)* |
+| `gitea_lfs_jwt_secret` | `''` | LFS authentication secret. Can be generated with ``gitea generate secret JWT_SECRET``. Will be autogenerated if not defined |
+| `gitea_server_extra_config` | `''` | you can use this variable to pass additional config parameters in the `[ui]` section of the config. |
+
+### Database ([database](https://docs.gitea.io/en-us/config-cheat-sheet/#database-database))
+| variable name | default value | description |
+| ------------- | ------------- | ----------- |
+
 
 
 
@@ -117,7 +127,6 @@ Here is a deeper insight into the variables of this gitea role. For the exact fu
 | `gitea_disable_gravatar` | `true` | Do you want to disable Gravatar ? (privacy and so on) (true/false) |
 | `gitea_disable_registration` | `false` | Do you want to disable user registration? (true/false) |
 | `gitea_register_email_confirm` | `false` | Enable this to ask for mail confirmation of registration. Requires `gitea_mailer_enabled` to be enabled. |
-| `gitea_offline_mode` | `true` | Disables use of CDN for static files and Gravatar for profile pictures. (true/false) |
 | `gitea_only_allow_external_registration` | `false` | Set to true to force registration only using third-party services (true/false) |
 | `gitea_show_registration_button` | `true` | Here you can hide the registration button. This will not disable registration! (true/false)|
 | `gitea_require_signin` | `true` | Do you require a signin to see repo's (even public ones)? (true/false)|
@@ -132,7 +141,6 @@ Here is a deeper insight into the variables of this gitea role. For the exact fu
 | `gitea_secret_key` | `''` | Global secret key. Will be autogenerated if not defined. Should be unique. |
 | `gitea_internal_token` | `''` | Internal API token. Will be autogenerated if not defined. Should be unique. |
 | `gitea_disable_git_hooks` | `true` | Set to false to enable users with git hook privilege to create custom git hooks. Can be dangerous. |
-| `gitea_lfs_secret` | `''` | < JWT secret for remote LFS usage. Can be generated with ``gitea generate secret JWT_SECRET``. Will be autogenerated if not defined |
 | `gitea_oauth2_jwt_secret` | `''` | Oauth2 JWT secret. Can be generated with ``gitea generate secret JWT_SECRET``. Will be autogenerated if not defined. |
 
 
@@ -166,8 +174,6 @@ Here is a deeper insight into the variables of this gitea role. For the exact fu
 
 ### LFS configuration
 
-* `gitea_lfs_enabled`: Enable GIT LFS *(git large file storeage: [git-lfs](https://git-lfs.github.com/))*. Default: `false`
-* `gitea_lfs_content_path`: path where the lfs files are stored
 
 ### Log configuration
 * `gitea_log_systemd` Disable logging into `file`, use systemd-journald
diff --git a/defaults/main.yml b/defaults/main.yml
index 372bea9..b233e45 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -43,15 +43,20 @@ gitea_http_port: '3000'
 # gitea_http_letsencrypt_mail: 'mail@example.com'
 gitea_start_ssh: true
 gitea_ssh_domain: "{{ gitea_http_domain }}"
-gitea_ssh_port: 2222
-gitea_ssh_listen: 0.0.0.0
+gitea_ssh_port: '2222'
+gitea_ssh_listen: '0.0.0.0'
+gitea_offline_mode: true
+gitea_lfs_server_enabled: false
+gitea_lfs_content_path: "{{ gitea_home }}/data/lfs"
+gitea_server_extra_config: ''
 
+# Database (database)
+# -> https://docs.gitea.io/en-us/config-cheat-sheet/#database-database
 
 # look and feel
 gitea_disable_gravatar: true
 gitea_disable_registration: false
 gitea_register_email_confirm: false
-gitea_offline_mode: true
 gitea_only_allow_external_registration: false
 gitea_show_registration_button: true
 gitea_require_signin: true
@@ -69,8 +74,6 @@ gitea_oauth2_jwt_secret: ''
 
 
 
-gitea_lfs_server_enabled: false
-gitea_lfs_content_path: "{{ gitea_home }}/data/lfs"
 
 gitea_systemd_cap_net_bind_service: false
 gitea_db_type: sqlite3
diff --git a/templates/gitea.ini.j2 b/templates/gitea.ini.j2
index d6510da..e0792af 100644
--- a/templates/gitea.ini.j2
+++ b/templates/gitea.ini.j2
@@ -10,6 +10,7 @@ APP_NAME = {{ gitea_app_name }}
 RUN_USER = {{ gitea_user }}
 RUN_MODE = {{ gitea_run_mode }}
 ;
+;
 ; -> https://docs.gitea.io/en-us/config-cheat-sheet/#repository-repository
 [repository]
 ROOT                = {{ gitea_repository_root }}
@@ -19,6 +20,7 @@ DISABLE_HTTP_GIT    = {{ gitea_disable_http_git | ternary('true', 'false') }}
 DEFAULT_BRANCH      = {{ gitea_default_branch }}
 {{ gitea_repository_extra_config }}
 ;
+;
 ; -> https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui
 [ui]
 SHOW_USER_EMAIL = {{ gitea_show_user_email | ternary('true', 'false') }}
@@ -26,11 +28,12 @@ DEFAULT_THEME   = {{ gitea_theme_default }}
 THEMES          = {{ gitea_themes }}
 {{ gitea_ui_extra_config }}
 ;
+;
 ; -> https://docs.gitea.io/en-us/config-cheat-sheet/#server-server
 [server]
-PROTOCOL         = {{ gitea_protocol }}
-DOMAIN           = {{ gitea_http_domain }}
-ROOT_URL         = {{ gitea_root_url }}
+PROTOCOL              = {{ gitea_protocol }}
+DOMAIN                = {{ gitea_http_domain }}
+ROOT_URL              = {{ gitea_root_url }}
 HTTP_ADDR             = {{ gitea_http_listen }}
 HTTP_PORT             = {{ gitea_http_port }}
 {% if gitea_http_port == 443 %}
@@ -41,31 +44,21 @@ ENABLE_LETSENCRYPT    = true
 LETSENCRYPT_ACCEPTTOS = true
 LETSENCRYPT_EMAIL     = {{ gitea_http_letsencrypt_mail }}
 {% endif %}
-START_SSH_SERVER = {{ gitea_start_ssh | ternary('true', 'false') }}
-
-
-
-; Domain name to be exposed in clone URL
-SSH_DOMAIN       = {{ gitea_ssh_domain }}
-; The network interface the builtin SSH server should listen on
-SSH_LISTEN_HOST  = {{ gitea_ssh_listen }}
-; Port number to be exposed in clone URL
-SSH_PORT         = {{ gitea_ssh_port }}
-; The port number the builtin SSH server should listen on
-SSH_LISTEN_PORT  = %(SSH_PORT)s
-; Disable CDN even in "prod" mode
-OFFLINE_MODE     = {{ gitea_offline_mode | ternary('true', 'false') }}
-; Default path for App data
-APP_DATA_PATH    = {{ gitea_home }}/data
+START_SSH_SERVER      = {{ gitea_start_ssh | ternary('true', 'false') }}
+SSH_DOMAIN            = {{ gitea_ssh_domain }}
+SSH_PORT              = {{ gitea_ssh_port }}
+SSH_LISTEN_HOST       = {{ gitea_ssh_listen }}
+OFFLINE_MODE          = {{ gitea_offline_mode | ternary('true', 'false') }}
+APP_DATA_PATH         = {{ gitea_home }}/data
 {% if gitea_lfs_server_enabled | bool -%}
-;Enables git-lfs support.
-LFS_START_SERVER = true
-; Where to store LFS files.
-LFS_CONTENT_PATH = {{ gitea_lfs_content_path }}
-; LFS authentication secret
-LFS_JWT_SECRET   = {{ gitea_lfs_jwt_secret }}
+LFS_START_SERVER      = true
+LFS_CONTENT_PATH      = {{ gitea_lfs_content_path }}
+LFS_JWT_SECRET        = {{ gitea_lfs_jwt_secret }}
 {% endif %}
-
+{{ gitea_server_extra_config }}
+;
+;
+; -> https://docs.gitea.io/en-us/config-cheat-sheet/#database-database
 [database]
 ; Either "mysql", "postgres", "mssql" or "sqlite3", it's your choice
 DB_TYPE  = {{ gitea_db_type }}