<figure><img src="image_1.png" /></figure>

HAL
open science

VMR PACKAGE MANAGE VIRTUAL MACHINES
FOR/WITH R

Jean-François Rey

► To cite this version:

Jean-François Rey. VMR PACKAGE MANAGE VIRTUAL MACHINES FOR/WITH R. Rencontres R 2023, Jun 2023, Avignon, France. 2023. [hal-04196129](https://hal.inrae.fr/hal-04196129)

HAL Id: hal-04196129

https://hal.inrae.fr/hal-04196129

Submitted on 5 Sep 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

Public Domain
<figure><img src="image_2.png" /></figure>

# {VMR} PACKAGE
## MANAGE VIRTUAL MACHINES FOR/WITH R

<figure><img src="image_3.png" /></figure>

## PRÉSENTATION

**{VMR} R package** allow to **manage, provision** and **use** a Virtual Machine preconfigured for **R**.

Develop, make tests and build a package in a clean environment with a choice of different providers and OS improve the quality, the productivity, the reproductibility and the share of R productions.

Here we present, the possibilities offered by **{VMR}** to manipulate a **VM** using **R** code.

How these VMs are built using several pipelines over GitLab CI/CD and stored in the Vagrant cloud repository.

<figure><img src="image_4.png" /></figure>

<figure><img src="image_5.png" /></figure>

## {VMR}

**=> R package to use Vagrant CLI tool**

<figure><img src="image_6.png" /></figure>

* Vagrant have to be installed (>=2.2.10)

* Implement most of the commands

* Currently works for VirtualBox (≥ 6.1.14) provider

* vmrList() : List boxes (OS, R Versions, providers)

* vmrCreate(...) : Create a VMR environment

* vmrInitEnv(...) : Initialyse environment and download VM

* vmrStart(), vmrSuspend(), vmrResume(), vmrStop()

<figure><img src="image_7.png" /></figure>

## TOOLS

<figure><img src="image_8.png" /></figure>

HashiCorp

**Vagrant**

**Vagrant** is a tool for building and managing virtual machine environments in a single workflow and focus on automation.
Open Source MIT License – HashiCorp

Box =~ a Virtual Machine
Provider =~ virtualization product

**VirtualBox** is a virtualization tool
Open Source GPL-v2 – ORACLE

Runs on and supports multiple OS

<figure><img src="image_9.png" /></figure>

<figure><img src="image_10.png" /></figure>

## BOXES AND VM CREATIONS

<figure><img src="image_11.png" /></figure>

### GitLab

<figure><img src="image_12.png" /></figure>

www

https://gitlab.com/rstuff/vms

<figure><img src="image_13.png" /></figure>

HashiCorp

**Packer**

CREATE
+
PROVISION

<figure><img src="image_14.png" /></figure>

STORE

<figure><img src="image_15.png" /></figure>

VAGRANT
CLOUD

LIST

DOWNLOAD

<figure><img src="image_16.png" /></figure>

<figure><img src="image_17.png" /></figure>

<figure><img src="image_18.png" /></figure>

VM
R version
OS

Repositories use CI/CD
to create, provision and store boxes

For Windows, Linux, Mac OS

<figure><img src="image_19.png" /></figure>

<figure><img src="image_20.png" /></figure>

<figure><img src="image_21.png" /></figure>

<figure><img src="image_22.png" /></figure>

ANSIBLE

<figure><img src="image_23.png" /></figure>

https://app.vagrantup.com/VMR/

<figure><img src="image_24.png" /></figure>

## WORK WITH VMR

<figure><img src="image_25.png" /></figure>

<figure><img src="image_26.png" /></figure>

<figure><img src="image_27.png" /></figure>

### VirtualBox Options

**Mount Local Directory**
vmrMountDir(vmr_env, src, dest)

opt ← virtualboxOptions()

opt$name ← "useR"

opt$gui ← TRUE

opt$modifyvm$memory ← 4096

opt$modifyvm$cpu ← 4

**Guest informations**

vmrInfo()

### R in the VM

vmrExec('print("Hello UseR!")')

vmrProvision(cmd="Rscript -e mycode.R", elt="mycode.R")

vmrInstallPackages pkg = c("vmr")

### R Packages

vmrPackageCheck()

vmrPackageTest()

vmrPackageBuild()

<figure><img src="image_28.png" /></figure>

## GITLAB-RUNNER

**Use a VM as a GitLab Runner for CI/CD**

VirtualboxGitlabRunner(...) → CLI to register the VM as Runner

<figure><img src="image_29.png" /></figure>

<figure><img src="image_30.png" /></figure>

## Automate Tests, Check and Build

<figure><img src="image_31.png" /></figure>

## PERSPECTIVES

* Add new providers : Docker, VMware, ...

* Find storage capacity for boxes

* Improve boxes provisioning

* Add new OS ( Fedora, Solaris, ...)

* Improve integration for R Dev (simplify remote R, execution interactive shell, Rstudio addins)

<figure><img src="image_32.png" /></figure>

Centre
Provence-Alpes-Côte d'Azur -
Avignon

<figure><img src="image_33.png" /></figure>

## Jean-François Rey¹

¹ BioStatistique et Processus Spatiaux (BioSP), INRAE Avignon, France

<figure><img src="image_34.png" /></figure>

Jeff.biosp.org

<figure><img src="image_35.png" /></figure>

jean-francois.rey@inrae.fr

<figure><img src="image_36.png" /></figure>

@jfrey_official

Biostatistique

<figure><img src="image_37.png" /></figure>

& Processus Spatiaux