Skip to content

Commit

Permalink
release 2.2.0 (#21)
Browse files Browse the repository at this point in the history
* closes #19

* closes #20
  • Loading branch information
loraine-gueguen authored Mar 27, 2023
1 parent df72d99 commit 5631d6f
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: CI
'on':
pull_request:
# pull_request:
push:
schedule:
- cron: "30 5 3 * *"
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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 (`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
Expand Down Expand Up @@ -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)
#
Expand Down
3 changes: 2 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<a href="http://testplaceholder.com">my favorite link</a>'}] }
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:[email protected]"
10 changes: 10 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions molecule/default/tests/bottom_web_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div id="bottomsupplementarycontent">
Render custom string for this database: <%= SequenceServer::Key_string %></br>
Render custom link for this database: <%= SequenceServer::Key_link %></br>
</div>
21 changes: 21 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<a href="http://testplaceholder.com">my favorite link</a>'
register: sequenceserver_command
failed_when: sequenceserver_command.rc > 0
27 changes: 24 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<body>"
marker: "<!-- {mark} ANSIBLE MANAGED BLOCK -->"
marker: "<!-- {mark} ANSIBLE MANAGED BLOCK - TOP -->"
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: "<!-- {mark} ANSIBLE MANAGED BLOCK - BOTTOM -->"
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
Expand Down
7 changes: 7 additions & 0 deletions templates/sequenceserver.rb.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5631d6f

Please sign in to comment.