83 lines
5.1 KiB
YAML
83 lines
5.1 KiB
YAML
---
|
|
- block:
|
|
- name: Configure the default CRAN mirror
|
|
template: src=Rprofile.site.j2 dest=/etc/R/Rprofile.site owner=root group=root mode=0444
|
|
tags: [ 'r_software', 'r_profile', 'r_pkg' ]
|
|
|
|
- name: Configure the JDK environment
|
|
shell: export JAVA_HOME={{ jdk_java_home }} ; export J2SDKDIR={{ jdk_java_home }} ; export J2REDIR={{ jdk_java_home }}/jre ; R CMD javareconf ; touch /etc/R/.java{{ jdk_default }}.env_conf
|
|
args:
|
|
creates: '/etc/R/.java{{ jdk_default }}.env_conf'
|
|
when:
|
|
- jdk_java_home is defined
|
|
- jdk_default is defined
|
|
tags: [ 'r_software', 'r_profile', 'r_pkg', 'r_java' ]
|
|
|
|
- name: Ensure that the R packages 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', 'r_plugins_version' ]
|
|
|
|
- block:
|
|
- name: Add the Ubuntu PPA '{{ r_cran_ubuntu_packages_ppa }}'
|
|
apt_repository: repo='{{ r_cran_ubuntu_packages_ppa }}' state=present update_cache=yes
|
|
|
|
- name: Install the R plugins from the Ubuntu PPA
|
|
apt: pkg={{ r_cran_ubuntu_packages }} state=present cache_valid_time=3600
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_deb_plugins' ]
|
|
|
|
- block:
|
|
- name: Install the R devtools package from CRAN
|
|
command: >
|
|
Rscript --slave --no-save --no-restore-history -e "if (! ('devtools' %in% installed.packages()[,'Package'])) { install.packages(pkgs='devtools', repos=c('https://cloud.r-project.org/')); print('Added'); } else { print('Already installed'); }"
|
|
register: install_devtools_result
|
|
failed_when: "install_devtools_result.rc != 0 or 'had non-zero exit status' in install_devtools_result.stderr"
|
|
changed_when: "'Added' in install_devtools_result.stdout"
|
|
|
|
- name: Install R packages from the cran sources repo or from an alternative repository, latest available version.
|
|
command: >
|
|
Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.name }}' %in% installed.packages()[,'Package'])) { require(devtools); require(methods) ; install.packages(pkgs='{{ item.name }}', repos=c('{{ item.repo | default ('https://cloud.r-project.org') }}/')); 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 | default([]) }}'
|
|
ignore_errors: True
|
|
|
|
- name: Get the R packages sources that need to be installed
|
|
get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }}
|
|
with_items: '{{ r_plugins_from_sources | default([]) }}'
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
|
|
|
|
- name: Install R packages from the cran sources, specific versions.
|
|
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 }}') { require(devtools); require(methods) ; 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 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.github_user }}/{{ item.plugin_name }}'); print('Added'); } else { print('Already Installed'); }"
|
|
register: install_github_plugins_result
|
|
failed_when: "install_github_plugins_result.rc != 0 or 'had non-zero exit status' in install_github_plugins_result.stderr"
|
|
changed_when: "'Added' in install_github_plugins_result.stdout"
|
|
with_items: '{{ r_plugins_from_github | default([]) }}'
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ]
|
|
ignore_errors: True
|
|
|
|
- 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 | default([]) }}'
|
|
when: r_plugins_list_to_remove is defined
|
|
|
|
when: r_cran_install_from_sources
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
|
|
|