From 5631d6f5099c3b4f6eb8fa09c1cd65c288cfcf41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loraine=20Brillet-Gu=C3=A9guen?= Date: Mon, 27 Mar 2023 22:15:04 +0200 Subject: [PATCH] release 2.2.0 (#21) * closes https://github.com/abims-sbr/ansible-sequenceserver/issues/19 * closes https://github.com/abims-sbr/ansible-sequenceserver/issues/20 --- .github/workflows/ci.yml | 2 +- README.md | 8 ++++-- defaults/main.yml | 5 +++- molecule/default/converge.yml | 3 ++- molecule/default/prepare.yml | 10 ++++++++ molecule/default/tests/bottom_web_page.html | 4 +++ molecule/default/verify.yml | 21 ++++++++++++++++ tasks/main.yml | 27 ++++++++++++++++++--- templates/sequenceserver.rb.j2 | 7 ++++++ 9 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 molecule/default/tests/bottom_web_page.html diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b570f27..6cc923a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ --- name: CI 'on': - pull_request: +# pull_request: push: schedule: - cron: "30 5 3 * *" diff --git a/README.md b/README.md index 68466d7..d1f6927 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Variable to set the version of SequenceServer to install. This role can be used ```yaml sequenceserver_blast_db: -# - { name: 'my_db', port: '4567', path: '/path/to/my/db', users: ['fbar','jsmith'], web_page_title: 'blablabla' } +# - { name: 'my_db', port: '4567', path: '/path/to/my/db', users: ['fbar','jsmith'], web_page_title: 'blablabla', placeholders: [{key: 'key1', value: 'value1'}, {key: 'key2', value: 'value2'}] } ``` This is the variable used to define the BLAST databases. @@ -46,6 +46,7 @@ Each database is defined as a dictionary of the following parameters: - `users` Optional. Useful if the database needs restricted access. List of authorized users (LDAP "uid"). - `ldap_businesscategory` Optional. Useful if the database needs restricted access. A ldap businessCategory value. LDAP users with this "businessCategory" value will have access to the database. - `web_page_title` Optional. The title displayed at the top of the web page. If not provided, the default title is "BLAST server for `name`". +- `placeholders` Optional. A list of placeholder dictionaries `{key: 'key_item', value: 'value_item'}` that are used to customize top or bottom supplementary HTML code (see `sequenceserver_top_web_page_html_path` and `sequenceserver_bottom_web_page_html_path`). For example `placeholders: [{key: 'key1', value: 'value1'}, {key: 'key2', value: 'value2'}]`. Unique `name` and `port` are mandatory for each database. `users` and `ldap_businesscategory` are optional and can be used to add an authentication layer with the nginx-auth-ldap module. It is planned to add a `groups` parameter soon to list authorized groups. @@ -76,10 +77,13 @@ sequenceserver_home_url: "http://sequenceserver.com" sequenceserver_support_email: "http://www.sequenceserver.com/#license-and-support" # Path to the file containing the supplementary HTML code to display at the top of the web page sequenceserver_top_web_page_html_path: "~/top_web_page.html" +# Path to the file containing the supplementary HTML code to display at the bottom of the web page +sequenceserver_bottom_web_page_html_path: "~/bottom_web_page.html" ``` These variables allow to customize the BLAST server web page. They are optional. Two variables are available to set the logo displayed on the BLAST server: `sequenceserver_logo_url` or `sequenceserver_logo_path`. If both are set, the logo given with `sequenceserver_logo_path` will override the logo given with `sequenceserver_logo_url`. -If the file `sequenceserver_top_web_page_html_path` exists, its content will be added in the base RUBY template used to display the web page and will be rendered at the top of the web page. This file must contain HTML code. This can be used, for example, to display information or warning messages to users (service shutdown, etc). +If the files `sequenceserver_top_web_page_html_path` or `sequenceserver_bottom_web_page_html_path` exist, their content will be added in the base RUBY template used to display the web page and will be rendered at the top and bottom of the web page. These files must contain HTML code. This can be used, for example, to display information or warning messages to users (service shutdown, etc). +Placeholders set in the database parameter `placeholders` (see above) can be used to customize the HTML code in these files. For example, if the database has the parameter `placeholders: [{key: 'key_item', value: 'value_item'}]`, the snippet `<%= SequenceServer::Key_item %>` will be replaced by the string `value_item` in the rendered HTML code. Please note that the first letter must be upper case in the snippet to be correctly interpreted as a Ruby constant by SequenceServer. ```yaml # User running the sequenceserver service (systemd) and running SLURM blast jobs diff --git a/defaults/main.yml b/defaults/main.yml index e9ae093..75fbc46 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,9 +15,10 @@ sequenceserver_version: 2.0.0 # groups: TODO. Optional. Useful if the database needs restricted access. List of authorized groups. # ldap_businesscategory: Optional. Useful if the database needs restricted access. A ldap businessCategory value. Ldap users with this businessCategory value will have access to the database. # web_page_title: Optional. The title displayed at the top of the web page. If not provided, the default title is "BLAST server for ". +# placeholders: Optional. A list of placeholder dictionaries `{key: 'key_item', value: 'value_item'}` that are used to customize top or bottom supplementary HTML code (`sequenceserver_top_web_page_html_path` and `sequenceserver_bottom_web_page_html_path`) # sequenceserver_blast_db: -# - { name: 'my_db', port: '4567', path: '/path/to/my/db', users: ['fbar','jsmith'], web_page_title: 'blablabla' } +# - { name: 'my_db', port: '4567', path: '/path/to/my/db', users: ['fbar','jsmith'], web_page_title: 'blablabla', placeholders: [{ key: 'key1', value: 'value1'}, { key: 'key2', value: 'value2'}] } # NCBI BLAST and SLURM variables # Used in the slurm bash scripts @@ -45,6 +46,8 @@ sequenceserver_home_url: "http://sequenceserver.com" sequenceserver_support_email: "http://www.sequenceserver.com/#license-and-support" # Path to the file containing the supplementary HTML code to display at the top of the web page sequenceserver_top_web_page_html_path: "~/top_web_page.html" +# Path to the file containing the supplementary HTML code to display at the bottom of the web page +sequenceserver_bottom_web_page_html_path: "~/bottom_web_page.html" # Service (systemd) # diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 3fd0833..39be29a 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -8,7 +8,8 @@ sequenceserver_blast_binaries: /usr/local/anaconda/envs/blast/bin sequenceserver_blast_db: # yamllint disable-line rule:braces - - { name: 'my_db', port: '4567', path: '/tmp/test-data' } + - { name: 'my_db', port: '4567', path: '/tmp/test-data', placeholders: [{ key: 'key_string', value: 'value1'}, { key: 'key_link', value: 'my favorite link'}] } sequenceserver_top_web_page_html_path: "/tmp/top_web_page.html" + sequenceserver_bottom_web_page_html_path: "/tmp/bottom_web_page.html" sequenceserver_home_url: "http://myfavoritewebsite.com" sequenceserver_support_email: "mailto:amazingsupport@myfavoritewebsite.com" diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index b3ecb68..470a9fe 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -6,6 +6,10 @@ - name: Update apt cache. apt: update_cache=true cache_valid_time=600 when: ansible_os_family == 'Debian' + - name: Install dependencies. + package: + name: + - curl - name: Install rsyslog include_role: name: robertdebock.rsyslog @@ -39,3 +43,9 @@ dest: /tmp/ owner: root mode: 0644 + - name: Copy bottom_web_page.html + copy: + src: tests/bottom_web_page.html + dest: /tmp/ + owner: root + mode: 0644 diff --git a/molecule/default/tests/bottom_web_page.html b/molecule/default/tests/bottom_web_page.html new file mode 100644 index 0000000..b1c650f --- /dev/null +++ b/molecule/default/tests/bottom_web_page.html @@ -0,0 +1,4 @@ +
+ Render custom string for this database: <%= SequenceServer::Key_string %>
+ Render custom link for this database: <%= SequenceServer::Key_link %>
+
diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 3a640c5..7299039 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -43,3 +43,24 @@ name: sequenceserver-my_db.service register: service_result failed_when: service_result.status.SubState != 'running' + - name: Test NGINX home page + get_url: + url: "http://localhost" + dest: "/tmp/nginx.html" + - name: Test SequenceServer home page with curl # same thing tried with the ansible get_url module without success + shell: # noqa 301 + cmd: "curl -sL http://localhost:4567 -o /tmp/home.html" + register: sequenceserver_command + failed_when: sequenceserver_command.rc > 0 + - name: Get SequenceServer home page content + slurp: + src: "/tmp/home.html" + register: sequenceserver_page + - name: Display SequenceServer home page content + debug: + msg: "{{ sequenceserver_page.content | b64decode }}" + - name: Test that the SequenceServer home page is rendering the values of the placeholders set for my_db + shell: # noqa 301 + cmd: curl -sL http://localhost:4567 | grep -q 'my favorite link' + register: sequenceserver_command + failed_when: sequenceserver_command.rc > 0 diff --git a/tasks/main.yml b/tasks/main.yml index a99478f..51d9728 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -92,27 +92,48 @@ - {regexp: '{{ sequenceserver_logo_title_regexp }}', replace: '{{ sequenceserver_logo_title_replace }}'} - {regexp: 'http://www.sequenceserver.com/#license-and-support', replace: '{{ sequenceserver_support_email }}'} -- name: Modify source erb file for custom web page title | Insert supplementary HTML code on the top of the web page | Check if the file exists +- name: Modify source erb file for custom web page title | Insert supplementary HTML code at the top of the web page | Check if the file exists stat: path: "{{ sequenceserver_top_web_page_html_path }}" register: top_web_page_html_path -- name: Modify source erb file for custom web page title | Insert supplementary HTML code on the top of the web page | Get the file content +- name: Modify source erb file for custom web page title | Insert supplementary HTML code at the bottom of the web page | Check if the file exists + stat: + path: "{{ sequenceserver_bottom_web_page_html_path }}" + register: bottom_web_page_html_path + +- name: Modify source erb file for custom web page title | Insert supplementary HTML code at the top of the web page | Get the file content slurp: src: "{{ sequenceserver_top_web_page_html_path }}" register: top_web_page_html_file when: top_web_page_html_path.stat.exists +- name: Modify source erb file for custom web page title | Insert supplementary HTML code at the bottom of the web page | Get the file content + slurp: + src: "{{ sequenceserver_bottom_web_page_html_path }}" + register: bottom_web_page_html_file + when: bottom_web_page_html_path.stat.exists + - name: Modify source erb file for custom web page title | Insert supplementary HTML code on the top of the web page | Insert or update with file content blockinfile: path: "{{ sequenceserver_file_to_modify_for_custom_web_page }}" block: "{{ top_web_page_html_file['content'] | b64decode }}" insertafter: "" - marker: "" + marker: "" backup: yes when: top_web_page_html_path.stat.exists notify: Restart all sequenceserver services +- name: Modify source erb file for custom web page title | Insert supplementary HTML code at the bottom of the web page | Insert or update with file content + blockinfile: + path: "{{ sequenceserver_file_to_modify_for_custom_web_page }}" + block: "{{ bottom_web_page_html_file['content'] | b64decode }}" + insertafter: "<%= yield %>" + marker: "" + backup: yes + when: bottom_web_page_html_path.stat.exists + notify: Restart all sequenceserver services + - name: Add slurm_sbatch.sh for HPC integration (https://sequenceserver.com/doc/#hpc) template: src: slurm_sbatch.sh.j2 diff --git a/templates/sequenceserver.rb.j2 b/templates/sequenceserver.rb.j2 index 0851e79..0bcd6fb 100644 --- a/templates/sequenceserver.rb.j2 +++ b/templates/sequenceserver.rb.j2 @@ -4,4 +4,11 @@ module SequenceServer {% else %} WEB_PAGE_TITLE = 'BLAST server for {{ item.name }}' {% endif %} +{% if item.placeholders is defined and item.placeholders %} + {% for placeholder in item.placeholders %} + {% if placeholder.key is defined and placeholder.key and placeholder.value is defined and placeholder.value %} + {{ placeholder.key[0]|upper}}{{placeholder.key[1:] }} = '{{ placeholder.value }}' + {% endif %} + {% endfor %} +{% endif %} end