From 3b3b46a53a65f0fa433b4215e60903d14002bfe5 Mon Sep 17 00:00:00 2001 From: Olivier Clavel Date: Tue, 25 Oct 2022 08:09:33 +0200 Subject: [PATCH] Use find instead of ls in command (#358) --- tasks/main.yml | 4 ++-- tasks/nexus_install.yml | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index aa5c82b3..de5b79ff 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -60,7 +60,7 @@ - nuget-group - nuget-hosted - nuget.org-proxy - when: (nexus_data_dir_contents.stdout | length == 0) and nexus_delete_default_repos + when: (nexus_data_dir_contents.matched == 0) and nexus_delete_default_repos - name: Deleting default blobstore include_tasks: delete_blobstore_each.yml @@ -72,7 +72,7 @@ | list | unique }} - when: (nexus_data_dir_contents.stdout | length == 0) and nexus_delete_default_blobstore + when: (nexus_data_dir_contents.matched == 0) and nexus_delete_default_blobstore - block: - include_tasks: setup_ldap_each.yml diff --git a/tasks/nexus_install.yml b/tasks/nexus_install.yml index a7d19588..fd3bf109 100644 --- a/tasks/nexus_install.yml +++ b/tasks/nexus_install.yml @@ -381,7 +381,13 @@ when: nexus_backup_configure | bool - name: 'Check if data directory is empty (first-time install)' - command: "ls --ignore=lost+found {{ nexus_data_dir }}" + find: + paths: + - "{{ nexus_data_dir }}" + excludes: + - lost+found + recurse: no + file_type: any register: nexus_data_dir_contents check_mode: no changed_when: false @@ -390,7 +396,7 @@ file: path: "{{ nexus_data_dir }}/clean_cache" state: touch - when: nexus_latest_version.changed and nexus_data_dir_contents.stdout | length > 0 + when: nexus_latest_version.changed and nexus_data_dir_contents.matched > 0 tags: # hard to run as a handler for time being - skip_ansible_lint