library/roles/R/tasks/r-installation.yml: Try to avoid a double run of the R packages install task.

This commit is contained in:
Andrea Dell'Amico 2016-03-01 16:17:54 +01:00
parent 44c7857c8f
commit 7e3ad01c35
1 changed files with 18 additions and 2 deletions

View File

@ -48,7 +48,7 @@
when: r_plugins_from_sources is defined
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
- name: Install R packages from the cran sources repo, latest available version
- name: Install R packages from the cran sources repo, latest available version. First try
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'); }"
register: install_plugins_result
@ -56,6 +56,7 @@
changed_when: "'Added' in install_plugins_result.stdout"
with_items: r_plugins_list_to_install
when: r_plugins_install_latest_source
ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
- name: Get the R packages sources that need to be installed
@ -72,6 +73,7 @@
changed_when: '"Added" in install_s_plugins_result.stdout'
with_items: r_plugins_from_sources
when: r_plugins_install_specific_source
register: r_packages_specific_source
ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
@ -82,9 +84,23 @@
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_install_specific_source
when:
- r_plugins_install_specific_source
- "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr"
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
- name: Install R packages from the cran sources repo, latest available version. Second try
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'); }"
register: install_plugins_result
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
when:
- r_plugins_install_latest_source
- "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr"
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
- name: Install R packages from github
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'); }"