New way to stick to a specific version of R.

This commit is contained in:
Andrea Dell'Amico 2023-12-07 15:36:07 +01:00
parent 4aad1fb00e
commit 61b064a5ab
Signed by: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
3 changed files with 128 additions and 109 deletions

View File

@ -10,7 +10,7 @@
# The install/remove script has been taken from here: http://adamj.eu/tech/2014/07/19/installing-and-removing-r-packages-with-ansible/
#
# Set to True if you want install from the CRAN deb repository
r_install_cran_repo: False
r_install_cran_repo: false
# This si the CRAN main repository, that contains the r-base-* packages
r_cran_ubuntu_repo_key: 'E298A3A825C0D65DFD57CBB651716619E084DAB9'
r_cran_ubuntu_repo: 'deb https://cloud.r-project.org/bin/linux/ubuntu {{ ansible_distribution_release }}-cran40/'
@ -25,27 +25,25 @@ r_apt_additional_repos:
- 'ppa:ubuntugis/ppa'
- 'ppa:cran/libgit2'
r_cran_set_default_mirror: True
r_cran_set_default_mirror: true
r_cran_mirror_site: https://cran.mirror.garr.it/mirrors/CRAN/
r_base_specific_version: False
r_base_pkg_version: 4.1.0
r_packages_main_state: present
r_packages_state: '{{ r_packages_main_state }}'
r_base_versioned: false
r_base_pkg_version: 4.2.3-1.1804.0
r_sitelib_path: '/usr/local/lib/R/site-library'
r_plugins_from_deb: True
r_packages_cleanup: False
r_install_rprofile_site: True
r_plugins_from_deb: true
r_packages_cleanup: false
r_install_rprofile_site: true
#
r_packages_updater: True
r_package_updater_via_subversion: False
r_packages_updater: true
r_package_updater_via_subversion: false
r_package_updater_subversion_repo: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RPackagesManagement/
r_packages_svn_base_dir: /srv/r_updater
r_package_updater_via_git: True
r_package_updater_via_git: true
r_package_updater_git_repo: 'https://code-repo.d4science.org/gCubeSystem/r-packages-list'
r_packages_git_base_dir: /srv/r_updater
r_packages_files_prefix: ''
r_packages_updater_also_upgrades_installed_packages: True
r_packages_updater_for_github_only: True
r_packages_updater_also_upgrades_installed_packages: true
r_packages_updater_for_github_only: true
# They need to be flat text files
# 1 package per line
#r_debian_packages_list_url
@ -67,6 +65,13 @@ r_base_packages_list:
- r-base-html
- r-mathlib
r_base_versioned_packages_list:
# - r-base=4.2.3-1.1804.0 # r-recommended is a requirement and it cannot be installed
- "r-base-core={{ r_base_pkg_version }}"
- "r-base-dev={{ r_base_pkg_version }}"
- "r-base-html={{ r_base_pkg_version }}"
- "r-mathlib={{ r_base_pkg_version }}"
r_distribution_required_packages:
- jags
- git
@ -89,8 +94,12 @@ r_distribution_required_packages:
- libnetcdf-dev
- netcdf-bin
# Some packages must be put on hold
# Some packages that must be put on hold
r_base_packages_hold_list: []
# - r-base-core
# - r-base-dev
# - r-base-html
# - r-mathlib
r_plugins_packages_list: []
@ -215,7 +224,6 @@ r_cran_ubuntu_packages:
- r-cran-rpart
- r-cran-rprojroot
- r-cran-rsconnect
- r-cran-rstan
- r-cran-rstanarm
- r-cran-rstantools
- r-cran-rstudioapi

View File

@ -1,14 +1,11 @@
galaxy_info:
author: Andrea Dell'Amico
description: Systems Architect
description: ansible role that installs R and a list of R packages from CRAN or any other repositories
company: ISTI-CNR
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning
namespace: adellam
role_name: r_distribution
license: EUPL 1.2+
min_ansible_version: 2.8
min_ansible_version: "2.14"
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
@ -16,10 +13,8 @@ galaxy_info:
- name: Ubuntu
versions:
- bionic
- name: EL
versions:
- 7
- focal
- jammy
galaxy_tags:
- R
- CRAN

View File

@ -1,101 +1,117 @@
---
- block:
- name: Add the CRAN repository (Ubuntu Trusty PPA)
apt_repository:
repo: '{{ r_cran_ubuntu_packages_ppa_trusty }}'
state: present
update_cache: yes
- name: Install some additional repositories. They provide dependencies for some R packages. Ubuntu Bionic
apt_repository:
repo: '{{ item }}'
state: present
update_cache: yes
loop: '{{ r_apt_additional_repos_trusty }}'
- name: r-installation-deb | Manage the CRAN PPA
when:
- r_install_cran_repo
- ansible_distribution_version is version_compare('14.04', '==')
tags: [ 'r_software', 'r_repo' ]
tags: ['r_software', 'r_repo']
block:
- name: r-installation-deb | Add the CRAN repository (Ubuntu Trusty PPA)
ansible.builtin.apt_repository:
repo: '{{ r_cran_ubuntu_packages_ppa_trusty }}'
state: present
update_cache: true
- block:
- name: Install the CRAN main R repository key
apt_key:
keyserver: 'keyserver.ubuntu.com'
id: '{{ r_cran_ubuntu_repo_key }}'
- name: Install the CRAN main R repository
apt_repository:
repo: '{{ r_cran_ubuntu_repo }}'
state: present
update_cache: yes
- name: Add the CRAN repository (Ubuntu Bionic PPA)
apt_repository:
repo: '{{ r_cran_ubuntu_packages_ppa }}'
state: present
update_cache: yes
- name: Install some additional repositories. They provide dependencies for some R packages. Ubuntu Bionic
apt_repository:
repo: '{{ item }}'
state: present
update_cache: yes
loop: '{{ r_apt_additional_repos }}'
- name: r-installation-deb | Install some additional repositories. They provide dependencies for some R packages. Ubuntu Bionic
ansible.builtin.apt_repository:
repo: '{{ item }}'
state: present
update_cache: true
loop: '{{ r_apt_additional_repos_trusty }}'
- name: r-installation-deb | Manage the CRAN PPA on Ubuntu >= 16.04
when:
- r_install_cran_repo
- ansible_distribution_version is version_compare('18.04', '>=')
tags: [ 'r_software', 'r_repo' ]
tags: ['r_software', 'r_repo']
block:
- name: r-installation-deb | Install the CRAN main R repository key
ansible.builtin.apt_key:
keyserver: 'keyserver.ubuntu.com'
id: '{{ r_cran_ubuntu_repo_key }}'
- block:
- name: Remove the CRAN repositores
apt_repository:
repo: '{{ r_cran_ubuntu_packages_ppa }}'
state: absent
update_cache: yes
- name: r-installation-deb | Install the CRAN main R repository
ansible.builtin.apt_repository:
repo: '{{ r_cran_ubuntu_repo }}'
state: present
update_cache: true
- name: Remove the CRAN main repository
apt_repository:
repo: '{{ r_cran_ubuntu_repo }}'
state: absent
update_cache: yes
- name: r-installation-deb | Add the CRAN repository (Ubuntu Bionic PPA)
ansible.builtin.apt_repository:
repo: '{{ r_cran_ubuntu_packages_ppa }}'
state: present
update_cache: true
- name: r-installation-deb | Install some additional repositories. They provide dependencies for some R packages. Ubuntu Bionic
ansible.builtin.apt_repository:
repo: '{{ item }}'
state: present
update_cache: true
loop: '{{ r_apt_additional_repos }}'
- name: r-installation-deb | Remove the CRAN repo when we do not want it
when: not r_install_cran_repo
tags: [ 'r_software', 'r_repo' ]
tags: ['r_software', 'r_repo']
block:
- name: r-installation-deb | Remove the CRAN repositores
ansible.builtin.apt_repository:
repo: '{{ r_cran_ubuntu_packages_ppa }}'
state: absent
update_cache: true
- block:
- name: Remove the hold state from the debian R packages
shell: apt-mark unhold {{ item }}
with_items: '{{ r_base_packages_hold_list | default([]) }}'
when: r_base_packages_hold_list is defined
ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ]
- name: r-installation-deb | Remove the CRAN main repository
ansible.builtin.apt_repository:
repo: '{{ r_cran_ubuntu_repo }}'
state: absent
update_cache: true
- name: Install the R base packages.
apt:
pkg: '{{ r_base_packages_list }}'
state: '{{ r_packages_main_state }}'
cache_valid_time: 3600
- name: When we install specific R deb packages, put them on hold
shell: apt-mark hold {{ item }}
with_items: '{{ r_base_packages_hold_list| default([]) }}'
when: r_base_specific_version
ignore_errors: True
tags: [ 'r_software', 'r_pkg', 'r_pkg_hold' ]
- name: r-installation-deb | Install the R base packages from the repository, unversioned
when: not r_base_versioned
tags: ['r_software', 'r_pkg', r_unversioned_packages]
block:
- name: r-installation-deb | Remove the hold state from the debian R packages
ansible.builtin.dpkg_selections:
name: "{{ item }}"
selection: install
with_items: '{{ r_base_packages_hold_list | default([]) }}'
tags: ['r_software', 'r_pkg', 'r_pkg_hold']
- name: Install the R additional modules from the deb repo
apt:
pkg: '{{ r_plugins_packages_list }}'
state: '{{ r_packages_state }}'
cache_valid_time: 3600
- name: r-installation-deb | Install the R base packages.
ansible.builtin.apt:
pkg: '{{ r_base_packages_list }}'
state: present
cache_valid_time: 3600
- name: Install some packages needed by R packages when installed from source
apt:
pkg: '{{ r_distribution_required_packages }}'
state: '{{ r_packages_state }}'
cache_valid_time: 3600
tags: [ 'r_software', 'r_pkg', 'r_deps' ]
- name: r-installation-deb | Install the R base packages from the repository, versioned. Put them on hold
when: r_base_versioned
tags: ['r_software', 'r_pkg', r_unversioned_packages]
block:
- name: r-installation-deb | Install the R base packages, versioned.
ansible.builtin.apt:
pkg: '{{ r_base_versioned_packages_list }}'
state: present
cache_valid_time: 3600
tags: [ 'r_software', 'r_pkg' ]
- name: r-installation-deb | Put some packages into hold state
ansible.builtin.dpkg_selections:
name: "{{ item }}"
selection: hold
with_items: '{{ r_base_packages_hold_list | default([]) }}'
tags: ['r_software', 'r_pkg', 'r_pkg_hold']
- name: r-installation-deb | Manage additional packages
tags: ['r_software', 'r_pkg', r_unversioned_packages]
block:
- name: r-installation-deb | Install some additional R modules from the deb repo
ansible.builtin.apt:
pkg: '{{ r_plugins_packages_list }}'
state: '{{ r_packages_state }}'
cache_valid_time: 3600
- name: r-installation-deb | Install some packages required by R packages when installed from source
ansible.builtin.apt:
pkg: '{{ r_distribution_required_packages }}'
state: '{{ r_packages_state }}'
cache_valid_time: 3600
tags: ['r_software', 'r_pkg', 'r_deps']