Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Install R Packages with Ansible

DZone's Guide to

How to Install R Packages with Ansible

· Big Data Zone
Free Resource

See how the beta release of Kubernetes on DC/OS 1.10 delivers the most robust platform for building & operating data-intensive, containerized apps. Register now for tech preview.

Here is a short snippet of Ansible playbook that installs R and any required packages to any nodes of the cluster:

- name: Making sure R is installed
apt: pkg=r-base state=installed

- name: adding a few R packages
command: /usr/bin/Rscript --slave --no-save --no-restore-history -e "if (! ('{{item}}' %in% installed.packages()[,'Package'])) install.packages(pkgs={{item}}, repos=c('http://www.freestatistics.org/cran/'))"
with_items:
- rjson
- rPython
- plyr
- psych
- reshape2

You should replace the repos with one chosen from the list of Cran mirrors.

Note that the command above installs each package only if it is not already present, but messes up the “changed” status of Ansible’s PLAY RECAP by incorrectly reporting a change per R package at every run.

Find more big data technical posts on my  blog

New Mesosphere DC/OS 1.10: Production-proven reliability, security & scalability for fast-data, modern apps. Register now for a live demo.

Topics:

Published at DZone with permission of Svend Vanderveken. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}