From 54deba19dc4ef86729017d29760e3abd87d49bac Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 3 Mar 2024 12:42:22 +0100 Subject: [PATCH 1/5] add files --- README.md | 9 +++++++++ tasks/customize_public_files.yml | 20 ++++++++++++++++++-- tasks/main.yml | 28 ++++++++++++++-------------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 5abe886..c532810 100644 --- a/README.md +++ b/README.md @@ -386,6 +386,15 @@ To deploy multiple files we created the ``gitea_custom_search`` variable, that c - Set ``gitea_customize_files`` to ``true`` - Create a directory with the files you want to deploy. - Point ``gitea_customize_files_path`` to this directory. *(Default ``{{ gitea_custom_search }}/gitea_files/``)* ++ **CUSTOM THEMES**: + - Set `gitea_custom_themes` to a list with URLs for custom theme CSS files. You usually want three individual files per theme. Example: + ```yaml + gitea_custom_themes: + - https://example.com/theme-custom-auto.css + - https://example.com/theme-custom-dark.css + - https://example.com/theme-custom-light.css + ``` + - Set `gitea_themes` variable and include the names of the new themes. To keep the existing ones, you need to pass all themes names, e.g. `auto,gitea,arc-green,,,` ## Requirements This role uses the ``ansible.builtin`` and ``community.general`` ansible Collections. To download the latest forgejo/gitea release we use json_query. This requires ``jmespath`` to be available. diff --git a/tasks/customize_public_files.yml b/tasks/customize_public_files.yml index 747a103..3a38bd8 100644 --- a/tasks/customize_public_files.yml +++ b/tasks/customize_public_files.yml @@ -6,7 +6,7 @@ state: directory owner: "{{ gitea_user }}" group: "{{ gitea_group }}" - mode: 'u=rwX,g=rX,o=' + mode: "u=rwX,g=rX,o=" loop: - "{{ gitea_custom }}/public" @@ -18,7 +18,23 @@ owner: "{{ gitea_user }}" group: "{{ gitea_group }}" directory_mode: true - mode: 'u=rwX,g=rX,o=' + mode: "u=rwX,g=rX,o=" failed_when: false tags: skip_ansible_lint notify: "Restart gitea" + +- name: Create css directory for custom themes + when: gitea_custom_themes is defined + ansible.builtin.file: + path: "{{ gitea_custom }}/public/css" + state: directory + owner: "{{ gitea_user }}" + +- name: Get custom themes + when: gitea_custom_themes is defined + ansible.builtin.get_url: + url: "{{ item.name }}" + dest: "{{ gitea_custom }}/css/{{ item.name | basename }}" + owner: git + loop: "{{ gitea_custom_themes }}" + notify: "Restart gitea" diff --git a/tasks/main.yml b/tasks/main.yml index 935c0b6..b8562a9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,12 +1,12 @@ --- - name: Perform optional versionscheck ansible.builtin.include_tasks: - file: 'versioncheck.yml' + file: "versioncheck.yml" when: submodules_versioncheck|bool - name: Gather installed packages for checks later on ansible.builtin.package_facts: - manager: 'auto' + manager: "auto" - name: Prepare gitea/forgejo variable import block: @@ -28,12 +28,12 @@ - name: Backup gitea before update ansible.builtin.include_tasks: - file: 'backup.yml' + file: "backup.yml" when: gitea_backup_on_upgrade|bool - name: Create gitea user and group ansible.builtin.include_tasks: - file: 'create_user.yml' + file: "create_user.yml" - name: "Install or update {{ gitea_fork }}" ansible.builtin.include_tasks: @@ -41,41 +41,41 @@ - name: Create directories ansible.builtin.include_tasks: - file: 'directory.yml' + file: "directory.yml" - name: Setup gitea systemd service ansible.builtin.include_tasks: - file: 'install_systemd.yml' + file: "install_systemd.yml" when: ansible_service_mgr == "systemd" - name: Generate JWT Secrets if undefined ansible.builtin.include_tasks: - file: 'jwt_secrets.yml' + file: "jwt_secrets.yml" - name: Generate gitea secrets if undefined ansible.builtin.include_tasks: - file: 'gitea_secrets.yml' + file: "gitea_secrets.yml" - name: Configure gitea ansible.builtin.include_tasks: - file: 'configure.yml' + file: "configure.yml" - name: Deploy optional fail2ban rules ansible.builtin.include_tasks: - file: 'fail2ban.yml' + file: "fail2ban.yml" when: gitea_fail2ban_enabled | bool - name: Optionally customize gitea ansible.builtin.include_tasks: - file: 'customize_logo.yml' + file: "customize_logo.yml" when: gitea_customize_logo | bool - name: Optionally customize footer ansible.builtin.include_tasks: - file: 'customize_footer.yml' + file: "customize_footer.yml" when: gitea_customize_footer | bool - name: Optionally deploy public files ansible.builtin.include_tasks: - file: 'customize_public_files.yml' - when: gitea_customize_files | bool + file: "customize_public_files.yml" + when: gitea_customize_files | bool or gitea_custom_themes is defined From 373059fbf8b08b84bfd029b78e436b7e2c1a14bf Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 3 Mar 2024 14:33:02 +0100 Subject: [PATCH 2/5] set mode --- tasks/customize_public_files.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/customize_public_files.yml b/tasks/customize_public_files.yml index 3a38bd8..9cca35e 100644 --- a/tasks/customize_public_files.yml +++ b/tasks/customize_public_files.yml @@ -36,5 +36,6 @@ url: "{{ item.name }}" dest: "{{ gitea_custom }}/css/{{ item.name | basename }}" owner: git + mode: "u=rwX,g=rX,o=" loop: "{{ gitea_custom_themes }}" notify: "Restart gitea" From 64bcb2f51754bbc3de2ef3e87547460e15ae7019 Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 3 Mar 2024 14:36:14 +0100 Subject: [PATCH 3/5] fix owner/group --- tasks/customize_public_files.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/customize_public_files.yml b/tasks/customize_public_files.yml index 9cca35e..340ddfd 100644 --- a/tasks/customize_public_files.yml +++ b/tasks/customize_public_files.yml @@ -35,7 +35,8 @@ ansible.builtin.get_url: url: "{{ item.name }}" dest: "{{ gitea_custom }}/css/{{ item.name | basename }}" - owner: git + owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" mode: "u=rwX,g=rX,o=" loop: "{{ gitea_custom_themes }}" notify: "Restart gitea" From aa5839537d61a4e10f17b6421a84cad913cbcb4b Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 3 Mar 2024 14:38:14 +0100 Subject: [PATCH 4/5] fix indentation --- tasks/customize_public_files.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/customize_public_files.yml b/tasks/customize_public_files.yml index 340ddfd..f006d2b 100644 --- a/tasks/customize_public_files.yml +++ b/tasks/customize_public_files.yml @@ -38,5 +38,5 @@ owner: "{{ gitea_user }}" group: "{{ gitea_group }}" mode: "u=rwX,g=rX,o=" - loop: "{{ gitea_custom_themes }}" + loop: "{{ gitea_custom_themes }}" notify: "Restart gitea" From b00da6a8bacd11e55a950e14656ced9d5f05af76 Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 3 Mar 2024 14:42:29 +0100 Subject: [PATCH 5/5] fix perms --- tasks/customize_public_files.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/customize_public_files.yml b/tasks/customize_public_files.yml index f006d2b..b2cd5bc 100644 --- a/tasks/customize_public_files.yml +++ b/tasks/customize_public_files.yml @@ -29,6 +29,8 @@ path: "{{ gitea_custom }}/public/css" state: directory owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" + mode: "u=rwX,g=rX,o=" - name: Get custom themes when: gitea_custom_themes is defined