From 2eac1eeca498255a62a1100b377aa3ed18351788 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 1 May 2020 16:24:00 -0400 Subject: [PATCH] Transform shell/ls task to use "find" module The Ansible way to list files which match a certain parttern is to use the find module: https://docs.ansible.com/ansible/latest/modules/find_module.html Also adding a comment that the task isn't useful for now, and modify a comment which recommends to use with_items (deprecated) while a loop should be used with newer Ansible. Change-Id: I67e55857d7d510d96319ee767473c11942b79239 --- roles/validate-yaml/tasks/main.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/roles/validate-yaml/tasks/main.yaml b/roles/validate-yaml/tasks/main.yaml index a98fb44..c38a851 100644 --- a/roles/validate-yaml/tasks/main.yaml +++ b/roles/validate-yaml/tasks/main.yaml @@ -18,14 +18,16 @@ # TODO(arxcruz) Right now there are yaml files that are not # a valid tempest-skiplist file, so we are using just one for now - - name: List all yaml files to be tested - shell: ls roles/validate-tempest/vars/*.yml - args: - chdir: "{{ tempest_skip_path }}" + # The task isn't useful until we get rid of the old yaml files + # (see next task). + - name: Find all yaml files to be tested + find: + paths: "{{ tempest_skip_path }}/roles/validate-tempest/vars" + patterns: '*.yml,*.yaml' register: yaml_files # TODO(arxcruz) Once we get rid of the old yaml files, - # use yaml_files.stdout_lines in a with_items + # use yaml_files.files in a loop - name: Validate tempest-skip yaml files shell: set -ex @@ -36,4 +38,4 @@ chdir: "{{ tempest_skip_path }}" vars: - tempest_skip_path: "{{ zuul.projects['opendev.org/openstack/openstack-tempest-skiplist'].src_dir }}" \ No newline at end of file + tempest_skip_path: "{{ zuul.projects['opendev.org/openstack/openstack-tempest-skiplist'].src_dir }}"