library/roles/R/tasks/main.yml: better test for the task that installs specific versions of the R library packages.

library/roles/R/tasks/main.yml: implement packages removal.
d4science-ghn-cluster/roles/dataminer_app/tasks/main.yml: Cleanup the pom dependencies mess.
This commit is contained in:
Andrea Dell'Amico 2015-12-03 17:16:44 +01:00
parent 771abd8491
commit 39a12b2936
2 changed files with 23 additions and 14 deletions

View File

@ -88,6 +88,6 @@ r_plugins_list_to_install:
# - { plugin_name: 'RFigisGeo', github_user: 'openfigis' } # - { plugin_name: 'RFigisGeo', github_user: 'openfigis' }
# - { plugin_name: 'rsdmx', github_user: 'opensdmx' } # - { plugin_name: 'rsdmx', github_user: 'opensdmx' }
# Plugins removal not yet implemented #
#r_plugins_list_to_remove: #r_plugins_list_to_remove:

View File

@ -24,28 +24,28 @@
when: r_needs_additional_distro_pkgs when: r_needs_additional_distro_pkgs
tags: [ 'r_software', 'r_pkg' ] tags: [ 'r_software', 'r_pkg' ]
- name: Ensure that the R plugin sources directory exists - name: Ensure that the R packages sources directory exists
file: dest={{ r_source_plugins_dest_dir }} state=directory owner=root group=root file: dest={{ r_source_plugins_dest_dir }} state=directory owner=root group=root
when: r_plugins_from_sources is defined when: r_plugins_from_sources is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
- name: Get the R plugin sources that need to be installed - name: Get the R packages sources that need to be installed
get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }} get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }}
with_items: r_plugins_from_sources with_items: r_plugins_from_sources
when: r_plugins_from_sources is defined when: r_plugins_from_sources is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
- name: Install R plugins from the cran sources, specific versions - name: Install R packages from the cran sources, specific versions
command: > command: >
Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.name }}' %in% installed.packages()[,'Package'])) { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else { print('Already Installed'); }" Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.name }}' %in% installed.packages()[,'Package'])) { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else if (packageVersion('{{ item.name }}') != '{{ item.version }}') { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else { print('Already Installed'); }"
register: install_s_plugins_result register: install_s_plugins_result
failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr"
changed_when: "'Added' in install_s_plugins_result.stdout" changed_when: '"Added" in install_s_plugins_result.stdout'
with_items: r_plugins_from_sources with_items: r_plugins_from_sources
when: r_plugins_install_specific_source when: r_plugins_install_specific_source
tags: [ 'r_software', 'r_pkg', 'r_plugins' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
- name: Install R plugins from the cran sources repo, latest version - name: Install R packages from the cran sources repo, latest version
command: > command: >
Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item }}' %in% installed.packages()[,'Package'])) { install.packages(pkgs='{{ item }}', repos=c('{{ r_cran_mirror_site }}/')); print('Added'); } else { print('Already installed'); }" Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item }}' %in% installed.packages()[,'Package'])) { install.packages(pkgs='{{ item }}', repos=c('{{ r_cran_mirror_site }}/')); print('Added'); } else { print('Already installed'); }"
register: install_plugins_result register: install_plugins_result
@ -55,13 +55,22 @@
when: r_plugins_install_latest_source when: r_plugins_install_latest_source
tags: [ 'r_software', 'r_pkg', 'r_plugins' ] tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
- name: Install R plugins from github - name: Install R packages from github
command: > command: >
Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.plugin_name }}' %in% installed.packages()[,'Package'])) { require(devtools); require(methods) ; options(repos='{{ r_cran_mirror_site }}/') ; install_github('{{ item.plugin_name }}', '{{ item.github_user }}'); print('Added'); } else { print('Already Installed'); }" Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.plugin_name }}' %in% installed.packages()[,'Package'])) { require(devtools); require(methods) ; options(repos='{{ r_cran_mirror_site }}/') ; install_github('{{ item.plugin_name }}', '{{ item.github_user }}'); print('Added'); } else { print('Already Installed'); }"
register: install_s_plugins_result register: install_github_plugins_result
failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" failed_when: "install_github_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr"
changed_when: "'Added' in install_s_plugins_result.stdout" changed_when: "'Added' in install_github_plugins_result.stdout"
with_items: r_plugins_from_github with_items: r_plugins_from_github
when: r_plugins_from_github is defined when: r_plugins_from_github is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ] tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ]
- name: Remove R unwanted packages
command: >
Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item }}' %in% installed.packages()[,'Package'])) { print('Not installed'); } else { remove.packages(pkgs='{{ item }}'); print('Removed'); }"
register: remove_plugins_result
failed_when: remove_plugins_result.rc != 0
changed_when: "'Removed' in remove_plugins_result.stdout"
with_items: r_plugins_list_to_remove
when: r_plugins_list_to_remove is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]