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/ # 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 # 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 # This si the CRAN main repository, that contains the r-base-* packages
r_cran_ubuntu_repo_key: 'E298A3A825C0D65DFD57CBB651716619E084DAB9' r_cran_ubuntu_repo_key: 'E298A3A825C0D65DFD57CBB651716619E084DAB9'
r_cran_ubuntu_repo: 'deb https://cloud.r-project.org/bin/linux/ubuntu {{ ansible_distribution_release }}-cran40/' 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:ubuntugis/ppa'
- 'ppa:cran/libgit2' - '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_cran_mirror_site: https://cran.mirror.garr.it/mirrors/CRAN/
r_base_specific_version: False r_base_versioned: false
r_base_pkg_version: 4.1.0 r_base_pkg_version: 4.2.3-1.1804.0
r_packages_main_state: present
r_packages_state: '{{ r_packages_main_state }}'
r_sitelib_path: '/usr/local/lib/R/site-library' r_sitelib_path: '/usr/local/lib/R/site-library'
r_plugins_from_deb: True r_plugins_from_deb: true
r_packages_cleanup: False r_packages_cleanup: false
r_install_rprofile_site: True r_install_rprofile_site: true
# #
r_packages_updater: True r_packages_updater: true
r_package_updater_via_subversion: False 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_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_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_package_updater_git_repo: 'https://code-repo.d4science.org/gCubeSystem/r-packages-list'
r_packages_git_base_dir: /srv/r_updater r_packages_git_base_dir: /srv/r_updater
r_packages_files_prefix: '' r_packages_files_prefix: ''
r_packages_updater_also_upgrades_installed_packages: True r_packages_updater_also_upgrades_installed_packages: true
r_packages_updater_for_github_only: True r_packages_updater_for_github_only: true
# They need to be flat text files # They need to be flat text files
# 1 package per line # 1 package per line
#r_debian_packages_list_url #r_debian_packages_list_url
@ -67,6 +65,13 @@ r_base_packages_list:
- r-base-html - r-base-html
- r-mathlib - 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: r_distribution_required_packages:
- jags - jags
- git - git
@ -89,8 +94,12 @@ r_distribution_required_packages:
- libnetcdf-dev - libnetcdf-dev
- netcdf-bin - netcdf-bin
# Some packages must be put on hold # Some packages that must be put on hold
r_base_packages_hold_list: [] r_base_packages_hold_list: []
# - r-base-core
# - r-base-dev
# - r-base-html
# - r-mathlib
r_plugins_packages_list: [] r_plugins_packages_list: []
@ -215,7 +224,6 @@ r_cran_ubuntu_packages:
- r-cran-rpart - r-cran-rpart
- r-cran-rprojroot - r-cran-rprojroot
- r-cran-rsconnect - r-cran-rsconnect
- r-cran-rstan
- r-cran-rstanarm - r-cran-rstanarm
- r-cran-rstantools - r-cran-rstantools
- r-cran-rstudioapi - r-cran-rstudioapi

View File

@ -1,14 +1,11 @@
galaxy_info: galaxy_info:
author: Andrea Dell'Amico 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 company: ISTI-CNR
namespace: adellam
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning role_name: r_distribution
license: EUPL 1.2+ license: EUPL 1.2+
min_ansible_version: "2.14"
min_ansible_version: 2.8
# To view available platforms and versions (or releases), visit: # To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/ # https://galaxy.ansible.com/api/v1/platforms/
# #
@ -16,10 +13,8 @@ galaxy_info:
- name: Ubuntu - name: Ubuntu
versions: versions:
- bionic - bionic
- name: EL - focal
versions: - jammy
- 7
galaxy_tags: galaxy_tags:
- R - R
- CRAN - CRAN

View File

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