From d9ca2ae4faafe3e94e3d47cc4f087c82f52b2b9c Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Sat, 29 Jun 2024 15:11:18 +0200 Subject: [PATCH 1/5] make subdomain static path configurable --- defaults/main.yml | 13 +++++++------ tasks/copy_static_files.yml | 8 ++++---- tasks/static_dirs.yml | 2 ++ tasks/static_subdomain_dirs.yml | 12 ++++++------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 8cf7d76..0e233d7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -305,42 +305,42 @@ galaxy_app_config_default: { {% if galaxy_manage_subdomain_static %} '{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_static_path }}/static/', {% for subdomain in galaxy_themes_subdomains %} - '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/', + '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/', {% endfor %} {% endif %} } static_images_dir_by_host: > { {% if galaxy_manage_subdomain_static %} '{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_static_path }}/static/images', {% for subdomain in galaxy_themes_subdomains %} - '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/images', + '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/images', {% endfor %} {% endif %} } static_welcome_html_by_host: > { {% if galaxy_manage_subdomain_static %} '{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_static_path }}/static/welcome.html', {% for subdomain in galaxy_themes_subdomains %} - '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/welcome.html', + '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/welcome.html', {% endfor %} {% endif %} } static_scripts_dir_by_host: > { {% if galaxy_manage_subdomain_static %} '{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_static_path }}/static/scripts', {% for subdomain in galaxy_themes_subdomains %} - '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/scripts', + '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/scripts', {% endfor %} {% endif %} } static_favicon_dir_by_host: > { {% if galaxy_manage_subdomain_static %} '{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_static_path }}/static', {% for subdomain in galaxy_themes_subdomains %} - '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}', + '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}', {% endfor %} {% endif %} } static_robots_txt_by_host: > { {% if galaxy_manage_subdomain_static %} '{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_static_path }}/static', {% for subdomain in galaxy_themes_subdomains %} - '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}', + '{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}', {% endfor %} {% endif %} } themes_config_file_by_host: > @@ -515,6 +515,7 @@ galaxy_themes_static_keys: static_robots_txt: "robots.txt" galaxy_themes_conf_path: files/galaxy/config/themes_conf.yml galaxy_themes_static_path: "{{ galaxy_root }}/server" +galaxy_themes_static_subdomain_path: "{{ galaxy_themes_static_path }}" galaxy_themes_static_dir: "{{ galaxy_root }}/server/static" galaxy_themes_symlinks: true galaxy_themes_symlinks_no_log: false # Hides extended logs for the symlink task in static/dist diff --git a/tasks/copy_static_files.yml b/tasks/copy_static_files.yml index 0ccc9a4..c198332 100644 --- a/tasks/copy_static_files.yml +++ b/tasks/copy_static_files.yml @@ -2,7 +2,7 @@ - name: Copy subdomain static files ansible.builtin.copy: src: "{{ item }}" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/{{ object.value }}" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/{{ object.value }}" mode: '0644' owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" @@ -11,7 +11,7 @@ - name: Copy files from dist ansible.builtin.copy: src: "{{ item }}" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/dist/" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/dist/" mode: '0644' owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" @@ -20,7 +20,7 @@ - name: Copy files from dist ansible.builtin.copy: src: "{{ item }}" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/dist/" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/dist/" mode: '0644' owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" @@ -29,7 +29,7 @@ - name: Copy custom welcome.html ansible.builtin.copy: src: "{{ item }}" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/welcome.html/index.html" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/welcome.html/index.html" mode: '0644' owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" diff --git a/tasks/static_dirs.yml b/tasks/static_dirs.yml index 926cd60..4eba219 100644 --- a/tasks/static_dirs.yml +++ b/tasks/static_dirs.yml @@ -6,6 +6,7 @@ owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" path: "{{ galaxy_themes_static_path }}/static/welcome.html" + when: "{{ galaxy_themes_manage_base_welcome_html }}" - name: Template welcome.html for basedomain ansible.builtin.template: @@ -14,6 +15,7 @@ owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" mode: '0644' + when: "{{ galaxy_themes_manage_base_welcome_html }}" - name: Include create subdomain static dirs and copy static files ansible.builtin.include_tasks: static_subdomain_dirs.yml diff --git a/tasks/static_subdomain_dirs.yml b/tasks/static_subdomain_dirs.yml index c6b3831..ecad4b7 100644 --- a/tasks/static_subdomain_dirs.yml +++ b/tasks/static_subdomain_dirs.yml @@ -5,7 +5,7 @@ mode: '0755' owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" - path: "{{ galaxy_themes_static_path }}/{{ item }}" + path: "{{ galaxy_themes_static_subdomain_path }}/{{ item }}" with_items: - "static-{{ subdomain.name }}" - "static-{{ subdomain.name }}/dist" @@ -20,7 +20,7 @@ - name: "Symlink files static-{{ subdomain.name }}/dist to static/dist" ansible.builtin.file: src: "{{ item.path }}" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/dist/{{ item.path | basename }}" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/dist/{{ item.path | basename }}" state: link when: galaxy_themes_symlinks no_log: "{{ galaxy_themes_symlinks_no_log }}" @@ -29,7 +29,7 @@ - name: "Symlink directory {{ item }} from static-{{ subdomain.name }}/{{ item }} to static/{{ item }}" ansible.builtin.file: src: "{{ galaxy_themes_static_path }}/static/{{ item }}" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/{{ item }}" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/{{ item }}" state: link when: galaxy_themes_symlinks ignore_errors: true @@ -43,7 +43,7 @@ - name: Synchronize contents from static to static-"{{ subdomain.name }}" ansible.posix.synchronize: src: "{{ galaxy_themes_static_path }}/static/" - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}" rsync_opts: ["--ignore-existing"] delegate_to: "{{ inventory_hostname }}" @@ -58,7 +58,7 @@ mode: '0755' owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" - path: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/welcome.html" + path: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/welcome.html" - name: Check if iframe for subdomain exists ansible.builtin.uri: @@ -71,7 +71,7 @@ - name: Template welcome.html for subdomains ansible.builtin.template: src: welcome.html.j2 - dest: "{{ galaxy_themes_static_path }}/static-{{ subdomain.name }}/welcome.html/index.html" + dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/welcome.html/index.html" owner: "{{ __galaxy_privsep_user_name }}" group: "{{ __galaxy_privsep_user_group }}" mode: '0644' From 1d03eb1180db149bd32dcd6b838676e3c707f2f9 Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Sat, 29 Jun 2024 15:12:43 +0200 Subject: [PATCH 2/5] remove redundant task --- tasks/copy_static_files.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tasks/copy_static_files.yml b/tasks/copy_static_files.yml index c198332..35a846a 100644 --- a/tasks/copy_static_files.yml +++ b/tasks/copy_static_files.yml @@ -17,15 +17,6 @@ group: "{{ __galaxy_privsep_user_group }}" with_fileglob: "{{ galaxy_themes_ansible_file_path }}/{{ subdomain.name }}/static/dist/*" -- name: Copy files from dist - ansible.builtin.copy: - src: "{{ item }}" - dest: "{{ galaxy_themes_static_subdomain_path }}/static-{{ subdomain.name }}/dist/" - mode: '0644' - owner: "{{ __galaxy_privsep_user_name }}" - group: "{{ __galaxy_privsep_user_group }}" - with_fileglob: "{{ galaxy_themes_ansible_file_path }}/{{ subdomain.name }}/static/dist/*" - - name: Copy custom welcome.html ansible.builtin.copy: src: "{{ item }}" From f94b371c0025323f284b95fc6bc68e15c18744e1 Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Sat, 29 Jun 2024 15:47:30 +0200 Subject: [PATCH 3/5] add toggle for welcome.html --- defaults/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/defaults/main.yml b/defaults/main.yml index 0e233d7..4581126 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -25,6 +25,7 @@ galaxy_manage_systemd_reports: no # For Reports galaxy_manage_cleanup: no galaxy_manage_themes: no galaxy_manage_subdomain_static: no +galaxy_themes_manage_base_welcome_html: no galaxy_manage_host_filters: no galaxy_auto_brand: no # automatically sets the subdomain name as brand From ee816797df0062c3b2ecd8857b19f01580030021 Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Sat, 29 Jun 2024 15:47:42 +0200 Subject: [PATCH 4/5] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04fdb9b..f2cd785 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ Also make sure that you set `galaxy_themes_welcome_url_prefix`, so your welcome It is mandatory to set the variables under `galaxy_themes_subdomains` as shown in the example in [defaults/main.yml](defaults/main.yml). If you enabled the `galaxy_manage_host_filters` variable, you can also specify the tool sections that should be shown for each individual subdomain. - +`galaxy_themes_manage_base_welcome_html: true` makes the role create a `welcome.html` directory and templates from a file called `welcome.html.j2` to `{{ galaxy_themes_static_path }}/welcome.html/index.html`. This will be the page Galaxy loads when accessing `/root`. [themes]: https://training.galaxyproject.org/training-material/topics/admin/tutorials/customization/tutorial.html **New options for Galaxy 18.01 and later** From 3df2eb5e1a259eb2a35643851ae1849758da0600 Mon Sep 17 00:00:00 2001 From: Mira Kuntz Date: Sat, 29 Jun 2024 15:51:13 +0200 Subject: [PATCH 5/5] add customizable subdomain static info --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f2cd785..0f08884 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,9 @@ files/galaxy/static Where the should exactly match your subdomain's name. The subdirectories `static` and `themes` are mandatory, as well as the correctly named theme file (if you enabled `galaxy_manage_themes`), while all subdirectories in `static` are optional. Which subdirectories and files are copied is managed by the `static_galaxy_themes_keys` variable. +`galaxy_themes_static_path` should point to the parent directory of your Galaxy's original static directory. (default is `galaxy_root`) +`galaxy_themes_static_subdomain_path` by default points to `galaxy_themes_static_path` but can be configured, in case you want to separate your subdomain static dirs from the `galaxy_root`. + Also make sure that you set `galaxy_themes_welcome_url_prefix`, so your welcome pages are templated correctly. It is mandatory to set the variables under `galaxy_themes_subdomains` as shown in the example in [defaults/main.yml](defaults/main.yml). If you enabled the `galaxy_manage_host_filters` variable, you can also specify the tool sections that should be shown for each individual subdomain.