Defined Type: r_lang::bioc

Defined in:
modules/r_lang/manifests/bioc.pp

Overview

Define: r_lang::bioc

Facilitates installation of R packages from bioconductor.org

Parameters

timeout

default 300 (seconds) but may need to be larger for R packages with a lot of dependencies that take time to build (e.g. tidyverse)

ensure

default 'present' but also accepts 'absent' hoping to support 'latest' eventually

library

default '/usr/local/lib/R/site-library', used for specifying the path of the library for installing the R package

Parameters:

  • timeout (Any) (defaults to: 300)
  • ensure (Any) (defaults to: 'present')
  • library (Any) (defaults to: '/usr/local/lib/R/site-library')


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'modules/r_lang/manifests/bioc.pp', line 20

define r_lang::bioc (
    $timeout = 300,
    $ensure = 'present',
    $library = '/usr/local/lib/R/site-library'
) {
    $pkg_path = "${library}/${title}"
    case $ensure {
        'absent': {
            # Since r_lang can be used on machines that don't have shiny_server,
            # we only want a package removal to restart the Shiny Server service
            # if the service actually exists:
            $remove_notify = defined(Service['shiny-server']) ? {
                true    => Service['shiny-server'],
                default => Undef,
            }
            exec { "remove-${title}":
                command => "/usr/bin/R -e \"remove.packages('${title}', lib = '${library}')\"",
                notify  => $remove_notify,
                onlyif  => "test -d ${pkg_path}",
            }
        }
        default: {
            exec { "package-${title}":
                require => [
                    File['/etc/R/biocLite.R']
                ],
                timeout => $timeout,
                command => "/usr/bin/R -e \"source('/etc/R/biocLite.R'); biocLite('${title}', lib = '${library}', suppressUpdates = TRUE, ask = FALSE)\"",
                creates => $pkg_path,
            }
        }
    }
}