Giter Site home page Giter Site logo

ansible-r's Introduction

r

CI Ansible Galaxy

Set up the latest version of R in Ubuntu systems.

Requirements

  • littler (will be installed)
  • bash (will not be installed)
  • software-properties-common (will be installed)
  • dirmngr (will be installed)
  • apt-transport-https (will be installed)

Variables

  • 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

  • r_bioclite_url: [default: https://bioconductor.org/biocLite.R]: The biocLite.R script URL for Bioconductor installs

  • r_install_dev: [default: false]: Whether or not install the r-base-dev package

  • r_install: [default: ['littler']]: Additional (apt) packages to install (e.g. r-recommended)

  • r_packages_lib: [default: /usr/local/lib/R/site-library]: The (default) library directory to install packages to

  • r_packages_repos: [default: "{{ r_cran_mirror }}"]: The (default) URL to install packages from

  • r_packages: [default: []]: (CRAN) Packages to install or remove

  • r_packages.{n}.name: [required]: The name of the package

  • r_packages.{n}.state: [optional, default: present]: The state of the package (e.g. updated, absent)

  • r_packages.{n}.type: [optional, default: cran]: The type of the package (e.g. bioconductor)

  • r_packages.{n}.lib: [optional, default: r_packages_lib]: The library directory to install the package to

  • r_packages.{n}.repos: [optional, default: r_packages_repos]: The URL to install the package from

  • r_environment: [default: {}]: Environment variables to set (during the install, update or delete packages tasks)

  • r_scripts_install_path:: [default: /usr/local/bin]: The path where to install the R script used to install, update and delete R package

  • r_scripts_install_owner: [default: root]: The owner of the R script to install, update and delete R package

  • r_scripts_install_group: [default: root]: The group of the R script to install, update and delete R package

Dependencies

None

Example(s)

Simple
---
- hosts: all
  roles:
    - oefenweb.r
Advanced
---
- hosts: all
  roles:
    - oefenweb.r
  vars:
    r_install_dev: true
    # apt packages
    r_install:
      - r-recommended
    # cran, bioconductor or github (R) packages
    r_packages:
      - name: dplyr
      - name: Biobase
        type: bioconductor
      - name: mangothecat/franc
        type: github

License

MIT

Author Information

Mischa ter Smitten

Feedback, bug-reports, requests, ...

Are welcome!

ansible-r's People

Contributors

fanchthesystem avatar kostyrev avatar lecorguille avatar mvdriel avatar pdacostaporto avatar tersmitten avatar thiagogomesverissimo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ansible-r's Issues

Updating packages via R-update-package is brocken

When updating packages via the role the 'R-update-package' results in this error:

failed: [... (item={'name': 'psych', 'type': 'cran', 'state': 'updated'}) => changed=false 
  ansible_loop_var: item
  cmd:
  - /usr/local/bin/R-update-package
  - psych
  - cran
  - /usr/local/lib/R/site-library
  delta: '0:00:01.354098'
  end: '2024-04-02 11:24:04.696954'
  item:
    name: psych
    state: updated
    type: cran
  msg: non-zero return code
  rc: 1
  start: '2024-04-02 11:24:03.342856'
  stderr: |-
    Error in download.file(url = paste0(repos, "/PACKAGES.rds"), destfile = dest,  :
      downloaded length 0 != reported length 0
    Calls: withCallingHandlers ... tryCatchList -> tryCatchOne -> doTryCatch -> download.file
    Execution halted
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

I tried to use the R update script directly resulting in the same problem:

./R-update-package psych cran /usr/local/lib/R/site-library 
Error in download.file(url = paste0(repos, "/PACKAGES.rds"), destfile = dest,  : 
  downloaded length 0 != reported length 0
Calls: withCallingHandlers ... tryCatchList -> tryCatchOne -> doTryCatch -> download.file
Execution halted

Can't add CRAN repository

My plays are failling when this role is trying to add the CRAN apt repository. The related error message shown by Ansible is:

TASK [oefenweb.r : repository | add cran-r] ************************************
task path: /etc/ansible/roles/oefenweb.r/tasks/repository.yml:11
<default> ESTABLISH LOCAL CONNECTION FOR USER: vagrant
<default> EXEC /bin/sh -c 'echo ~vagrant && sleep 0'
<default> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028 `" && echo ansible-tmp-1566962934.62-12908592978028="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/packaging/os/apt_repository.py
<default> PUT /home/vagrant/.ansible/tmp/ansible-local-19781b7Pbbg/tmpWCph8Z TO /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py
<default> EXEC /bin/sh -c 'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/ /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py && sleep 0'
<default> EXEC /bin/sh -c 'sudo -H -S -n  -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-qgxrmqhgbsprunpruwjdudgellnyzfpx ; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py'"'"' && sleep 0'
<default> EXEC /bin/sh -c 'rm -f -r /home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py", line 114, in <module>
    _ansiballz_main()
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py", line 106, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py", line 49, in invoke_module
    imp.load_module('__main__', mod, module, MOD_DESC)
  File "/tmp/ansible_apt_repository_payload_E7Qw0R/__main__.py", line 554, in <module>
  File "/tmp/ansible_apt_repository_payload_E7Qw0R/__main__.py", line 546, in main
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 559, in update
    raise FetchFailedException(e)
apt.cache.FetchFailedException: W:GPG error: https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9, E:The repository 'https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/ InRelease' is not signed.

failed: [default] (item={u'url': u'https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/', u'type': u'deb'}) => {
    "ansible_loop_var": "item", 
    "changed": false, 
    "item": {
        "type": "deb", 
        "url": "https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py\", line 114, in <module>\n    _ansiballz_main()\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py\", line 106, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/vagrant/.ansible/tmp/ansible-tmp-1566962934.62-12908592978028/AnsiballZ_apt_repository.py\", line 49, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_apt_repository_payload_E7Qw0R/__main__.py\", line 554, in <module>\n  File \"/tmp/ansible_apt_repository_payload_E7Qw0R/__main__.py\", line 546, in main\n  File \"/usr/lib/python2.7/dist-packages/apt/cache.py\", line 559, in update\n    raise FetchFailedException(e)\napt.cache.FetchFailedException: W:GPG error: https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9, E:The repository 'https://cran.rstudio.com/bin/linux/ubuntu bionic-cran35/ InRelease' is not signed.\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
    "rc": 1
}

Looks like a problem with the signing key of the repository.

I'm using Ubuntu 18.04 LTS (Bionic Beaver).

Add option to change status of apt packages

Currently, for any installed apt dependencies for this ansible role (r-base, r-base-dev) and any "additional" installs (littler by default), the state (defined by the ansible apt module) is hardcoded to be latest. This means to install any packages, you will also be forced to upgrade R to the latest version.

Ideally, I'd like to have an option to change the state variable for apt packages. to avoid upgrades (e.g. by setting it to present rather than latest.

I'm just working on being able to add this by adding new variables to defaults/main.yml. I'll let you know when it's ready and hope you'll accept a pull request again (or help add this functionality any other way you see fit).

Multiple R installs

Is it possible to support multiple R installations?

For example, say you have the following on your machine and want to choose which one you install packages to.
/opt/R/3.1.0
/opt/R/3.2.0

Can't install from github?

I'm trying to install stuff from github following the suggestions in issue #21 and the README, but it fails as follows.

My playbook (basically cut-and-paste of the the README):

---
- hosts: all
  roles:
    - tersmitten.r
  vars:
    r_packages:
      - name: mangothecat/franc
        type: github

The error:

< TASK [tersmitten.r : packages | install] >
 ------------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

task path: /etc/ansible/roles/tersmitten.r/tasks/packages.yml:24
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 89, in run
    items = self._get_loop_items()
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 202, in _get_loop_items
    loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=True, convert_bare=False)
  File "/usr/local/lib/python2.7/dist-packages/ansible/utils/listify.py", line 34, in listify_lookup_plugin_terms
    terms = templar.template(terms.strip(), convert_bare=convert_bare, fail_on_undefined=fail_on_undefined)
  File "/usr/local/lib/python2.7/dist-packages/ansible/template/__init__.py", line 437, in template
    disable_lookups=disable_lookups,
  File "/usr/local/lib/python2.7/dist-packages/ansible/template/__init__.py", line 659, in do_template
    res = j2_concat(rf)
  File "<template>", line 7, in root
  File "/usr/local/lib/python2.7/dist-packages/ansible/template/__init__.py", line 197, in resolve
    val = super(AnsibleContext, self).resolve(key)
  File "/usr/lib/python2.7/dist-packages/jinja2/runtime.py", line 153, in resolve
    return self.parent[key]
  File "/usr/local/lib/python2.7/dist-packages/ansible/template/vars.py", line 95, in __getitem__
    raise type(e)(to_native(variable) + ': ' + e.message)
TemplateRuntimeError: {{ r_packages | selectattr('type', 'defined') | selectattr('type', 'equalto', 'github') | map(attribute='name') | list | length > 0 }}: no test named 'equalto'

fatal: [149.165.156.235]: FAILED! => {
    "failed": true
}

MSG:

Unexpected failure during module execution.

 ____________
< PLAY RECAP >
 ------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

IP_NUMBER_EDITED            : ok=6    changed=0    unreachable=0    failed=1   

PS: this is tersmitten.r v1.4.1, last available from the galaxy

deprecation of result|version_compare

Thank you for the extremely helpful playbook. I'm getting this notification:

TASK [oefenweb.r : repository | add cran-r] ***************************************************************************************************************************************
[DEPRECATION WARNING]: Using tests as filters is deprecated. Instead of using `result|version_compare` use `result is version_compare`. This feature will be removed in version
2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

I think it's fussy about

r_version_35: "{{ ansible_distribution_version | version_compare('18.04', '>=') }}"
but I am very new to ansible, so I could be completely wrong.

Need to install dirmngr from apt

It is necessary install dirmngr package before run this role, error for debian 9 when the roles tries to add the gpg key:

"Warning: apt-key output should no
t be parsed (stdout is not a terminal)\ngpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory\ng

Install packages from GitHub

Not all packages are available on CRAN or BioConductor. Most of these are accessible from GitHub although there are other supposed sources such as BitBucket as well. I was thinking of adding an additional R package installation script and associated task and variable to install from these other sources.

littler

Hi again,

FYI, I've forked this repository again and made modifications to remove the littler dependency (and just use Rscript instead which is included with the standard R installation). I did this firstly because its one less dependency, but also because I noticed a weird issue with littler for bioconductor package installations. I can't quite figure out what's going on, but it looks like when running the script R-install-pacakge through littler, bioconductor attempted to install out of date packages if they'd been recently updated, but I don't see this issue with Rscript. Anyway, this solves an issue for me, and if I get chance I'll investigate. If your interested in incorporating this change I can issue a pull request.

Best,
Dan

Installing additional packages fails

Hello

Thanks for making this available - it's very useful.

However, I'm having trouble installing additional packages, with the following simple playbook:


---
- hosts: all
  sudo: true
  remote_user: centos
  vars:
    r_install_dev: True
    r_install: ['r-recommended']
    r_packages: ['dplyr']
  roles:
    - ansible-r

This is the error I see:

TASK: [ansible-r | packages | install] ****************************************
fatal: [frontend001] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute002] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute001] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute003] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute005] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute006] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute004] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute007] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute008] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute011] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute010] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute012] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute013] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute014] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute015] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute016] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute009] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute017] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute018] => One or more undefined variables: 'unicode object' has no attribute 'name'
fatal: [compute019] => One or more undefined variables: 'unicode object' has no attribute 'name'

FATAL: all hosts have already failed -- aborting

I tried adding the packages into the 'r_install' variable, but they didn't work there either:


---
- hosts: all
  sudo: true
  remote_user: centos
  vars:
    r_install_dev: True
    r_install: ['r-recommended', 'dplyr']
  roles:
    - ansible-r

producing the error:

failed: [compute019] => (item=r-recommended,dplyr) => {"failed": true, "item": "r-recommended,dplyr"}
msg: No package matching 'dplyr' is available

Can't install a role using Ansible Galaxy

- downloading role 'ansible-r', owned by
 [WARNING]: - ansible-r was NOT installed successfully: Role has no field named u'owner'

And it's not actually only a warning. The role was indeed not installed :]

Default cran_mirror, public-key don't work

These will..

- name: repository | add public key
  apt_key:
    id: FCAE2A0E115C3D8A
    keyserver: keyserver.ubuntu.com 
    state: present
  tags:
    - r-repository-public-key
- import_role:
    name: oefenweb.latest_r
  vars:
    r_install_dev: true
    r_cran_mirror: https://cloud.r-project.org
    r_version: "40"
    r_install:
      - r-recommended

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.