diff --git a/smartgears/accounting_rstudio_se_plugin/defaults/main.yml b/smartgears/accounting_rstudio_se_plugin/defaults/main.yml index e2f3591d..ec556e55 100644 --- a/smartgears/accounting_rstudio_se_plugin/defaults/main.yml +++ b/smartgears/accounting_rstudio_se_plugin/defaults/main.yml @@ -1,32 +1,13 @@ --- -accounting_aggregator_se_plugin_install: False -accounting_aggregator_se_plugin_ver: 1.1.0-4.5.0-148744 -accounting_aggregator_se_plugin_name: 'accounting-aggregator-se-plugin-{{ accounting_aggregator_se_plugin_ver }}-jar-with-dependencies.jar' -accounting_aggregator_se_plugin_url: 'http://maven.research-infrastructures.eu/nexus/content/repositories/{{ gcube_repository }}/org/gcube/accounting/accounting-aggregator-se-plugin/{{ accounting_aggregator_se_plugin_ver }}/{{ accounting_aggregator_se_plugin_name }}' - -accounting_aggregator_se_plugin_maven_group_id : 'org.gcube.accounting' -accounting_aggregator_se_plugin_maven_artifact_id : 'accounting-aggregator-se-plugin' -accounting_aggregator_se_plugin_maven_version : '1.0.0-SNAPSHOT' - - -accounting_insert_storage_se_plugin_install: False -accounting_insert_storage_se_plugin_ver: 1.0.1-4.5.0-148393 -accounting_insert_storage_se_plugin_name: '{{ accounting_insert_storage_se_plugin_maven_artifact_id }}-{{ accounting_insert_storage_se_plugin_ver }}-jar-with-dependencies.jar' -accounting_insert_storage_se_plugin_url: 'http://maven.research-infrastructures.eu/nexus/content/repositories/{{ gcube_repository }}/org/gcube/accounting/{{ accounting_insert_storage_se_plugin_maven_artifact_id }}/{{ accounting_insert_storage_se_plugin_ver }}/{{ accounting_insert_storage_se_plugin_name }}' - -accounting_insert_storage_se_plugin_maven_group_id : 'org.gcube.accounting' -accounting_insert_storage_se_plugin_maven_artifact_id : 'accounting-insert-storage-se-plugin' -accounting_insert_storage_se_plugin_maven_version : '1.0.0-4.4.0-142716' - - - -# To be moved in RStudio playbook - accounting_insert_rstudio_se_plugin_install: False -accounting_insert_rstudio_se_plugin_ver: 1.0.0-4.5.0-148358 -accounting_insert_rstudio_se_plugin_name: '{{ accounting_insert_rstudio_se_plugin_maven_artifact_id }}-{{ accounting_insert_rstudio_se_plugin_ver }}-jar-with-dependencies.jar' -accounting_insert_rstudio_se_plugin_url: 'http://maven.research-infrastructures.eu/nexus/content/repositories/{{ gcube_repository }}/org/gcube/accounting/{{ accounting_insert_rstudio_se_plugin_maven_artifact_id }}/{{ accounting_insert_rstudio_se_plugin_ver }}/{{ accounting_insert_rstudio_se_plugin_name }}' +accounting_insert_rstudio_se_plugin_name: accounting-insert-rstudio-se-plugin -accounting_insert_rstudio_se_plugin_maven_group_id : 'org.gcube.accounting' -accounting_insert_rstudio_se_plugin_maven_artifact_id : 'accounting-insert-rstudio-se-plugin' -accounting_insert_rstudio_se_plugin_maven_version : '1.0.0-4.4.0-142716' +accounting_insert_rstudio_se_plugin_version: '1.0.0-4.4.0-142716' +accounting_insert_rstudio_se_plugin_group_id: 'org.gcube.accounting' +accounting_insert_rstudio_se_plugin_artifact_id: accounting-insert-rstudio-se-plugin +accounting_insert_rstudio_se_plugin_extension: jar +accounting_insert_rstudio_se_plugin_classifier: jar-with-dependencies +accounting_insert_rstudio_se_plugin_file: '{{ accounting_insert_rstudio_se_plugin_name }}-{{ accounting_insert_rstudio_se_plugin_version }}-{{ accounting_insert_rstudio_se_plugin_classifier }}.{{ accounting_insert_rstudio_se_plugin_extension }}' + +accounting_rstudio_quota_dest_dir: /srv/d4science +accounting_rstudio_quota_dest_file: '{{ accounting_rstudio_quota_dest_dir }}/home_disk_space' diff --git a/smartgears/accounting_rstudio_se_plugin/tasks/main.yml b/smartgears/accounting_rstudio_se_plugin/tasks/main.yml index 777c8012..a179b496 100644 --- a/smartgears/accounting_rstudio_se_plugin/tasks/main.yml +++ b/smartgears/accounting_rstudio_se_plugin/tasks/main.yml @@ -1,42 +1,27 @@ --- -- name: Remove the old accounting aggregator plugin - shell: rm -f {{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib/accounting-aggregator-se-plugin-*-jar-with-dependencies.jar - when: accounting_aggregator_se_plugin_upgrade - tags: [ 'smartgears', 'accounting_aggregator_se', 'tomcat' ] +- block: + - name: Get the accounting insert storage plugin and install it inside the smart executor + maven_artifact: artifact_id={{ accounting_insert_rstudio_se_plugin_name }} version={{ accounting_insert_rstudio_se_plugin_version | default(omit) }} group_id={{ accounting_insert_rstudio_se_plugin_group_id }} extension={{ accounting_insert_rstudio_se_plugin_extension | default('war') }} repository_url={{ smartgears_global_base_url }} classifier={{ accounting_insert_rstudio_se_plugin_classifier }} dest={{ smartgears_downloads_dir }}/{{ accounting_insert_rstudio_se_plugin_file }} + register: accounting_insert_rstudio_download + + - name: Remove the old accounting insert storage plugin + shell: rm -f {{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib/{{ accounting_insert_rstudio_se_plugin_maven_artifact_id }}-*-jar-with-dependencies.jar + when: (accounting_insert_rstudio_download | changed) -- name: Remove the old accounting insert storage plugin - shell: rm -f {{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib/{{ accounting_insert_storage_se_plugin_maven_artifact_id }}-*-jar-with-dependencies.jar - when: accounting_insert_storage_se_plugin_upgrade - tags: [ 'smartgears', 'accounting_insert_storage_se', 'tomcat' ] + - name: Copy the accounting aggregator plugin to its final destination + copy: src={{ smartgears_downloads_dir }}/{{ accounting_insert_rstudio_se_plugin_file }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib/{{ accounting_insert_rstudio_se_plugin_file }} remote_src=yes + when: (accounting_insert_rstudio_download | changed) + notify: Restart smartgears + - name: Install the script that calculates the occupied space for each user + become_user: root + template: src=calculate_home_space.j2 dest=/usr/local/bin/calculate_home_space mode=0755 owner=root group=root -- name: Remove the old accounting rstudio storage plugin - shell: rm -f {{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib/{{ accounting_insert_rstudio_se_plugin_maven_artifact_id }}-*-jar-with-dependencies.jar - when: accounting_insert_rstudio_se_plugin_upgrade + - name: Install a cron job that runs the calculates the home used space + cron: name="Calculate the home used space" special_time=hourly user=root job="/usr/local/bin/calculate_home_space >/dev/null 2>&1" + + become: True + become_user: '{{ smartgears_user }}' + when: accounting_insert_rstudio_se_plugin_install tags: [ 'smartgears', 'accounting_insert_rstudio_se', 'tomcat' ] - -- name: Get the accounting aggregator plugin and install it inside the smart executor - become: True - become_user: '{{ smartgears_user }}' - get_url: url={{ accounting_aggregator_se_plugin_url }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib - when: accounting_aggregator_se_plugin_install - notify: Restart smartgears - tags: [ 'smartgears', 'accounting_aggregator_se', 'tomcat' ] - - -- name: Get the accounting insert storage plugin and install it inside the smart executor - become: True - become_user: '{{ smartgears_user }}' - get_url: url={{ accounting_insert_storage_se_plugin_url }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib - when: accounting_insert_storage_se_plugin_install - notify: Restart smartgears - tags: [ 'smartgears', 'accounting_insert_storage_se', 'tomcat' ] - -- name: Get the accounting insert rstudio plugin and install it inside the smart executor - become: True - become_user: '{{ smartgears_user }}' - get_url: url={{ accounting_insert_rstudio_se_plugin_url }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib - when: accounting_insert_rstudio_se_plugin_install - notify: Restart smartgears - tags: [ 'smartgears', 'accounting_insert_rstudio_se', 'tomcat' ] diff --git a/smartgears/accounting_rstudio_se_plugin/templates/calculate_home_space.j2 b/smartgears/accounting_rstudio_se_plugin/templates/calculate_home_space.j2 new file mode 100644 index 00000000..2bf2bf3a --- /dev/null +++ b/smartgears/accounting_rstudio_se_plugin/templates/calculate_home_space.j2 @@ -0,0 +1,9 @@ +#!/bin/bash + +DEST_FILE={{ accounting_rstudio_quota_dest_file }} +mkdir -p {{ accounting_rstudio_quota_dest_dir }} + +> $DEST_FILE +cd /home ; for h in $( /bin/ls -1 . | grep -v gcube ) ; do du -s ${h} >> $DEST_FILE ; done + +exit 0