diff --git a/R/defaults/main.yml b/R/defaults/main.yml index be54b86e..03804209 100644 --- a/R/defaults/main.yml +++ b/R/defaults/main.yml @@ -8,19 +8,24 @@ # The install/remove script has been taken from here: http://adamj.eu/tech/2014/07/19/installing-and-removing-r-packages-with-ansible/ # -r_install_cran_repo: False +# Set to present if you want install from CRAN +r_install_cran_repo: absent #r_cran_mirror_site: http://cran.rstudio.com r_cran_mirror_site: http://cran.mirror.garr.it/mirrors/CRAN/ +r_base_specific_version: False r_base_pkg_version: 2.14.1 r_packages_state: present +r_plugins_from_deb: True +r_plugins_install_latest_source: True +r_plugins_install_specific_source: True r_source_plugins_dest_dir: /var/cache/R r_base_packages_list: - r-base - - jags r_plugins_packages_list: + - jags - r-cran-rjags - r-cran-abind - r-cran-boot @@ -41,9 +46,6 @@ r_plugins_packages_list: - r-cran-spatial - r-cran-survival -# r_plugins_from_sources: -# - { name: 'plyr', version: '1.7.1', source: 'plyr_1.7.1.tar.gz', url: 'http://cran.r-project.org/src/contrib/Archive/plyr/plyr_1.7.1.tar.gz' } - r_plugins_list_to_install: - R2WinBUGS - R2jags @@ -67,5 +69,13 @@ r_plugins_list_to_install: - tools - utils +# r_plugins_from_sources: +# - { name: 'plyr', version: '1.7.1', source: 'plyr_1.7.1.tar.gz', url: 'http://cran.r-project.org/src/contrib/Archive/plyr/plyr_1.7.1.tar.gz' } + +# r_plugins_from_github: +# - { plugin_name: 'RFigisGeo', github_user: 'openfigis' } +# - { plugin_name: 'rsdmx', github_user: 'opensdmx' } + +# Plugins removal not yet implemented #r_plugins_list_to_remove: diff --git a/R/tasks/main.yml b/R/tasks/main.yml index 312e6847..22f50cd9 100644 --- a/R/tasks/main.yml +++ b/R/tasks/main.yml @@ -1,48 +1,24 @@ --- -- name: Install the cran repository key - apt_key: id=E084DAB9 keyserver=keyserver.ubuntu.com state=present - register: update_apt_cache - when: r_install_cran_repo - tags: - - r_software - - r_repo +- name: Manage the cran repository key + apt_key: id=E084DAB9 keyserver=keyserver.ubuntu.com state={{ r_install_cran_repo }} + tags: [ 'r_software', 'r_repo' ] -- name: Install the cran repository definition - apt_repository: repo='deb http://cran.rstudio.com/bin/linux/ubuntu {{ ansible_distribution_release }}/' state=present - register: update_apt_cache - when: r_install_cran_repo - tags: - - r_software - - r_repo +- name: Manage the cran repository definition + apt_repository: repo='deb http://cran.rstudio.com/bin/linux/ubuntu {{ ansible_distribution_release }}/' state={{ r_install_cran_repo }} update_cache=yes + tags: [ 'r_software', 'r_repo' ] -- name: Install the cran repository definition - apt_repository: repo='deb {{ r_cran_mirror_site }}/bin/linux/ubuntu {{ ansible_distribution_release }}/' state=absent - register: update_apt_cache - when: not r_install_cran_repo - tags: - - r_software - - r_repo - -- name: Update the apt cache if needed - apt: update_cache=yes - when: ( update_apt_cache | changed ) - tags: - - r_software - - r_repo - -- name: Install the R base packages +# +# This does not work. It resolves dependecies badly and/or installs the right version only for one of the packages +- name: Install a specific version of the R base package apt: pkg={{ item }} state={{ r_packages_state }} with_items: r_base_packages_list - tags: - - r_software - - r_pkg + tags: [ 'r_software', 'r_pkg' ] -- name: Install the R plugins from the ubuntu repo +- name: Install the R additional modules from the deb repo apt: pkg={{ item }} state={{ r_packages_state }} with_items: r_plugins_packages_list - tags: - - r_software - - r_pkg + when: r_plugins_from_deb + tags: [ 'r_software', 'r_pkg' ] - name: Ensure that the R plugin sources directory exists file: dest={{ r_source_plugins_dest_dir }} state=directory owner=root group=root @@ -55,23 +31,33 @@ when: r_plugins_from_sources is defined tags: [ 'r_software', 'r_pkg', 'r_plugins' ] -- name: Install R plugins from the cran sources +- name: Install R plugins from the cran sources, specific versions command: > Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.name }}' %in% installed.packages()[,'Package'])) { install.packages('{{ r_source_plugins_dest_dir }}/{{ item.source }}', repos = NULL, type='source'); print('Added'); } else { print('Already Installed'); }" register: install_s_plugins_result failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" changed_when: "'Added' in install_s_plugins_result.stdout" with_items: r_plugins_from_sources - when: r_plugins_from_sources is defined + when: r_plugins_install_specific_source tags: [ 'r_software', 'r_pkg', 'r_plugins' ] -- name: Install R plugins from the cran binaries repo +- name: Install R plugins from the cran sources repo, latest version command: > Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item }}' %in% installed.packages()[,'Package'])) { install.packages(pkgs='{{ item }}', repos=c('{{ r_cran_mirror_site }}/')); print('Added'); } else { print('Already installed'); }" register: install_plugins_result failed_when: "install_plugins_result.rc != 0 or 'had non-zero exit status' in install_plugins_result.stderr" changed_when: "'Added' in install_plugins_result.stdout" with_items: r_plugins_list_to_install + when: r_plugins_install_latest_source tags: [ 'r_software', 'r_pkg', 'r_plugins' ] +- name: Install R plugins from github + command: > + Rscript --slave --no-save --no-restore-history -e "if (! ('{{ item.plugin_name }}' %in% installed.packages()[,'Package'])) { require(devtools); require(methods) ; options(repos='{{ r_cran_mirror_site }}/') ; install_github('{{ item.plugin_name }}', '{{ item.github_user }}'); print('Added'); } else { print('Already Installed'); }" + register: install_s_plugins_result + failed_when: "install_s_plugins_result.rc != 0 or 'had non-zero exit status' in install_s_plugins_result.stderr" + changed_when: "'Added' in install_s_plugins_result.stdout" + with_items: r_plugins_from_github + when: r_plugins_from_github is defined + tags: [ 'r_software', 'r_pkg', 'r_plugins', 'r_plugins_github' ] diff --git a/ubuntu-deb-general/files/backports-squeeze b/ubuntu-deb-general/files/backports-squeeze new file mode 100644 index 00000000..b75466bd --- /dev/null +++ b/ubuntu-deb-general/files/backports-squeeze @@ -0,0 +1,3 @@ +Package: * +Pin: release a=squeeze-backports +Pin-Priority: 600 diff --git a/ubuntu-deb-general/files/backports b/ubuntu-deb-general/files/backports-wheezy similarity index 100% rename from ubuntu-deb-general/files/backports rename to ubuntu-deb-general/files/backports-wheezy diff --git a/ubuntu-deb-general/tasks/packages.yml b/ubuntu-deb-general/tasks/packages.yml index 78d8236f..f7ffc9cc 100644 --- a/ubuntu-deb-general/tasks/packages.yml +++ b/ubuntu-deb-general/tasks/packages.yml @@ -1,67 +1,46 @@ --- -- name: install iotop backport PPA - copy: src=files/hardy-iotop-ppa dest=/etc/apt/sources.list.d/iotop-ppa.list - when: is_hardy - notify: apt update - tags: - - packages - -- name: GPG key for iotop backport PPA - shell: apt-key list | grep -q 4B1E287796DD5C9A || gpg --keyserver keyserver.ubuntu.com --recv 4B1E287796DD5C9A; gpg --export --armor 4B1E287796DD5C9A | sudo apt-key add - - when: is_hardy - tags: - - packages - - name: Install the basic packages apt: pkg=python-software-properties state=installed - when: has_apt - tags: - - packages + tags: packages - name: Install software-properties-common if needed apt: pkg=software-properties-common state=installed when: is_quantal - tags: - - packages + tags: packages -- name: Install the backports repository on debian 6 - apt_repository: repo='deb http://http.debian.net/debian-backports squeeze-backports main' state=present - register: update_apt_cache +- name: Default the backports repository on debian 6 + copy: src=backports-squeeze dest=/etc/apt/preferences.d/backports owner=root group=root mode=644 when: is_debian6 tags: squeeze-backports -- name: Install the backports repository on debian 7 - apt_repository: repo='deb http://http.debian.net/debian wheezy-backports main' state=present - register: update_apt_cache +- name: Install the backports repository on debian 6 + apt_repository: repo='deb http://http.debian.net/debian-backports squeeze-backports main' state=present update_cache=yes + when: is_debian6 + tags: squeeze-backports + +- name: Default the backports repository on debian 7 + copy: src=backports-wheezy dest=/etc/apt/preferences.d/backports owner=root group=root mode=644 when: is_debian7 tags: wheezy-backports -- name: Default the backports repository on debian 7 - copy: src=backports dest=/etc/apt/preferences.d owner=root group=root mode=644 - register: update_apt_cache +- name: Install the backports repository on debian 7 + apt_repository: repo='deb http://http.debian.net/debian wheezy-backports main' state=present update_cache=yes when: is_debian7 - tags: Default-wheezy-backports + tags: wheezy-backports - name: Install the backports repository on debian 8 - apt_repository: repo='deb http://http.debian.net/debian jessie-backports main' state=present - register: update_apt_cache + apt_repository: repo='deb http://http.debian.net/debian jessie-backports main' state=present update_cache=yes when: is_debian8 tags: jessie-backports # Debian 7 “Wheezy” from February 2016 to May 2018 # Debian 8 “Jessie“ from May 2018 to April/May 2020 - name: Install the squeeze-lts repository on debian 6 - apt_repository: repo='deb http://http.debian.net/debian squeeze-lts main contrib non-free' state=present + apt_repository: repo='deb http://http.debian.net/debian squeeze-lts main contrib non-free' state=present update_cache=yes register: update_apt_cache when: is_debian6 tags: squeeze-lts -# - name: Install the wheezy-lts repository on debian 7 -# apt_repository: repo='deb http://http.debian.net/debian wheezy-lts main contrib non-free' state=present -# register: update_apt_cache -# when: is_debian7 -# tags: wheeze-lts - - name: apt key for the internal ppa repository apt_key: url=http://ppa.research-infrastructures.eu/system/keys/system-archive.asc state=present when: is_ubuntu