Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save radamhu/2d57372b4216ae3fec5e78d2bc18978d to your computer and use it in GitHub Desktop.
Save radamhu/2d57372b4216ae3fec5e78d2bc18978d to your computer and use it in GitHub Desktop.
ansible: get files from directory - only names without path
- name: "get files from dir"
find:
paths: "/some/dir/foo"
register: found_files
- name: print file names without path
debug:
msg: "{{ found_files['files'] | map(attribute='path') | map('regex_replace','^.*/(.*)$','\\1') | list }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment