From 4d26565bb74188814a68d8fba5353d89711233ba Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 17 May 2021 10:44:34 +0200 Subject: [PATCH] Cs fixes --- tasks/get_list_packages.yml | 16 ---------------- tasks/packages.yml | 19 ++++++++++++++++--- templates/R-install-package.j2 | 4 ++-- templates/R-list-installed-packages.j2 | 1 - 4 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 tasks/get_list_packages.yml diff --git a/tasks/get_list_packages.yml b/tasks/get_list_packages.yml deleted file mode 100644 index 7bf9c78..0000000 --- a/tasks/get_list_packages.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: packages | list installed packages - command: > - R-list-installed-packages {{ r_packages_lib }} - environment: "{{ r_environment }}" - register: _r_installed_packages - changed_when: false - tags: - - r-list-installed-packages - -- name: packages | set_fact list installed packages - set_fact: - r_installed_packages: "{{ _r_installed_packages.stdout_lines }}" - tags: - - r-list-installed-packages diff --git a/tasks/packages.yml b/tasks/packages.yml index 592703c..baef509 100644 --- a/tasks/packages.yml +++ b/tasks/packages.yml @@ -21,9 +21,22 @@ tags: - r-packages-copy-r-scripts -- name: packages | init the package lists - include: get_list_packages.yml - when: r_list_packages_once +- block: + + - name: packages | list installed packages + command: > + R-list-installed-packages {{ r_packages_lib }} + environment: "{{ r_environment }}" + register: _r_installed_packages + changed_when: false + + - name: packages | set_fact list installed packages + set_fact: + r_installed_packages: "{{ _r_installed_packages.stdout_lines }}" + + when: r_list_packages_once | bool + tags: + - r-packages-list-installed - name: packages | install command: > diff --git a/templates/R-install-package.j2 b/templates/R-install-package.j2 index 94c7dbd..501114c 100644 --- a/templates/R-install-package.j2 +++ b/templates/R-install-package.j2 @@ -16,7 +16,7 @@ if (type == 'github') { package = argv[1]; } -{% if r_list_packages_once == false %} +{% if not r_list_packages_once %} if (!(package %in% installed.packages(lib.loc = lib)[, 'Package'])) { {% endif %} if (type == 'cran') { @@ -54,6 +54,6 @@ if (!(package %in% installed.packages(lib.loc = lib)[, 'Package'])) { cat("Unrecognised type\n"); q(status = 1); } -{% if r_list_packages_once == false %} +{% if not r_list_packages_once %} } {% endif %} diff --git a/templates/R-list-installed-packages.j2 b/templates/R-list-installed-packages.j2 index 843f33d..0be72f9 100644 --- a/templates/R-list-installed-packages.j2 +++ b/templates/R-list-installed-packages.j2 @@ -9,4 +9,3 @@ if (is.null(argv) | length(argv) < 1) { lib = ifelse(is.na(argv[1]), '{{ r_packages_lib }}', argv[1]); cat(paste(installed.packages(lib.loc = lib)[, 'Package'], collapse="\n")) -