DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Automating Unix Security Across Hybrid Clouds
  • Cloud Automation Excellence: Terraform, Ansible, and Nomad for Enterprise Architecture
  • Streamlining Event Data in Event-Driven Ansible
  • Clean Up Event Data in Ansible Event-Driven Automation

Trending

  • Securing the AI Host: Spring AI MCP Server Communication With API Keys
  • Building a Spring AI Assistant With MCP Servers: A Step-by-Step Tutorial
  • Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
  • Zero-Downtime Deployments for Java Apps on Kubernetes
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. How to Install R Packages with Ansible

How to Install R Packages with Ansible

By 
Svend Vanderveken user avatar
Svend Vanderveken
·
Mar. 05, 14 · Interview
Likes (0)
Comment
Save
Tweet
Share
6.2K Views

Join the DZone community and get the full member experience.

Join For Free

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. 
R (programming language) Ansible (software)

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

Opinions expressed by DZone contributors are their own.

Related

  • Automating Unix Security Across Hybrid Clouds
  • Cloud Automation Excellence: Terraform, Ansible, and Nomad for Enterprise Architecture
  • Streamlining Event Data in Event-Driven Ansible
  • Clean Up Event Data in Ansible Event-Driven Automation

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook