From 33d3286e7448d7152ba75aed1f8ffd427ff26772 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 12:44:48 +0200 Subject: [PATCH 01/13] Change the tomcat roles so that we are now able to change the default temporary directory. --- tomcat-multiple-instances/tasks/main.yml | 7 ++++++- tomcat-multiple-instances/templates/tomcat-default.j2 | 3 +++ tomcat/tasks/tomcat-pkgs.yml | 6 ++++++ tomcat/templates/tomcat-default.j2 | 4 +++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tomcat-multiple-instances/tasks/main.yml b/tomcat-multiple-instances/tasks/main.yml index ee42680..c49dec1 100644 --- a/tomcat-multiple-instances/tasks/main.yml +++ b/tomcat-multiple-instances/tasks/main.yml @@ -56,6 +56,12 @@ register: tomcat_first_install tags: [ 'tomcat', 'tomcat_instances' ] +- name: Create the tmp directory + file: dest={{ item.catalina_tmp_directory }} state=directory + with_items: '{{ tomcat_m_instances }}' + when: item.catalina_tmp_directory is defined + tags: [ 'tomcat', 'tomcat_instances' ] + - name: Populate the instances conf directory copy: src={{ item[1] }} dest={{ item.0.instance_path }}/conf/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=0640 with_nested: @@ -76,7 +82,6 @@ - tomcat restart instances with changed configs tags: [ 'tomcat', 'tomcat_instances', 'tomcat_catalina_properties' ] - - name: Populate the instances conf/policy.d directory copy: src=policy.d/{{ item[1] }} dest={{ item.0.instance_path }}/conf/policy.d/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=0640 with_nested: diff --git a/tomcat-multiple-instances/templates/tomcat-default.j2 b/tomcat-multiple-instances/templates/tomcat-default.j2 index 74ac914..8e165ad 100644 --- a/tomcat-multiple-instances/templates/tomcat-default.j2 +++ b/tomcat-multiple-instances/templates/tomcat-default.j2 @@ -50,6 +50,9 @@ JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address={{ item.re {% endif %} # WARNING: This directory will be destroyed and recreated at every startup ! JVM_TMP={{ item.instance_path }}/tmp +{% if item.catalina_tmp_directory is defined %} +export CATALINA_TMPDIR={{ item.catalina_tmp_directory }} +{% endif %} # Additional options not managed by the provisioning tools if [ -f /etc/default/tomcat-instance-{{ item.http_port }}.local ] ; then . /etc/default/tomcat-instance-{{ item.http_port }}.local diff --git a/tomcat/tasks/tomcat-pkgs.yml b/tomcat/tasks/tomcat-pkgs.yml index 184f8ad..e5487d9 100644 --- a/tomcat/tasks/tomcat-pkgs.yml +++ b/tomcat/tasks/tomcat-pkgs.yml @@ -9,6 +9,12 @@ notify: tomcat restart tags: tomcat +- name: Create the catalina temp directory, if different from the default + file: dest={{ catalina_tmp_directory }} state=directory owner={{ tomcat_user }} group={{ tomcat_user }} + when: catalina_tmp_directory is defined + notify: tomcat restart + tags: tomcat + - name: Configure tomcat defaults template: src=tomcat-default.j2 dest=/etc/default/tomcat{{ tomcat_version }} when: tomcat_install_default_conf diff --git a/tomcat/templates/tomcat-default.j2 b/tomcat/templates/tomcat-default.j2 index 02ad697..8d8862f 100644 --- a/tomcat/templates/tomcat-default.j2 +++ b/tomcat/templates/tomcat-default.j2 @@ -48,7 +48,9 @@ JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address={{ tomcat_ # Location of the JVM temporary directory # WARNING: This directory will be destroyed and recreated at every startup ! JVM_TMP={{ tomcat_tmp_dir }} - +{% if catalina_tmp_directory is defined %} +export CATALINA_TMPDIR={{ catalina_tmp_directory }} +{% endif %} {% if tomcat_load_additional_default_conf %} if [ -f /etc/default/tomcat.local ] ; then . /etc/default/tomcat.local From ce4442395571fb7202c81b912681422043d3d4fd Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 12:52:03 +0200 Subject: [PATCH 02/13] library/roles/smartgears/smartgears/defaults/main.yml: add a default for the catalina (tomcat) tmp directory, so that we can change it when needed. --- smartgears/smartgears/defaults/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smartgears/smartgears/defaults/main.yml b/smartgears/smartgears/defaults/main.yml index a9fa8b4..65c069a 100644 --- a/smartgears/smartgears/defaults/main.yml +++ b/smartgears/smartgears/defaults/main.yml @@ -55,6 +55,7 @@ smartgears_log_max_history: 30 smartgears_log_max_file_size: 10MB smartgears_log_total_file_cap: 2GB smartgears_log_dir: '{{ smartgears_user_home }}/tomcat/logs' +smartgears_tomcat_tmp_dir: '{{ smartgears_user_home }}/tomcat/tmp' smartgears_logback_template: True smartgears_tomcat_contexts: [ '' ] @@ -65,7 +66,7 @@ http_port: '{{ smartgears_http_port }}' tomcat_m_webapps_unpack: True tomcat_m_instances: - - { http_enabled: True, http_port: '{{ smartgears_http_port }}', http_address: '{{ smartgears_tomcat_listen_address }}', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '-1', java_home: '{{ jdk_java_home }}', user: '{{ smartgears_user }}', user_home: '{{ smartgears_user_home }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ smartgears_instance_path }}', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_use_ssl: '{{ tomcat_m_jmx_use_ssl }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/{{ smartgears_http_port }}/conf', jmx_monitorpass: '{{ tomcat_m_jmx_monitorpass | default(omit) }}', jmx_controlpass: '{{ tomcat_m_jmx_controlpass | default(omit) }}', remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_port: '{{ smartgears_debugging_port }}' , access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ '0.0.0.0/0' ], app_contexts: '{{ smartgears_tomcat_contexts }}', skip_smartgears: False,smartgears_id: 1, servername: '{{ ansible_fqdn }}' } + - { http_enabled: True, http_port: '{{ smartgears_http_port }}', http_address: '{{ smartgears_tomcat_listen_address }}', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '-1', java_home: '{{ jdk_java_home }}', user: '{{ smartgears_user }}', user_home: '{{ smartgears_user_home }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ smartgears_instance_path }}', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_use_ssl: '{{ tomcat_m_jmx_use_ssl }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/{{ smartgears_http_port }}/conf', jmx_monitorpass: '{{ tomcat_m_jmx_monitorpass | default(omit) }}', jmx_controlpass: '{{ tomcat_m_jmx_controlpass | default(omit) }}', catalina_tmp_directory: '{{ smartgears_tomcat_tmp_dir }}' remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_port: '{{ smartgears_debugging_port }}', access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ '0.0.0.0/0' ], app_contexts: '{{ smartgears_tomcat_contexts }}', skip_smartgears: False,smartgears_id: 1, servername: '{{ ansible_fqdn }}' } # To enable debugging: # - Set From 6dfaef66d0b36ad79090ed60a7f8aa9064fb1dc0 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 12:57:05 +0200 Subject: [PATCH 03/13] nginx: create the directory defined by the variable nginx_client_body_temp_dir, when the variable has been defined. --- nginx/tasks/nginx-config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nginx/tasks/nginx-config.yml b/nginx/tasks/nginx-config.yml index 6edd9d5..5e7c5ef 100644 --- a/nginx/tasks/nginx-config.yml +++ b/nginx/tasks/nginx-config.yml @@ -6,6 +6,10 @@ - name: Create the pki directory file: dest={{ pki_dir }}/nginx state=directory + - name: Create the client body tmp directory, if needed + file: dest={{ nginx_client_body_temp_dir }}/nginx state=directory owner=www-data group=www-data mode=0700 + when: nginx_client_body_temp_dir is defined + - name: Create a dhparams file 2048 bits long shell: openssl dhparam -out {{ pki_dir }}/nginx/dhparams.pem 2048 args: From 25eebdf57f50161ce77f1aa5d8dfab7f896e4759 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 13:02:18 +0200 Subject: [PATCH 04/13] Fix a typo. --- smartgears/smartgears/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartgears/smartgears/defaults/main.yml b/smartgears/smartgears/defaults/main.yml index 65c069a..27822ec 100644 --- a/smartgears/smartgears/defaults/main.yml +++ b/smartgears/smartgears/defaults/main.yml @@ -66,7 +66,7 @@ http_port: '{{ smartgears_http_port }}' tomcat_m_webapps_unpack: True tomcat_m_instances: - - { http_enabled: True, http_port: '{{ smartgears_http_port }}', http_address: '{{ smartgears_tomcat_listen_address }}', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '-1', java_home: '{{ jdk_java_home }}', user: '{{ smartgears_user }}', user_home: '{{ smartgears_user_home }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ smartgears_instance_path }}', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_use_ssl: '{{ tomcat_m_jmx_use_ssl }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/{{ smartgears_http_port }}/conf', jmx_monitorpass: '{{ tomcat_m_jmx_monitorpass | default(omit) }}', jmx_controlpass: '{{ tomcat_m_jmx_controlpass | default(omit) }}', catalina_tmp_directory: '{{ smartgears_tomcat_tmp_dir }}' remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_port: '{{ smartgears_debugging_port }}', access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ '0.0.0.0/0' ], app_contexts: '{{ smartgears_tomcat_contexts }}', skip_smartgears: False,smartgears_id: 1, servername: '{{ ansible_fqdn }}' } + - { http_enabled: True, http_port: '{{ smartgears_http_port }}', http_address: '{{ smartgears_tomcat_listen_address }}', ajp_enabled: False, ajp_port: '8109', ajp_address: '127.0.0.1', restart_timeout: '{{ tomcat_m_restart_timeout }}', shutdown_port: '-1', java_home: '{{ jdk_java_home }}', user: '{{ smartgears_user }}', user_home: '{{ smartgears_user_home }}', user_shell: '{{ tomcat_m_default_user_shell }}', instance_path: '{{ smartgears_instance_path }}', max_threads: '{{ tomcat_m_max_threads }}', autodeploy: '{{ tomcat_m_webapps_autodeploy }}', unpack: '{{ tomcat_m_webapps_unpack }}', default_conf: True, java_opts: '{{ tomcat_m_java_opts }}', java_gc_opts: '{{ tomcat_m_java_gc_opts }}', other_java_opts: '{{ tomcat_m_other_java_opts }}', jmx_enabled: '{{ tomcat_m_jmx_enabled }}', jmx_disable_additional_ports: '{{ tomcat_m_jmx_disable_additional_ports }}', jmx_port: '{{ tomcat_m_jmx_port }}', jmx_use_ssl: '{{ tomcat_m_jmx_use_ssl }}', jmx_auth_enabled: '{{ tomcat_m_jmx_auth_enabled }}', jmx_auth_dir: '{{ tomcat_m_instances_base_path }}/{{ smartgears_http_port }}/conf', jmx_monitorpass: '{{ tomcat_m_jmx_monitorpass | default(omit) }}', jmx_controlpass: '{{ tomcat_m_jmx_controlpass | default(omit) }}', catalina_tmp_directory: '{{ smartgears_tomcat_tmp_dir }}', remote_debugging: '{{ tomcat_m_enable_remote_debugging }}', remote_debugging_port: '{{ smartgears_debugging_port }}', access_log_enabled: True, log_rotation_freq: daily, log_retain: 30, allowed_hosts: [ '0.0.0.0/0' ], app_contexts: '{{ smartgears_tomcat_contexts }}', skip_smartgears: False,smartgears_id: 1, servername: '{{ ansible_fqdn }}' } # To enable debugging: # - Set From 042c6a7767c1d38e5df703924b0a62bae5a50172 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 13:02:27 +0200 Subject: [PATCH 05/13] tomcat-multiple-instances: Create the tmp directory with the correct permissions and ownership. --- tomcat-multiple-instances/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tomcat-multiple-instances/tasks/main.yml b/tomcat-multiple-instances/tasks/main.yml index c49dec1..114f785 100644 --- a/tomcat-multiple-instances/tasks/main.yml +++ b/tomcat-multiple-instances/tasks/main.yml @@ -56,8 +56,8 @@ register: tomcat_first_install tags: [ 'tomcat', 'tomcat_instances' ] -- name: Create the tmp directory - file: dest={{ item.catalina_tmp_directory }} state=directory +- name: Create the catalina tmp directory + file: dest={{ item.catalina_tmp_directory }} state=directory owner={{ item.0.user }} group={{ item.0.user }} mode=0700 with_items: '{{ tomcat_m_instances }}' when: item.catalina_tmp_directory is defined tags: [ 'tomcat', 'tomcat_instances' ] From 9308f7cdf01c428bca89530abe68723bb26984d0 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 13:05:31 +0200 Subject: [PATCH 06/13] tomcat-multiple-instances: Fix the permissions of the temp directory, again. --- tomcat-multiple-instances/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tomcat-multiple-instances/tasks/main.yml b/tomcat-multiple-instances/tasks/main.yml index 114f785..792556a 100644 --- a/tomcat-multiple-instances/tasks/main.yml +++ b/tomcat-multiple-instances/tasks/main.yml @@ -57,7 +57,7 @@ tags: [ 'tomcat', 'tomcat_instances' ] - name: Create the catalina tmp directory - file: dest={{ item.catalina_tmp_directory }} state=directory owner={{ item.0.user }} group={{ item.0.user }} mode=0700 + file: dest={{ item.catalina_tmp_directory }} state=directory owner={{ item.user }} group={{ item.user }} mode=0700 with_items: '{{ tomcat_m_instances }}' when: item.catalina_tmp_directory is defined tags: [ 'tomcat', 'tomcat_instances' ] From cb8cc3f3561b1869dee78351f17dc4bcccabf358 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 16:02:37 +0200 Subject: [PATCH 07/13] shiniproxy: Install version 1.0. Introduce a memory limit for the shiny apps. --- shinyproxy/defaults/main.yml | 6 ++++-- shinyproxy/templates/shinyproxy-conf.yml.j2 | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/shinyproxy/defaults/main.yml b/shinyproxy/defaults/main.yml index 8317353..4d0105f 100644 --- a/shinyproxy/defaults/main.yml +++ b/shinyproxy/defaults/main.yml @@ -1,6 +1,6 @@ --- shinyproxy_install: False -shinyproxy_version: 0.9.3 +shinyproxy_version: 1.0.0 shinyproxy_file_name: 'shinyproxy-{{ shinyproxy_version }}.jar' shinyproxy_url: 'https://www.shinyproxy.io/downloads/{{ shinyproxy_file_name }}' shinyproxy_app_name: shinyproxy.jar @@ -10,8 +10,10 @@ shinyproxy_http_port: 8080 # For logrotate. In days shinyproxy_log_retention: 10 shinyproxy_default_apps: True -shinyproxy_docker_url: 'http://localhost:2375/' +shinyproxy_docker_url: 'http://localhost:2375' shinyproxy_docker_port_range_start: 20000 +shinyproxy_container_wait_time: 60000 +shinyproxy_hide_navbar: 'false' shinyproxy_app_title: 'Open Analytics Shiny Proxy' shinyproxy_logo_url: 'http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png' diff --git a/shinyproxy/templates/shinyproxy-conf.yml.j2 b/shinyproxy/templates/shinyproxy-conf.yml.j2 index b75b1c5..482c2fc 100644 --- a/shinyproxy/templates/shinyproxy-conf.yml.j2 +++ b/shinyproxy/templates/shinyproxy-conf.yml.j2 @@ -5,7 +5,9 @@ shiny: landing-page: / heartbeat-rate: 10000 heartbeat-timeout: 60000 + container-wait-time: {{ shinyproxy_container_wait_time }} port: {{ shinyproxy_http_port }} + hide-navbar: {{ shinyproxy_hide_navbar }} authentication: {{ shinyproxy_authentication }} admin-groups: {{ shinyproxy_admin_group }} {% if shinyproxy_ldap_enabled %} @@ -49,9 +51,11 @@ shiny: description: {{ app.description }} docker-cmd: ["R", "-e {{ app.cmd }}"] docker-image: {{ app.docker_image }} + docker-memory: {{ app.docker_memory | default('2g') }} {% if app.groups is defined %} groups: {{ app.groups }} {% endif %} + {% endfor %} {% endif %} From cc74bb44f12097a4a713e2364e97b92f59915019 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 16:16:24 +0200 Subject: [PATCH 08/13] shinyproxy: add a task that pulls the new images. --- shinyproxy/tasks/main.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shinyproxy/tasks/main.yml b/shinyproxy/tasks/main.yml index 596ac19..574f13a 100644 --- a/shinyproxy/tasks/main.yml +++ b/shinyproxy/tasks/main.yml @@ -20,7 +20,7 @@ - name: Install the shinyproxy configuration file template: src=shinyproxy-conf.yml.j2 dest={{ shinyproxy_install_dir }}/application.yml owner=root group={{ shinyproxy_user }} mode=0640 notify: Restart shinyproxy - tags: [ 'shinyproxy', 'shinyproxy_conf' ] + tags: [ 'shinyproxy', 'shinyproxy_conf', 'shinyproxy_images' ] - name: Install the shinyproxy logrotate configuration template: src=shinyproxy-logrotate.j2 dest=/etc/logrotate.d/shinyproxy owner=root group=root mode=0444 @@ -29,6 +29,12 @@ - name: Ensure that the shinyproxy service is enabled and running service: name=shinyproxy state=started enabled=yes + - name: Pull the Docker images of shiny apps + docker_image: name={{ item.docker_image }} pull=yes state=present + with_items: '{{ shinyproxy_apps }}' + when: shinyproxy_apps is defined + tags: [ 'shinyproxy', 'shinyproxy_images' ] + when: shinyproxy_install tags: shinyproxy From f2196b3cf9318b7e4e0c378705a1497c8753eacf Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 19:22:56 +0200 Subject: [PATCH 09/13] More fixes to the algorithms updater script. --- .../templates/algorithms-updater.j2 | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/smartgears/dataminer_app/templates/algorithms-updater.j2 b/smartgears/dataminer_app/templates/algorithms-updater.j2 index 879bae0..450c1b6 100644 --- a/smartgears/dataminer_app/templates/algorithms-updater.j2 +++ b/smartgears/dataminer_app/templates/algorithms-updater.j2 @@ -87,40 +87,13 @@ function algorithms_updater() { ALGO_NAME=$( echo "$algo" | awk -F \| '{ print $1 }' ) ALGO_BODY=$( echo "$algo" | awk -F \| '{ print $2 }' ) ALGO_DATE=$( echo "$algo" | awk -F \| '{ print $3 }' ) - ALGO_TIMESTAMP=$( date +%s -d "$ALGO_DATE" ) + ALGO_TIMESTAMP=$( date +%s -d "$ALGO_DATE" 2>/dev/null ) if [ $? -ne 0 ] ; then echo "the date for algorithm $ALGO_NAME is wrong" - fi - ALGO_LINE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE ) - ALGO_PRESENT=$? - if [ $ALGO_PRESENT -ne 0 ] ; then - echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "RETVAL=" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo '-------------------------------------------'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo 'Adding algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo 'With command $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "$ALGO_BODY" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo 'RETVAL=$?' >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo 'Done.'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_ else - ALGO_LOCAL_TIMESTAMP=0 - ALGO_LOCAL_DATE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | awk -F \| '{ print $2 }' | grep -v \' ) - ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" ) - if [ $? -ne 0 ] ; then - echo "the locally saved date for algorithm $ALGO_NAME is wrong" - fi - if [ $ALGO_LOCAL_TIMESTAMP -ne $ALGO_TIMESTAMP ] ; then + ALGO_LINE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE ) + ALGO_PRESENT=$? + if [ $ALGO_PRESENT -ne 0 ] ; then echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "RETVAL=" >> $ALGORITHMS_TEMP_SCRIPT.body_ @@ -137,11 +110,39 @@ function algorithms_updater() { echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo 'grep -v $ALGO_NAME $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo '$ALGO_NAME | $ALGO_TIMESTAMP' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_ + else + ALGO_LOCAL_TIMESTAMP=0 + # ALGO_LOCAL_DATE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | awk -F \| '{ print $2 }' | grep -v \' ) + # ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" 2>/dev/null ) + ALGO_LOCAL_TIMESTAMP=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | tail -1 | awk -F \| '{ print $2 }' | grep -v \' ) + if [ $? -ne 0 ] || [ $ALGO_LOCAL_TIMESTAMP -ne $ALGO_TIMESTAMP ]; then + echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "RETVAL=" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo '-------------------------------------------'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo 'Adding algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo 'With command $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "$ALGO_BODY" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo 'RETVAL=$?' >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo 'Done.'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "echo ''" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo '$ALGO_NAME | $ALGO_TIMESTAMP' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_ + fi fi fi done < ${ALGORITHMS_TEMP_SCRIPT}.algorithmslist From daeda765a16a86b12c0d99f67b7b7adfc231e88f Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 19:25:06 +0200 Subject: [PATCH 10/13] Other fixes to library/roles/smartgears/dataminer_app/templates/algorithms-updater.j2. --- smartgears/dataminer_app/templates/algorithms-updater.j2 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/smartgears/dataminer_app/templates/algorithms-updater.j2 b/smartgears/dataminer_app/templates/algorithms-updater.j2 index 450c1b6..19d2e91 100644 --- a/smartgears/dataminer_app/templates/algorithms-updater.j2 +++ b/smartgears/dataminer_app/templates/algorithms-updater.j2 @@ -112,14 +112,13 @@ function algorithms_updater() { echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo '$ALGO_NAME | $ALGO_TIMESTAMP' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_ else ALGO_LOCAL_TIMESTAMP=0 - # ALGO_LOCAL_DATE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | awk -F \| '{ print $2 }' | grep -v \' ) - # ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" 2>/dev/null ) - ALGO_LOCAL_TIMESTAMP=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE | tail -1 | awk -F \| '{ print $2 }' | grep -v \' ) + ALGO_LOCAL_DATE=$( egrep ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE | tail -1 | awk -F \| '{ print $2 }' | grep -v \' ) + ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" 2>/dev/null ) if [ $? -ne 0 ] || [ $ALGO_LOCAL_TIMESTAMP -ne $ALGO_TIMESTAMP ]; then echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ @@ -139,7 +138,7 @@ function algorithms_updater() { echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo '$ALGO_NAME | $ALGO_TIMESTAMP' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_ fi From 56df697c0e9460849ffc3b4f125a5baa7aaced7c Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 19:25:58 +0200 Subject: [PATCH 11/13] Fix the ckan-connector-fixer.sh.j2 script. --- smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 b/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 index 992e2e8..028f791 100644 --- a/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 +++ b/smartgears/ckan_connector/templates/ckan-connector-fixer.sh.j2 @@ -47,8 +47,8 @@ cd /usr/lib/ckan/default/src/ckan if [ "$CKAN_CREATE_USER" == "True" ] ; then # Create the admin user paster sysadmin add $CK_ADMIN -c $CK_INI << EOF - y + $CK_ADMIN_PWD $CK_ADMIN_PWD From b011d82213f9ca8308d463a4e3a9c8515c3aec21 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 15 Sep 2017 19:38:57 +0200 Subject: [PATCH 12/13] Correct another case of the algorithms-updater script. --- .../dataminer_app/templates/algorithms-updater.j2 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/smartgears/dataminer_app/templates/algorithms-updater.j2 b/smartgears/dataminer_app/templates/algorithms-updater.j2 index 19d2e91..b82a145 100644 --- a/smartgears/dataminer_app/templates/algorithms-updater.j2 +++ b/smartgears/dataminer_app/templates/algorithms-updater.j2 @@ -91,7 +91,7 @@ function algorithms_updater() { if [ $? -ne 0 ] ; then echo "the date for algorithm $ALGO_NAME is wrong" else - ALGO_LINE=$( egrep ^"$ALGO_NAME" $ALGORITHMS_INSTALLED_FILE ) + ALGO_LINE=$( egrep ^"$ALGO_NAME " $ALGORITHMS_INSTALLED_FILE ) ALGO_PRESENT=$? if [ $ALGO_PRESENT -ne 0 ] ; then echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ @@ -110,15 +110,15 @@ function algorithms_updater() { echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo 'egrep -v ^"$ALGO_NAME " $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "fi" >> $ALGORITHMS_TEMP_SCRIPT.body_ else ALGO_LOCAL_TIMESTAMP=0 - ALGO_LOCAL_DATE=$( egrep ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE | tail -1 | awk -F \| '{ print $2 }' | grep -v \' ) - ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" 2>/dev/null ) + ALGO_LOCAL_DATE=$( egrep ^"$ALGO_NAME " $ALGORITHMS_INSTALLED_FILE | tail -1 | awk -F \| '{ print $2 }' | grep -v \' ) + ALGO_LOCAL_TIMESTAMP=$( date +%s -d "$ALGO_LOCAL_DATE" 2>/dev/null ) if [ $? -ne 0 ] || [ $ALGO_LOCAL_TIMESTAMP -ne $ALGO_TIMESTAMP ]; then echo "logger 'algorithms-updater: running the add command of algorithm $ALGO_NAME'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "logger 'algorithms-updater: the add command string is $ALGO_BODY'" >> $ALGORITHMS_TEMP_SCRIPT.body_ @@ -136,7 +136,7 @@ function algorithms_updater() { echo 'if [ $RETVAL -ne 0 ] ; then' >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME failed'" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo "else" >> $ALGORITHMS_TEMP_SCRIPT.body_ - echo " echo 'egrep -v ^$ALGO_NAME\ $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ + echo " echo 'egrep -v "^$ALGO_NAME " $ALGORITHMS_INSTALLED_FILE > ${ALGORITHMS_INSTALLED_FILE}_ " >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo 'mv ${ALGORITHMS_INSTALLED_FILE}_ $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " echo '$ALGO_NAME | $ALGO_DATE' >> $ALGORITHMS_INSTALLED_FILE" >> $ALGORITHMS_TEMP_SCRIPT.body_ echo " logger 'algorithms-updater: the adding of algorithm $ALGO_NAME succeeded'" >> $ALGORITHMS_TEMP_SCRIPT.body_ From 4f79fdd574ec94d11617688a4e08c023aecf03d5 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Sun, 17 Sep 2017 16:27:28 +0200 Subject: [PATCH 13/13] shinyproxy: Force the pull of newer images. --- shinyproxy/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shinyproxy/tasks/main.yml b/shinyproxy/tasks/main.yml index 574f13a..28e5ddd 100644 --- a/shinyproxy/tasks/main.yml +++ b/shinyproxy/tasks/main.yml @@ -30,7 +30,7 @@ service: name=shinyproxy state=started enabled=yes - name: Pull the Docker images of shiny apps - docker_image: name={{ item.docker_image }} pull=yes state=present + docker_image: name={{ item.docker_image }} pull=yes state={{ item.image_state | default('present') }} force=yes with_items: '{{ shinyproxy_apps }}' when: shinyproxy_apps is defined tags: [ 'shinyproxy', 'shinyproxy_images' ]