How to Install R Packages with Ansible
Join the DZone community and get the full member experience.
Join For FreeHere 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.Published at DZone with permission of Svend Vanderveken. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments