Using Ansible to Install R and Workbench


Using Ansible to Install R and Workbench on RedHat/ Centos/ Rocky Linux Servers

IMPORTANT: Ansible installation and support is outside the scope of Posit Support. The following instructions are for guidance only, and they should be modified based on your OS/Linux environment and your specific needs. For more information on Ansible, see the resource here;

Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, installations, and application deployment. 

Benefits of using Ansible:

  • Free: Ansible is an open-source tool.
  • Simple setup: No special coding skills are necessary to use Ansible’s playbooks.
  • Powerful: Ansible lets you model even highly complex IT workflows. 
  • Agentless: You don’t need to install any other software or firewall ports on the client systems you want to automate. 
  • Efficient: Because you don’t need to install any extra software, there’s more room for application resources on your server.


  • Install, and upgrade Posit products
  • Start and stop services.
  • Perform a wide variety of configuration tasks.
  • Implement a security policy.

Using Ansible to install WorkBench


  • RPM-based Linux Server from Ansible will be run ("the Ansible server")
  • Inventory file of the target servers on the Ansible server. 
  • Download and install EPEL repository
  • Install Ansible packages from the EPEL repository
  • Create a playbook to deploy the product, typically titled workbench.yml

Follow the steps below to install Ansible on RHEL/CentOS 8

Step 1:

Update /etc/hosts file with the hostname and IP details of your Ansible server and managed hosts in your setup.

# cat /etc/hosts localhost localhost.localdomain localhost4 localhost4.localdomain4   ansible   host1   host2

Step 2

Download and install the EPEL repository using your package manager of choice (RPM/YUM/DNF);

 # rpm -Uvh

# dnf -y install epel-release

Step 3:

Install Ansible:

# dnf -y install ansible


Step 4:

Validate that ansible is installed. 

# ansible -–version

************** Done! Ansible is installed. *******************

Next, create an inventory file with the hosts you would like to deploy the product on.


# touch myhosts.txt && vi myhosts.txt

After that, create a playbook; you can use the template below as an example:

Note: The example below is based on the Rocky Linux distribution of Linux; please customize your code to fit your Linux distribution and environment.

- name: update server
    name: '*'
    state: latest

- name: Install EPEL Repo
    state: latest

- name: Install dnf-plugins-core
    name: dnf-plugins-core
    state: present

# use this parameter for Rocky linux and comment out the next codeReady parameter.
#- name: Enable powertools
#  community.general.ini_file:
#    path: "/etc/yum.repos.d/Rocky-PowerTools.repo"
#    section: powertools
#    option: enabled
#    value: "1"
#    mode: "0644"

#  notify:
#    - Yum update cache

- name: Enable the CodeReady Linux Builder repository
  command: sudo subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms

- name: Export R Version

  shell: export R_VERSION=4.2.2

- name: Download R
  shell: curl -O

- name: Install R
  shell: sudo yum install R-4.2.2-1-1.x86_64.rpm -y

- name: Create a symlink to R
  shell: sudo ln -snf /opt/R/4.2.2/bin/R /usr/local/bin/R

- name: Create a symlink to RScripts
  shell: sudo ln -snf /opt/R/4.2.2/bin/Rscript /usr/local/bin/Rscript

- name: Download WorkBench_2022-12 for RHEL8
  shell: curl -O

- name: Install WorkBench
  shell: sudo yum install rstudio-workbench-rhel-2022.12.0-353.pro20-x86_64.rpm -y

- name: Restart rstudio-service
    name: rstudio-server
    state: restarted

For more information about ansible, see here