Puppet Class: r_lang

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

Overview

SPDX-License-Identifier: Apache-2.0

Class: r_lang

Class containing stuff for installing R and its packages from different sources:

  • r_lang::cran for installing from Comprehensive R Archive Network (CRAN)

  • r_lang::git for installing from any Git repository (e.g. Gerrit)

  • r_lang::github for installing from a GitHub-hosted repository

Also provides a utility script for updating library of installed R packages.

Heads-up that by default r_lang::git and r_lang::github are technically not available because those require the R package 'devtools' which is not installed by default and cannot be installed because its dependencies are not installed unless the `$devtools$` parameter is set to `true`.

Parameters:

  • devtools (Any) (defaults to: false)


16
17
18
19
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'modules/r_lang/manifests/init.pp', line 16

class r_lang (
    $devtools = false
) {

    $essentials = [
        'r-base', 'r-base-dev', 'r-recommended',
        # To get higher performance for linear algebra operations
        'libopenblas-dev'
    ]
    ensure_packages($essentials)

    file { '/usr/local/lib/R/site-library':
        ensure => 'directory',
        owner  => 'root',
        group  => 'root',
        mode   => '0775',
    }

    # R script for updating any particular installed R package:
    file { '/etc/R/update-library.R':
        ensure => 'present',
        owner  => 'root',
        group  => 'root',
        mode   => '0644',
        source => 'puppet:///modules/r_lang/update-library.R',
    }

    if $devtools {
        $devtools_essentials = [
            'git',                  # for git2r
            'libxml2-dev',          # for xml2
            'libssl-dev',           # for openssl
            'libcurl4-openssl-dev', # for curl
            'libssh2-1-dev'         # for git2r
        ]
        ensure_packages($devtools_essentials)

        r_lang::cran { 'openssl':
            require => Package['libssl-dev'],
        }

        $r_packages = [
            'xml2',
            'curl',
            'devtools',
        ]
        r_lang::cran { $r_packages:
            require => [
                R_lang::Cran['openssl']
            ],
        }
    }

}