ansible-roles/R/tasks/main.yml

78 lines
2.9 KiB
YAML

---
- name: Install the cran repository key
apt_key: id=E084DAB9 keyserver=keyserver.ubuntu.com state=present
register: update_apt_cache
when: r_install_cran_repo
tags:
- r_software
- r_repo
- name: Install the cran repository definition
apt_repository: repo='deb http://cran.rstudio.com/bin/linux/ubuntu {{ ansible_distribution_release }}/' state=present
register: update_apt_cache
when: r_install_cran_repo
tags:
- r_software
- r_repo
- name: Install the cran repository definition
apt_repository: repo='deb {{ r_cran_mirror_site }}/bin/linux/ubuntu {{ ansible_distribution_release }}/' state=absent
register: update_apt_cache
when: not r_install_cran_repo
tags:
- r_software
- r_repo
- name: Update the apt cache if needed
apt: update_cache=yes
when: ( update_apt_cache | changed )
tags:
- r_software
- r_repo
- name: Install the R base packages
apt: pkg={{ item }} state={{ r_packages_state }}
with_items: r_base_packages_list
tags:
- r_software
- r_pkg
- name: Install the R plugins from the ubuntu repo
apt: pkg={{ item }} state={{ r_packages_state }}
with_items: r_plugins_packages_list
tags:
- 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'); }"
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
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]