I need to pull some information from a large number of ONTAP clusters and store the info into a separete file per cluster. This info will then be importing into mongoDB and used for various reporting requirements.
I have the playbook setup using a loop for the login credentials so it can iterate over each cluster defined in a file but the "results" are all stored in a single variable so when copying to a file i send up with all output together.
Is there a better way to do this or how can i register the results for each item in the loop separately?
collections:
- netapp.ontap
gather_facts: false
tasks:
- name: gather ontap info required for esa select subsets only
netapp.ontap.na_ontap_rest_info:
hostname: "{{ item.cluster_ip }}"
username: "{{ item.username }}"
password: "{{ item.password }}"
https: true
validate_certs: false
use_rest: Always
use_python_keys: true
hal_linking: false
max_records: 5000
fields:
- '*'
gather_subset:
- cluster
- cluster/nodes
- storage/aggregates
- storage/shelves
- storage/switches
register: "{{ ontap_info }}"
loop: "{{ clusters }}"
- name: copy output to a file
ansible.builtin.copy:
content: "{{ ontap_info }}"
dest: /playbooks/esa/inventory/"{{ cluster + uuid }}"```