Created
July 27, 2023 02:17
-
-
Save cat-bro/37760ccbdb27f137239d8dfba51275e1 to your computer and use it in GitHub Desktop.
ansible: iterate over a list of directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Get a list of directories within a directory | |
find: | |
paths: | |
- "{{ parent_dir_name }}" | |
file_type: directory | |
depth: 1 | |
register: list_of_dirs | |
- name: Iterate over list of dirs | |
debug: | |
msg: | |
"Found directory {{ item }} in {{ parent_dir_name }}" | |
with_items: "{{ list_of_dirs.files | map(attribute='path') | map('basename') }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment