Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom subdomain static path #217

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ files/galaxy/static
Where the <subdomain-name-1> 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.


`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**
Expand Down
14 changes: 8 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -305,42 +306,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: >
Expand Down Expand Up @@ -515,6 +516,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
Expand Down
15 changes: 3 additions & 12 deletions tasks/copy_static_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -11,16 +11,7 @@
- name: Copy files from dist
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ galaxy_themes_static_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 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 }}"
Expand All @@ -29,7 +20,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 }}"
Expand Down
2 changes: 2 additions & 0 deletions tasks/static_dirs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tasks/static_subdomain_dirs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }}"
Expand All @@ -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
Expand All @@ -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 }}"

Expand All @@ -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:
Expand All @@ -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'
Expand Down
Loading