forked from ISTI-ansible-roles/ansible-roles
library/isti_vars/r-packages.yml: Add some R packages.
library/roles/R/tasks/r-installation.yml: Add some checks.
This commit is contained in:
parent
b446c20fb5
commit
465eeb8fe7
|
@ -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' ]
|
||||
|
||||
|
|
Loading…
Reference in New Issue