From 465eeb8fe7d13e1d0ba1bb24784fdc851511807e Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 14 Oct 2016 14:33:19 +0200 Subject: [PATCH] library/isti_vars/r-packages.yml: Add some R packages. library/roles/R/tasks/r-installation.yml: Add some checks. --- R/tasks/r-installation.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/R/tasks/r-installation.yml b/R/tasks/r-installation.yml index f15c3302..93af5b35 100644 --- a/R/tasks/r-installation.yml +++ b/R/tasks/r-installation.yml @@ -102,6 +102,26 @@ tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ] ignore_errors: True +- name: Install R packages from the cran sources, specific versions. First round + 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 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 + 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' + with_items: '{{ r_plugins_from_sources | default([]) }}' + ignore_errors: True + tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ] + +- name: Install R packages from the cran sources, specific versions. Second round, to avoid circular dependencies + 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 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 + 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' + with_items: '{{ r_plugins_from_sources | default([]) }}' + when: ( install_s_plugins_result | failed ) + tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ] + - 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'); }" @@ -111,3 +131,4 @@ with_items: '{{ r_plugins_list_to_remove | default([]) }}' when: r_plugins_list_to_remove is defined tags: [ 'r_software', 'r_pkg', 'r_plugins' ] +