I'm trying to use the result of Ansible find command, which return list of files it find on a specific folder, the problem is, when I iterate over the result, I do not have the file names, I only have their full paths (including the name), is there an easy way to use the result item below to provide the file_name in the second command as shown below?
- name: get files
find:
paths: /home/me
file_type: "file"
register: find_result
- name: Execute docker secret create
shell: docker secret create <file_name> {{ item.path }}
run_once: true
with_items: "{{ find_result.files }}"
question from:
https://stackoverflow.com/questions/45564899/extract-filename-from-file-result-in-ansible 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…