With Ansible, I need to extract content from multiple files. With one file I used slurp and registered a variable.
- name: extract nameserver from .conf file
slurp:
src: /opt/test/roles/bind_testing/templates/zones/example_file.it.j2
delegate_to: 127.0.0.1
register: file
- debug:
msg: "{{ file['content'] | b64decode }}"
But now I have multiple files so I need to extract content from every files, register them one by one to be able to process them later with operations like sed, merging_list etc...
How can I do this in ansible?
I tried to use slurp with with_fileglob directive but I couldn't register the files...
- name: extract nameserver from .conf file
slurp:
src: "{{ item }}"
with_fileglob:
- "/opt/test/roles/bind9_domain/templates/zones/*"
delegate_to: 127.0.0.1
register: file