diff --git a/R/defaults/main.yml b/R/defaults/main.yml index 9a795501..be54b86e 100644 --- a/R/defaults/main.yml +++ b/R/defaults/main.yml @@ -14,6 +14,8 @@ r_cran_mirror_site: http://cran.mirror.garr.it/mirrors/CRAN/ r_base_pkg_version: 2.14.1 r_packages_state: present +r_source_plugins_dest_dir: /var/cache/R + r_base_packages_list: - r-base - jags @@ -39,6 +41,9 @@ r_plugins_packages_list: - r-cran-spatial - r-cran-survival +# r_plugins_from_sources: +# - { name: 'plyr', version: '1.7.1', source: 'plyr_1.7.1.tar.gz', url: 'http://cran.r-project.org/src/contrib/Archive/plyr/plyr_1.7.1.tar.gz' } + r_plugins_list_to_install: - R2WinBUGS - R2jags @@ -54,6 +59,7 @@ r_plugins_list_to_install: - grid - methods - parallel + - reshape - splines - stats - stats4 diff --git a/R/tasks/main.yml b/R/tasks/main.yml index a0cfb881..312e6847 100644 --- a/R/tasks/main.yml +++ b/R/tasks/main.yml @@ -44,6 +44,27 @@ - r_software - r_pkg +- name: Ensure that the R plugin sources directory exists + file: dest={{ r_source_plugins_dest_dir }} state=directory owner=root group=root + when: r_plugins_from_sources is defined + tags: [ 'r_software', 'r_pkg', 'r_plugins' ] + +- name: Get the R plugin sources that need to be installed + get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }} + with_items: r_plugins_from_sources + when: r_plugins_from_sources is defined + tags: [ 'r_software', 'r_pkg', 'r_plugins' ] + +- name: Install R plugins from the cran sources + 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'); }" + 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 + when: r_plugins_from_sources is defined + tags: [ 'r_software', 'r_pkg', 'r_plugins' ] + - name: Install R plugins from the cran binaries repo 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'); }" @@ -51,9 +72,6 @@ failed_when: "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr" changed_when: "'Added' in install_plugins_result.stdout" with_items: r_plugins_list_to_install - tags: - - r_software - - r_pkg - + tags: [ 'r_software', 'r_pkg', 'r_plugins' ]