Skip to content

Commit 0fc5aaa

Browse files
authored
Merge pull request roles-ansible#36 from roles-ansible/custom
implement custom logos
2 parents 2fbcfb5 + e27ef27 commit 0fc5aaa

File tree

7 files changed

+111
-5
lines changed

7 files changed

+111
-5
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,23 @@ As this will only deploy config files, fail2ban already has to be installed or o
213213
| `gitea_fail2ban_jail_bantime` | `900` | fail2ban jail `bantime` setting. |
214214
| `gitea_fail2ban_jail_action` | `iptables-allports` | fail2ban jail `action` setting. |
215215

216+
### optional customisation
217+
You can optionally customize your gitea using this ansible role. We got our information about customisation from [docs.gitea.io/en-us/customizing-gitea](https://docs.gitea.io/en-us/customizing-gitea/).
218+
To deploy multiple files we created the ``gitea_custom_search`` variable, that can point to the path where you put the custom gitea files *( default ``"files/host_files/{{ inventory_hostname }}/gitea"``.
219+
220+
+ LOGO
221+
- Set ``gitea_customize_logo`` to ``true``
222+
- We search for:
223+
* ``logo.svg`` - Used for favicon, site icon, app icon
224+
* ``logo.png`` - Used for Open Graph
225+
* ``favicon.png`` - Used as fallback for browsers that don’t support SVG favicons
226+
* ``apple-touch-icon.png`` - Used on iOS devices for bookmarks
227+
- We search in *(using [first_found](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/first_found_lookup.html))*:
228+
* ``{{ gitea_custom_search }}/gitea_logo/``
229+
* ``files/{{ inventory_hostname }}/gitea_logo/``
230+
* ``files/{{ gitea_http_domain }}/gitea_logo/``
231+
* ``files/gitea_logo/``
232+
216233
## Contributing
217234
Don't hesitate to create a pull request, and when in doubt you can reach me on
218235
Mastodon [@[email protected]](https://chaos.social/@l3d).

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,8 @@ gitea_fail2ban_jail_maxretry: '10'
146146
gitea_fail2ban_jail_findtime: '3600'
147147
gitea_fail2ban_jail_bantime: '900'
148148
gitea_fail2ban_jail_action: 'iptables-allports'
149+
150+
# gitea customisation
151+
gitea_custom_search: "files/host_files/{{ inventory_hostname }}/gitea"
152+
gitea_customize_logo: false
153+
gitea_custom: "{{ gitea_home }}/custom"

tasks/customize_logo.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
- name: create directory for custom logos
3+
become: true
4+
ansible.builtin.file:
5+
path: "{{ item }}"
6+
state: directory
7+
owner: "{{ gitea_user }}"
8+
group: "{{ gitea_group }}"
9+
mode: 'u=rwX,g=rX,o='
10+
with_items:
11+
- "{{ gitea_custom }}/public"
12+
- "{{ gitea_custom }}/public/img"
13+
14+
- name: transfer custom logo.svg
15+
become: true
16+
ansible.builtin.copy:
17+
src: "{{ lookup('first_found', transfer_custom_logo_logosvg) }}"
18+
dest: "{{ gitea_custom }}/public/img/logo.svg"
19+
owner: "{{ gitea_user }}"
20+
group: "{{ gitea_group }}"
21+
mode: '0644'
22+
ignore_errors: true
23+
24+
- name: transfer custom logo.png
25+
become: true
26+
ansible.builtin.copy:
27+
src: "{{ lookup('first_found', transfer_custom_logo_logopng) }}"
28+
dest: "{{ gitea_custom }}/public/img/logo.png"
29+
owner: "{{ gitea_user }}"
30+
group: "{{ gitea_group }}"
31+
mode: '0644'
32+
ignore_errors: true
33+
34+
- name: transfer custom favicon.png
35+
become: true
36+
ansible.builtin.copy:
37+
src: "{{ lookup('first_found', transfer_custom_logo_faviconpng) }}"
38+
dest: "{{ gitea_custom }}/public/img/favicon.png"
39+
owner: "{{ gitea_user }}"
40+
group: "{{ gitea_group }}"
41+
mode: '0644'
42+
ignore_errors: true
43+
44+
- name: transfer custom apple-touch-icon.png
45+
become: true
46+
ansible.builtin.copy:
47+
src: "{{ lookup('first_found', transfer_custom_logo_appletouchiconpng) }}"
48+
dest: "{{ gitea_custom }}/public/img/apple-touch-icon.png"
49+
owner: "{{ gitea_user }}"
50+
group: "{{ gitea_group }}"
51+
mode: '0644'
52+
ignore_errors: true

tasks/directory.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
- "/etc/gitea"
1212
- "{{ gitea_home }}"
1313
- "{{ gitea_home }}/data"
14-
- "{{ gitea_home }}/custom"
15-
- "{{ gitea_home }}/custom/https"
16-
- "{{ gitea_home }}/custom/mailer"
14+
- "{{ gitea_custom }}"
15+
- "{{ gitea_custom }}/https"
16+
- "{{ gitea_custom }}/mailer"
1717
- "{{ gitea_home }}/indexers"
1818
- "{{ gitea_home }}/log"
1919
- "{{ gitea_repository_root }}"

tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@
4848
- name: deploy optional fail2ban rules
4949
ansible.builtin.include_tasks: fail2ban.yml
5050
when: gitea_fail2ban_enabled|bool
51+
52+
- name: optionally customize gitea
53+
ansible.builtin.include_tasks: customize_logo.yml
54+
when: gitea_customize_logo|bool

templates/gitea.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ After=network.target
55
[Service]
66
User={{ gitea_user }}
77
Group={{ gitea_group }}
8-
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/gitea.ini --custom-path {{ gitea_home }}/custom/
8+
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/gitea.ini --custom-path {{ gitea_custom }}/
99
Restart=on-failure
1010
WorkingDirectory={{ gitea_home }}
1111
{% if gitea_systemd_cap_net_bind_service %}

vars/main.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,33 @@ gitea_variables:
2020
paths:
2121
- 'vars'
2222

23-
playbook_version_number: 15 # should be int
23+
transfer_custom_logo_logosvg:
24+
files:
25+
- "{{ gitea_custom_search }}/gitea_logo/logo.svg"
26+
- "files/{{ inventory_hostname }}/gitea_logo/logo.svg"
27+
- "files/{{ gitea_http_domain }}/gitea_logo/logo.svg"
28+
- 'files/gitea_logo/logo.svg'
29+
30+
transfer_custom_logo_logopng:
31+
files:
32+
- "{{ gitea_custom_search }}/gitea_logo/logo.png"
33+
- "files/{{ inventory_hostname }}/gitea_logo/logo.png"
34+
- "files/{{ gitea_http_domain }}/gitea_logo/logo.png"
35+
- 'files/gitea_logo/logo.png'
36+
37+
transfer_custom_logo_faviconpng:
38+
files:
39+
- "{{ gitea_custom_search }}/gitea_logo/favicon.png"
40+
- "files/{{ inventory_hostname }}/gitea_logo/favicon.png"
41+
- "files/{{ gitea_http_domain }}/gitea_logo/favicon.png"
42+
- 'files/gitea_logo/favicon.png'
43+
44+
transfer_custom_logo_appletouchiconpng:
45+
files:
46+
- "{{ gitea_custom_search }}/gitea_logo/apple-touch-icon.png"
47+
- "files/{{ inventory_hostname }}/gitea_logo/apple-touch-icon.png"
48+
- "files/{{ gitea_http_domain }}/gitea_logo/apple-touch-icon.png"
49+
- 'files/gitea_logo/apple-touch-icon.png'
50+
51+
playbook_version_number: 16 # should be int
2452
playbook_version_path: 'do1jlr.gitea.version'

0 commit comments

Comments
 (0)