2015-05-28 11:32:57 +02:00
|
|
|
---
|
2015-11-27 20:06:45 +01:00
|
|
|
- name: Manage the cran repository key
|
|
|
|
apt_key: id=E084DAB9 keyserver=keyserver.ubuntu.com state={{ r_install_cran_repo }}
|
|
|
|
tags: [ 'r_software', 'r_repo' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-11-27 20:06:45 +01:00
|
|
|
- name: Manage the cran repository definition
|
|
|
|
apt_repository: repo='deb http://cran.rstudio.com/bin/linux/ubuntu {{ ansible_distribution_release }}/' state={{ r_install_cran_repo }} update_cache=yes
|
|
|
|
tags: [ 'r_software', 'r_repo' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-12-21 18:23:08 +01:00
|
|
|
- name: Remove the hold state from the debian R packages
|
|
|
|
shell: apt-mark unhold {{ item }}
|
|
|
|
with_items: r_base_packages_hold_list
|
|
|
|
when: r_base_packages_hold_list is defined
|
|
|
|
ignore_errors: True
|
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ]
|
|
|
|
|
|
|
|
- name: Install the R base packages.
|
|
|
|
apt: pkg={{ item }} state={{ r_packages_main_state }} force=yes
|
2015-05-28 11:32:57 +02:00
|
|
|
with_items: r_base_packages_list
|
2015-11-27 20:06:45 +01:00
|
|
|
tags: [ 'r_software', 'r_pkg' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-12-09 15:53:32 +01:00
|
|
|
- name: When we install specific R deb packages, put them on hold
|
|
|
|
shell: apt-mark hold {{ item }}
|
|
|
|
with_items: r_base_packages_hold_list
|
|
|
|
when: r_base_specific_version
|
|
|
|
ignore_errors: True
|
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ]
|
|
|
|
|
2015-11-27 20:06:45 +01:00
|
|
|
- name: Install the R additional modules from the deb repo
|
2015-12-21 18:23:08 +01:00
|
|
|
apt: pkg={{ item }} state={{ r_packages_state }} force=yes
|
2015-05-28 11:32:57 +02:00
|
|
|
with_items: r_plugins_packages_list
|
2015-11-27 20:06:45 +01:00
|
|
|
when: r_plugins_from_deb
|
|
|
|
tags: [ 'r_software', 'r_pkg' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2016-01-21 11:48:03 +01:00
|
|
|
- name: Configure the default CRAN mirror
|
|
|
|
template: src=Rprofile.site.j2 dest=/etc/R/Rprofile.site owner=root group=root mode=0444
|
2016-02-03 16:40:08 +01:00
|
|
|
when: r_install_cran_repo == 'present'
|
2016-01-21 11:48:03 +01:00
|
|
|
tags: [ 'r_software', 'r_profile', 'r_pkg' ]
|
|
|
|
|
2016-02-03 16:40:08 +01:00
|
|
|
- name: Install some packages needed by R packages when installed from source
|
2015-12-21 18:23:08 +01:00
|
|
|
apt: pkg={{ item }} state={{ r_packages_state }} update_cache=yes force=yes
|
2015-12-01 16:52:21 +01:00
|
|
|
with_items: r_distribution_required_packages
|
|
|
|
when: r_needs_additional_distro_pkgs
|
|
|
|
tags: [ 'r_software', 'r_pkg' ]
|
|
|
|
|
2015-12-03 17:16:44 +01:00
|
|
|
- name: Ensure that the R packages sources directory exists
|
2015-06-26 17:24:19 +02:00
|
|
|
file: dest={{ r_source_plugins_dest_dir }} state=directory owner=root group=root
|
|
|
|
when: r_plugins_from_sources is defined
|
2015-12-03 17:16:44 +01:00
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
|
2015-06-26 17:24:19 +02:00
|
|
|
|
2016-02-03 16:40:08 +01:00
|
|
|
- name: Install R packages from the cran sources repo, latest available version
|
|
|
|
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
|
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
|
|
|
|
|
2015-12-03 17:16:44 +01:00
|
|
|
- name: Get the R packages sources that need to be installed
|
2015-06-26 17:24:19 +02:00
|
|
|
get_url: url={{ item.url }} dest={{ r_source_plugins_dest_dir }}
|
|
|
|
with_items: r_plugins_from_sources
|
2016-02-03 16:40:08 +01:00
|
|
|
when: r_plugins_install_specific_source
|
2015-12-03 17:16:44 +01:00
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
|
2015-06-26 17:24:19 +02:00
|
|
|
|
2015-12-03 17:16:44 +01:00
|
|
|
- name: Install R packages from the cran sources, specific versions
|
2015-06-26 17:24:19 +02:00
|
|
|
command: >
|
2015-12-03 17:16:44 +01:00
|
|
|
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'); }"
|
2015-06-26 17:24:19 +02:00
|
|
|
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"
|
2015-12-03 17:16:44 +01:00
|
|
|
changed_when: '"Added" in install_s_plugins_result.stdout'
|
2015-06-26 17:24:19 +02:00
|
|
|
with_items: r_plugins_from_sources
|
2015-11-27 20:06:45 +01:00
|
|
|
when: r_plugins_install_specific_source
|
2015-12-16 14:14:44 +01:00
|
|
|
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
|
|
|
|
when: r_plugins_install_specific_source
|
2015-12-03 17:16:44 +01:00
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_version' ]
|
2015-06-26 17:24:19 +02:00
|
|
|
|
2015-12-03 17:16:44 +01:00
|
|
|
- name: Install R packages from github
|
2015-11-27 20:06:45 +01:00
|
|
|
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'); }"
|
2015-12-03 17:16:44 +01:00
|
|
|
register: install_github_plugins_result
|
2015-12-04 13:07:31 +01:00
|
|
|
failed_when: "install_github_plugins_result.rc != 0 or 'had non-zero exit status' in install_github_plugins_result.stderr"
|
2015-12-03 17:16:44 +01:00
|
|
|
changed_when: "'Added' in install_github_plugins_result.stdout"
|
2015-11-27 20:06:45 +01:00
|
|
|
with_items: r_plugins_from_github
|
|
|
|
when: r_plugins_from_github is defined
|
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-12-03 17:16:44 +01:00
|
|
|
- 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
|
|
|
|
when: r_plugins_list_to_remove is defined
|
|
|
|
tags: [ 'r_software', 'r_pkg', 'r_plugins' ]
|