From c2908a62fdf2bb5fab590341b7e1117efe08470b Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Tue, 10 Dec 2024 11:27:44 +0100 Subject: [PATCH 1/3] Make use of other keyring --- tasks/packages.yml | 2 +- tasks/repository.yml | 25 ++++++++++++++++++------- tests/test.yml | 3 ++- tests/vagrant.yml | 3 ++- vars/main.yml | 10 +++++++--- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/tasks/packages.yml b/tasks/packages.yml index 7d66240..d6c303c 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -6,7 +6,7 @@ dest: "{{ r_scripts_install_path }}/{{ item.dest }}" owner: "{{ r_scripts_install_owner }}" group: "{{ r_scripts_install_group }}" - mode: 0755 + mode: '0755' with_items: - src: R-list-installed-packages.j2 dest: R-list-installed-packages diff --git a/tasks/repository.yml b/tasks/repository.yml index 1170436..521a0d5 100644 --- a/tasks/repository.yml +++ b/tasks/repository.yml @@ -9,20 +9,31 @@ tags: - r-repository-install-dependencies -- name: repository | add public key +- name: repository | (keyrings) directory | create + ansible.builtin.file: + path: "{{ r_keyring_dst | dirname }}" + state: directory + owner: root + group: root + mode: '0755' + tags: + - r-repository-keyrings-directory-create + +- name: repository | (keyring) file | download ansible.builtin.apt_key: - id: E298A3A825C0D65DFD57CBB651716619E084DAB9 + id: "{{ r_keyring_id }}" keyserver: "{{ apt_key_keyserver | default('keyserver.ubuntu.com') }}" + keyring: "{{ r_keyring_dst }}" state: present tags: - - r-repository-public-key + - r-repository-keyring-file-download -- name: repository | add cran-r +- name: repository | add ansible.builtin.apt_repository: repo: "{{ item.type }} {{ item.url }}" - state: present + state: "{{ item.state | default('present') }}" update_cache: true - mode: 0644 - with_items: "{{ r_repository }}" + mode: '0644' + with_items: "{{ r_repositories }}" tags: - r-repository-add diff --git a/tests/test.yml b/tests/test.yml index 5969110..8808281 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -1,6 +1,7 @@ # test file --- -- hosts: localhost +- name: converge + hosts: localhost connection: local become: true roles: diff --git a/tests/vagrant.yml b/tests/vagrant.yml index cb458a1..2a1ab1d 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -1,6 +1,7 @@ # test file --- -- hosts: all +- name: converge + hosts: all remote_user: vagrant become: true roles: diff --git a/vars/main.yml b/vars/main.yml index 8a519e4..a0a5a90 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,14 +1,18 @@ # vars file --- -r_repository_suffix: "{{ '-cran' + r_version if r_version is version('35', '>=') else '' }}" -r_repository: +r_keyring_id: E298A3A825C0D65DFD57CBB651716619E084DAB9 +r_keyring_dst: /usr/share/keyrings/insync.gpg +r_repositories: + - type: "deb [signed-by={{ r_keyring_dst }}]" + url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_repository_suffix }}/" - type: deb url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_repository_suffix }}/" + state: absent +r_repository_suffix: "{{ '-cran' + r_version if r_version is version('35', '>=') else '' }}" r_dependencies_pre: - software-properties-common - dirmngr - - gpg-agent - apt-transport-https r_dependencies: From 81d02752591aaecad0ec77c192f1b19f8b846b08 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Tue, 10 Dec 2024 11:29:34 +0100 Subject: [PATCH 2/3] Cleanup --- vars/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/main.yml b/vars/main.yml index a0a5a90..f1bc757 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,14 +1,14 @@ # vars file --- r_keyring_id: E298A3A825C0D65DFD57CBB651716619E084DAB9 -r_keyring_dst: /usr/share/keyrings/insync.gpg +r_keyring_dst: /usr/share/keyrings/cran-r.gpg +r_repository_suffix: "{{ '-cran' + r_version if r_version is version('35', '>=') else '' }}" r_repositories: - type: "deb [signed-by={{ r_keyring_dst }}]" url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_repository_suffix }}/" - type: deb url: "{{ r_cran_mirror }}/bin/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }}{{ r_repository_suffix }}/" state: absent -r_repository_suffix: "{{ '-cran' + r_version if r_version is version('35', '>=') else '' }}" r_dependencies_pre: - software-properties-common From 71650a23d5028b0b5b58c6e30024ee204827e094 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Tue, 10 Dec 2024 11:47:44 +0100 Subject: [PATCH 3/3] Cleanup --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca5813b..dae48f7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Set up the latest version of R in Ubuntu systems. * `r_cran_mirror`: [default: `https://cran.rstudio.com/`]: Your favorite [CRAN mirror](https://cran.r-project.org/mirrors.html) * `r_bioclite_url`: [default: `https://bioconductor.org/biocLite.R`]: The `biocLite.R` script URL for [Bioconductor](https://bioconductor.org/) installs -* `r_install_dev`: [default: `false`]: Whether or not install the `r-base-dev` package +* `r_install_dev`: [default: `false`]: Whether install the `r-base-dev` package * `r_install`: [default: `['littler']`]: Additional (apt) packages to install (e.g. `r-recommended`) * `r_packages_lib`: [default: `/usr/local/lib/R/site-library`]: The (default) library directory to install packages to @@ -33,7 +33,7 @@ Set up the latest version of R in Ubuntu systems. * `r_packages.{n}.lib`: [optional, default: `r_packages_lib`]: The library directory to install the package to * `r_packages.{n}.repos`: [optional, default: `r_packages_repos`]: The URL to install the package from -* `r_environment`: [default: `{}`]: Environment variables to set (during the install, update or delete packages tasks) +* `r_environment`: [default: `{}`]: Environment variables to set (during the installation, update or delete packages tasks) * `r_scripts_install_path:`: [default: `/usr/local/bin`]: The path where to install the R script used to install, update and delete R package * `r_scripts_install_owner`: [default: `root`]: The owner of the R script to install, update and delete R package