From 968b4e130106a296170df2a67caf3af022a48501 Mon Sep 17 00:00:00 2001 From: Dylan Hsin Date: Wed, 31 Jul 2024 15:16:55 +0200 Subject: [PATCH] YDA-5834: add config folder path to portal role --- docker/images/yoda_portal/Dockerfile | 4 ++++ docker/images/yoda_portal/yoda_portal_init.sh | 24 +++++++++++++++---- roles/yoda_portal/defaults/main.yml | 5 ++-- roles/yoda_portal/tasks/main.yml | 11 +++++++++ roles/yoda_portal/templates/flask.cfg.j2 | 8 +++++-- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/docker/images/yoda_portal/Dockerfile b/docker/images/yoda_portal/Dockerfile index c36338a3f..4960cf216 100644 --- a/docker/images/yoda_portal/Dockerfile +++ b/docker/images/yoda_portal/Dockerfile @@ -42,6 +42,10 @@ RUN useradd yodadeployment && \ chown yodadeployment:yodadeployment /var/www/yoda && \ git clone --branch $YODA_PORTAL_BRANCH $YODA_PORTAL_REPO /var/www/yoda && \ git config --global --add safe.directory /var/www/yoda +# Create portal's shared config folder +RUN mkdir -p /var/www/yoda/config && \ + chown yodadeployment:yodadeployment /var/www/yoda/config && \ + chmod 0775 /var/www/yoda/config COPY yoda-portal-vhost.conf /etc/apache2/sites-available/001-yoda-portal-vhost.conf RUN ln -s /etc/apache2/sites-available/001-yoda-portal-vhost.conf /etc/apache2/sites-enabled/001-yoda-portal-vhost.conf RUN virtualenv --python /usr/bin/python3 /var/www/yoda/venv && \ diff --git a/docker/images/yoda_portal/yoda_portal_init.sh b/docker/images/yoda_portal/yoda_portal_init.sh index 63d79357f..02658f511 100644 --- a/docker/images/yoda_portal/yoda_portal_init.sh +++ b/docker/images/yoda_portal/yoda_portal_init.sh @@ -165,11 +165,27 @@ OIDC_JWT_OPTIONS = { "verify_signature": True #verify the JWT cryptographic signature } +# Yoda portal +YODA_PORTAL_PATH = '/var/www/yoda' # Path to location of portal +YODA_CONFIG_PATH = '/var/www/yoda/config' # Path to portal's shared configuration + # Portal theme configuration -YODA_THEME_PATH = '/var/www/yoda/themes' # Path to location of themes -YODA_THEME = 'uu' # Reference to actual theme directory in YODA_THEME_PATH -YODA_MAIN_PATH = '/var/www/yoda' -YODA_THEME_MAPPING = {'uu': 'Utrecht University - default', 'uu_its': 'Utrecht University - ITS', 'uu_gw': 'Utrecht University - Humanities', 'uu_youth': 'Utrecht University - YOUth', 'uu_i-lab': 'Utrecht University - i-lab', 'uu_science': 'Utrecht University - Science', 'uu_fsw': 'Utrecht University - Social Science', 'uu_geo': 'Utrecht University - Geo', 'uu_dgk': 'Utrecht University - Veterinary Medicine', 'uu_dag': 'Utrecht University - Data Archive for Geosciences (DAG)', 'vu': 'Vrije University Amsterdam', 'wur': 'Wageningen University & Research'} +YODA_THEME_PATH = '/var/www/yoda/themes' # Path to location of themes +YODA_THEME = 'uu' # Reference to actual theme directory in YODA_THEME_PATH +YODA_THEME_MAPPING = { + 'uu': 'Utrecht University - default', + 'uu_its': 'Utrecht University - ITS', + 'uu_gw': 'Utrecht University - Humanities', + 'uu_youth': 'Utrecht University - YOUth', + 'uu_i-lab': 'Utrecht University - i-lab', + 'uu_science': 'Utrecht University - Science', + 'uu_fsw': 'Utrecht University - Social Science', + 'uu_geo': 'Utrecht University - Geo', + 'uu_dgk': 'Utrecht University - Veterinary Medicine', + 'uu_dag': 'Utrecht University - Data Archive for Geosciences (DAG)', + 'vu': 'Vrije University Amsterdam', + 'wur': 'Wageningen University & Research' +} # External User Service configuration YODA_EUS_FQDN = 'eus.yoda.test' diff --git a/roles/yoda_portal/defaults/main.yml b/roles/yoda_portal/defaults/main.yml index 8457472df..73fa81755 100644 --- a/roles/yoda_portal/defaults/main.yml +++ b/roles/yoda_portal/defaults/main.yml @@ -13,8 +13,7 @@ update_portal: true # Yoda theme yoda_theme_path: /var/www/yoda/themes # Base path holding customised portal themes yoda_theme: uu # Yoda theme: uu or vu (default: uu) -yoda_main_path: /var/www/yoda # Yoda portal installation path -theme_mapping: +yoda_theme_mapping: uu: "Utrecht University - default" uu_its: "Utrecht University - ITS" uu_gw: "Utrecht University - Humanities" @@ -31,6 +30,8 @@ theme_mapping: # Yoda portal yoda_portal_version: "{{ yoda_version }}" yoda_portal_log_api_call_duration: false +yoda_portal_path: /var/www/yoda # Path to location of portal +yoda_config_path: '/var/www/yoda/config' # Path to portal's shared configuration # Text file extensions configuration text_file_extensions: ['bash', 'csv', 'c', 'cpp', 'csharp', 'css', 'diff', 'fortran', 'gams', 'gauss', 'go', 'graphql', 'ini', 'irpf90', 'java', 'js', 'json', 'julia', 'julia-repl', 'kotlin', 'less', 'lua', 'makefile', 'markdown', 'md', 'mathematica', 'matlab', 'maxima', 'mizar', 'objectivec', 'openscad', 'perl', 'php', 'php-template', 'plaintext', 'txt', 'python', 'py', 'python-repl', 'r', 'ruby', 'rust', 'sas', 'scilab', 'scss', 'shell', 'sh', 'sql', 'stan', 'stata', 'swift', 'typescript', 'ts', 'vbnet', 'wasm', 'xml', 'yaml', 'html'] diff --git a/roles/yoda_portal/tasks/main.yml b/roles/yoda_portal/tasks/main.yml index e61211206..52ae6199a 100644 --- a/roles/yoda_portal/tasks/main.yml +++ b/roles/yoda_portal/tasks/main.yml @@ -105,6 +105,17 @@ when: not ansible_check_mode +- name: Ensure the portal config directory exists + become_user: "{{ yoda_deployment_user }}" + ansible.builtin.file: + path: "{{ yoda_config_path }}" + state: directory + owner: "{{ yoda_deployment_user }}" + group: "{{ yoda_deployment_user }}" + mode: '0775' + become: true + + - name: Copy Yoda Portal config for Flask ansible.builtin.template: src: "flask.cfg.j2" diff --git a/roles/yoda_portal/templates/flask.cfg.j2 b/roles/yoda_portal/templates/flask.cfg.j2 index e19eacb0b..85bf22689 100644 --- a/roles/yoda_portal/templates/flask.cfg.j2 +++ b/roles/yoda_portal/templates/flask.cfg.j2 @@ -92,11 +92,15 @@ OIDC_JWT_OPTIONS = { } {% endif %} +# Portal configuration +YODA_PORTAL_PATH = '{{ yoda_portal_path | default("/var/www/yoda") }}' # Path to location of portal +YODA_CONFIG_PATH = '{{ yoda_config_path | default("/var/www/yoda/config") }}' # Path to portal's shared configuration + # Portal theme configuration YODA_THEME_PATH = '{{ yoda_theme_path | default("/var/www/yoda/themes") }}' # Path to location of themes YODA_THEME = '{{ yoda_theme | default("uu") }}' # Reference to actual theme directory in YODA_THEME_PATH -YODA_MAIN_PATH = '{{ yoda_main_path | default("/var/www/yoda") }}' -YODA_THEME_MAPPING = {{ theme_mapping | default("{}") }} +YODA_THEME_MAPPING = {{ yoda_theme_mapping | default("{}") }} + # External User Service configuration YODA_EUS_FQDN = '{{ yoda_eus_fqdn | default("") }}'