mirror of https://github.com/ansible/ansible.git
Fix fileglob when using 'file*' vs 'stuff/file*' (#68945)
* Fix fileglob when using 'file*' vs 'stuff/file*'
when not having dir in glob, files/ subdir was being ignored.
* tests for fileglob
(cherry picked from commit d3cab602a5)
pull/69271/head
parent
17458a16ca
commit
f8a5377cc6
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- deal with cases in which just a file is pased and not a path with directories, now fileglob correctly searches in 'files/' subdirs.
|
||||
@ -0,0 +1 @@
|
||||
shippable/posix/group1
|
||||
@ -0,0 +1 @@
|
||||
in files subdir adjacent to play
|
||||
@ -0,0 +1 @@
|
||||
in play adjacent subdir of files/
|
||||
@ -0,0 +1,13 @@
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
expected:
|
||||
play_adj: ajectent to play
|
||||
play_adj_subdir: in files subdir adjacent to play
|
||||
somepath/play_adj_subsubdir: in play adjacent subdir of files/
|
||||
in_role: file in role
|
||||
otherpath/in_role_subdir: file in role subdir
|
||||
tasks:
|
||||
- name: Import role lookup
|
||||
import_role:
|
||||
name: get_file
|
||||
@ -0,0 +1 @@
|
||||
ajectent to play
|
||||
@ -0,0 +1 @@
|
||||
file in role
|
||||
@ -0,0 +1 @@
|
||||
file in role subdir
|
||||
@ -0,0 +1,10 @@
|
||||
- name: show file contents
|
||||
debug:
|
||||
msg: '{{ q("fileglob", seed + ".*") }}'
|
||||
register: found
|
||||
|
||||
- name: did we get right one?
|
||||
assert:
|
||||
that:
|
||||
- found['msg'][0].endswith(seed + '.txt')
|
||||
- q('file', found['msg'][0])[0] == expected[seed]
|
||||
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
# fun multilevel finds
|
||||
for seed in play_adj play_adj_subdir somepath/play_adj_subsubdir in_role otherpath/in_role_subdir
|
||||
do
|
||||
ansible-playbook find_levels/play.yml -e "seed='${seed}'" "$@"
|
||||
done
|
||||
Loading…
Reference in New Issue