Skip to content

Commit

Permalink
Allow R4 install (#49)
Browse files Browse the repository at this point in the history
* enable install of R 4.0

* add a warning about r_version_35

* update readme about r_version and r_version_35

* Allow R4 install

* Fixes

Co-authored-by: Fanch <[email protected]>
  • Loading branch information
tersmitten and FanchTheSystem authored Jan 19, 2021
1 parent 327e0a3 commit 7b5e07f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Set up the latest version of R in Ubuntu systems.

#### Variables

* `r_version_35`: [default: `false`, for `Ubuntu >= 18.04` always `true`]: Whether or not to install R 3.5+
* `r_version`: [default: `34`, `35` for `Ubuntu >= 18.04`, `40` for `Ubuntu >= 20.04`]: Version to install

* `r_cran_mirror`: [default: `https://cran.rstudio.com/`]: Your favorite [CRAN mirror](https://cran.r-project.org/mirrors.html)
* `r_bioclite_url`: [default: `https://bioconductor.org/biocLite.R`]: The `biocLite.R` script URL for [Bioconductor](https://bioconductor.org/) installs
Expand Down
14 changes: 7 additions & 7 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ role = File.basename(File.expand_path(File.dirname(__FILE__)))

boxes = [
{
:name => "ubuntu-1404",
:box => "bento/ubuntu-14.04",
:name => "ubuntu-1604",
:box => "bento/ubuntu-16.04",
:ip => '10.0.0.12',
:cpu => "50",
:ram => "256"
},
{
:name => "ubuntu-1604",
:box => "bento/ubuntu-16.04",
:name => "ubuntu-1804",
:box => "bento/ubuntu-18.04",
:ip => '10.0.0.13',
:cpu => "50",
:ram => "256"
:ram => "384"
},
{
:name => "ubuntu-1804",
:box => "bento/ubuntu-18.04",
:name => "ubuntu-2004",
:box => "bento/ubuntu-20.04",
:ip => '10.0.0.14',
:cpu => "50",
:ram => "384"
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# defaults file for r
---
r_version_35: "{{ (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('18.04', '>=')) }}"
r_version: "{{ '40' if ansible_distribution_version is version('20.04', '>=') else '35' if ansible_distribution_version is version('18.04', '>=') else '34' }}"

r_cran_mirror: https://cran.rstudio.com/
r_bioclite_url: https://bioconductor.org/biocLite.R
Expand Down
20 changes: 10 additions & 10 deletions tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
register: _r_install_package
changed_when: "_r_install_package.stdout_lines[-1] is defined and _r_install_package.stdout_lines[-1] == 'changed'"
with_items:
"{{
r_packages_from_github | ternary (r_preset_package_remotes, []) +
r_packages_from_bioconductor | ternary ((r_version_35 | ternary (r_preset_package_bioconductor, [])), []) +
r_packages
}}"
"{{
r_packages_from_github | ternary (r_preset_package_remotes, []) +
r_packages_from_bioconductor | ternary ((r_version is version('35', '>=') | ternary (r_preset_package_bioconductor, [])), []) +
r_packages
}}"
when: item.state is undefined or item.state == 'present'
tags:
- r-packages-install
Expand Down Expand Up @@ -67,11 +67,11 @@
register: _r_update_package
changed_when: "_r_update_package.stdout_lines[-1] is defined and _r_update_package.stdout_lines[-1] == 'changed'"
with_items:
"{{
r_packages_from_github | ternary (r_preset_package_remotes, []) +
r_packages_from_bioconductor | ternary ((r_version_35 | ternary (r_preset_package_bioconductor, [])), []) +
r_packages
}}"
"{{
r_packages_from_github | ternary (r_preset_package_remotes, []) +
r_packages_from_bioconductor | ternary ((r_version is version('35', '>=') | ternary (r_preset_package_bioconductor, [])), []) +
r_packages
}}"
when:
- item.state is defined
- item.state == 'updated'
Expand Down
2 changes: 1 addition & 1 deletion templates/usr/local/bin/R-install-package.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (!(package %in% installed.packages(lib.loc = lib)[, 'Package'])) {
}, warning = stop);
} else if (type == 'bioconductor') {
withCallingHandlers({
{% if r_version_35 %}
{% if r_version is version('35', '>=') %}
BiocManager::install(package, lib = lib, update = FALSE)
{% else %}
source('{{ r_bioclite_url }}')
Expand Down
2 changes: 1 addition & 1 deletion templates/usr/local/bin/R-update-package.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (package %in% old.packages(lib.loc = lib, repos = repos)[, 'Package'] & type

if (type == 'bioconductor') {
withCallingHandlers({
{% if r_version_35 %}
{% if r_version is version('35', '>=') %}
BiocManager::install(package, lib = lib, update = FALSE)
{% else %}
source('{{ r_bioclite_url }}')
Expand Down
3 changes: 2 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# vars file for r
---
r_repository_suffix: "{{ '-cran' + r_version if r_version is version('35', '>=') else '' }}"
r_repository:
- type: deb
url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_version_35 | ternary('-cran35', '') }}/"
url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_repository_suffix }}/"

r_dependencies_pre:
- apt-transport-https
Expand Down

0 comments on commit 7b5e07f

Please sign in to comment.