- name: Retrieve billing data using custom python script vars: output_file: "ibm_billing_metrics.json" tag_key: "tag" tag_value: "{{ item }}-{{ tag_uuid }}" ansible.builtin.command: cmd: python3 files/fetch_billing_data_ibm.py --tag_key '{{ tag_key }}' --tag_value '{{ item }}-{{ tag_uuid }}' --api_key '{{ IBM_CLOUD_TOKEN }}' register: billing_data loop: - karpenter - cas - name: Write billing data to file ansible.builtin.copy: content: "{{ billing_data.stdout }}" dest: "{{ output_file | replace('.json', '-'+item+'.json') }}" when: billing_data is defined loop: - karpenter - cas