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

Effortlessly power IoT, predictive analytics, and machine learning applications with an elastic, resilient data infrastructure. Learn how with Mesosphere DC/OS.

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

Learn to design and build better data-rich applications with this free eBook from O’Reilly. Brought to you by Mesosphere DC/OS.

Topics:

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

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}