From 5a4d729503649e7a03aab331775c2941d0b8a660 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Sat, 7 Apr 2018 18:32:12 +0200 Subject: [PATCH] Change the dataminer roles again so that the algorithms are always installed but the script that adds them is optiona. --- .../tasks/dataminer-algorithms-installer.yml | 65 ++++++++++--------- .../dataminer_app/tasks/dataminer-app.yml | 12 +++- smartgears/dataminer_app/tasks/main.yml | 2 +- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/smartgears/dataminer_app/tasks/dataminer-algorithms-installer.yml b/smartgears/dataminer_app/tasks/dataminer-algorithms-installer.yml index f806e40..d05d980 100644 --- a/smartgears/dataminer_app/tasks/dataminer-algorithms-installer.yml +++ b/smartgears/dataminer_app/tasks/dataminer-algorithms-installer.yml @@ -1,5 +1,23 @@ --- -# This is only needed to force an upgrade of the algorithm importer script +- block: + - name: Install the subversion packages + become_user: root + apt: pkg=subversion state=present update_cache=yes cache_valid_time=1800 + + - name: Create a directory where to install the algorithms directory + file: path={{ smartgears_user_home }}/wps_algorithms/algorithms state=directory + tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_svn' ] + + - name: Download the WPS algorithms from subversion + subversion: repo={{ dataminer_wps_algorithms_svn }} dest={{ smartgears_user_home }}/wps_algorithms/algorithms/{{ dataminer_infra_reference }} checkout=yes force=yes update=yes + tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_svn' ] + + become: True + become_user: '{{ smartgears_user }}' + tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_installer' ] + + +# This is only needed to force an upgrade of the algorithm importer script and libraries - block: - name: Remove the old dataminer algorithm installer to force an upgrade file: path={{ smartgears_user_home }}/algorithmInstaller state=absent @@ -10,33 +28,12 @@ become: True become_user: '{{ smartgears_user }}' when: - - dataminer_app_install + - dataminer_algorithms_installer - dataminer_algorithms_upgrade tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_installer' ] - + - block: - - - name: Verify if we have the old algorithms setup - stat: path={{ smartgears_user_home }}/wps_algorithms/algorithms/AAPS_NASO_PUBLISHER.jar - register: old_algo_setup - - - name: Wipe away the algoriths directory if it comes from the old setup - file: dest={{ smartgears_user_home }}/wps_algorithms state=absent - when: old_algo_setup.stat.exists - - - name: Create a directory where to install the algorithms directory - file: path={{ smartgears_user_home }}/wps_algorithms/algorithms state=directory - tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_svn' ] - - - name: Install the subversion packages - become_user: root - apt: pkg=subversion state=present update_cache=yes cache_valid_time=1800 - - - name: Download the WPS algorithms from subversion - subversion: repo={{ dataminer_wps_algorithms_svn }} dest={{ smartgears_user_home }}/wps_algorithms/algorithms/{{ dataminer_infra_reference }} checkout=yes force=yes update=yes - tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_svn' ] - - name: Get the algorithms installer via maven_artifact maven_artifact: artifact_id={{ dataminer_algorithms_name }} version={{ dataminer_algorithms_version | default(omit) }} group_id={{ dataminer_algorithms_group_id }} extension={{ dataminer_algorithms_extension | default('war') }} repository_url={{ dataminer_algorithms_base_url }} dest={{ smartgears_downloads_dir }}/{{ dataminer_algorithms_file }} register: algorithms_installer_downloaded @@ -49,6 +46,7 @@ - name: Unarchive the algorithms installer unarchive: copy=no src={{ smartgears_downloads_dir }}/{{ dataminer_algorithms_file }} dest={{ smartgears_user_home }} creates='{{ smartgears_user_home }}/algorithmInstaller/addAlgorithm.sh' + notify: Restart smartgears tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_installer' ] - name: Create a directory where to install the algorithms updater logs and data @@ -60,18 +58,23 @@ template: src=algorithms-updater.j2 dest=/usr/local/bin/algorithms-updater mode=0755 tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_script' ] - - name: Remove the list of the installed algorithms if we are upgrading from the old algorithms setup - file: dest={{ smartgears_user_home }}/wps_algorithms_install_log/already_installed_algorithms.txt state=absent - when: old_algo_setup.stat.exists - - name: Cron job that updates the algorithms repository and adds the missing algorithms configurations cron: name="SVN update the algorithms repository" minute="{{ dataminer_algorithms_updater_minute_frequency }}" hour="{{ dataminer_algorithms_updater_hour_frequency }}" job="/usr/local/bin/algorithms-updater > {{ smartgears_user_home }}/wps_algorithms_install_log/algorithms_updater_cron.log 2>&1" user='{{ smartgears_user }}' state={{ dataminer_algorithms_updater_cron }} tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_cron' ] become: True become_user: '{{ smartgears_user }}' - when: - - dataminer_app_install - - dataminer_algorithms_upgrade + when: dataminer_algorithms_installer tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_installer' ] +- block: + - name: Remove the cron job that updates the algorithms repository and adds the missing algorithms configurations + cron: name="SVN update the algorithms repository" minute="{{ dataminer_algorithms_updater_minute_frequency }}" hour="{{ dataminer_algorithms_updater_hour_frequency }}" job="/usr/local/bin/algorithms-updater > {{ smartgears_user_home }}/wps_algorithms_install_log/algorithms_updater_cron.log 2>&1" user='{{ smartgears_user }}' state={{ dataminer_algorithms_updater_cron }} state=absent + tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_cron' ] + + become: True + become_user: '{{ smartgears_user }}' + when: not dataminer_algorithms_installer + tags: [ 'tomcat', 'dataminer', 'wps', 'dataminer_algorithms', 'dataminer_algorithms_installer' ] + + \ No newline at end of file diff --git a/smartgears/dataminer_app/tasks/dataminer-app.yml b/smartgears/dataminer_app/tasks/dataminer-app.yml index 97aca12..18d3656 100644 --- a/smartgears/dataminer_app/tasks/dataminer-app.yml +++ b/smartgears/dataminer_app/tasks/dataminer-app.yml @@ -35,13 +35,20 @@ - name: Remove the file that lists the installed algorithms, after an upgrade file: dest={{ smartgears_user_home }}/wps_algorithms_install_log/already_installed_algorithms.txt state=absent + register: reinstall_algorithms when: dataminer_updated is changed + - name: After an update, reinstall the algorithms + shell: /usr/local/bin/algorithms-updater & + when: + - reinstall_algorithms is changed + - dataminer_algorithms_installer + become: True become_user: '{{ smartgears_user }}' - when: dataminer_app_install tags: [ 'tomcat', 'dataminer', 'wps' ] + - block: - name: Install the nscd service to work around dns timeouts @@ -56,10 +63,9 @@ when: dataminer_install_nscd is defined and dataminer_install_nscd tags: [ 'tomcat', 'dataminer', 'wps', 'dm_nscd' ] - become: True become_user: '{{ smartgears_user }}' - when: + when: - dataminer_app_install - dataminer_install_nscd tags: [ 'tomcat', 'dataminer', 'wps' ] diff --git a/smartgears/dataminer_app/tasks/main.yml b/smartgears/dataminer_app/tasks/main.yml index 08a8296..19fd157 100644 --- a/smartgears/dataminer_app/tasks/main.yml +++ b/smartgears/dataminer_app/tasks/main.yml @@ -7,4 +7,4 @@ when: dataminer_app_install - import_tasks: install-gcube-key.yml - import_tasks: dataminer-algorithms-installer.yml - when: dataminer_algorithms_installer + when: dataminer_app_install