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
This commit is contained in:
Emilien Macchi 2020-05-01 16:24:00 -04:00
parent 015c05331b
commit 2eac1eeca4
1 changed files with 8 additions and 6 deletions

View File

@ -18,14 +18,16 @@
# TODO(arxcruz) Right now there are yaml files that are not # TODO(arxcruz) Right now there are yaml files that are not
# a valid tempest-skiplist file, so we are using just one for now # a valid tempest-skiplist file, so we are using just one for now
- name: List all yaml files to be tested # The task isn't useful until we get rid of the old yaml files
shell: ls roles/validate-tempest/vars/*.yml # (see next task).
args: - name: Find all yaml files to be tested
chdir: "{{ tempest_skip_path }}" find:
paths: "{{ tempest_skip_path }}/roles/validate-tempest/vars"
patterns: '*.yml,*.yaml'
register: yaml_files register: yaml_files
# TODO(arxcruz) Once we get rid of the old 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 - name: Validate tempest-skip yaml files
shell: shell:
set -ex set -ex
@ -36,4 +38,4 @@
chdir: "{{ tempest_skip_path }}" chdir: "{{ tempest_skip_path }}"
vars: vars:
tempest_skip_path: "{{ zuul.projects['opendev.org/openstack/openstack-tempest-skiplist'].src_dir }}" tempest_skip_path: "{{ zuul.projects['opendev.org/openstack/openstack-tempest-skiplist'].src_dir }}"