I've been scouring the web to help point me in the right direction but to no avail.
I'm trying to take multi-line array from one YML file and parse the values into a different ansible playbook:
services.yml array:
---
Groups:
services:
Columns: [service_name, port, protocol, destination]
Rows:
- ['service1', '1234', 'TCP', 'Inbound']
- ['service2', '5678', 'TCP', 'Inbound']
- ['service3', '9012', 'TCP', 'Inbound']
Which gets parsed into this powershell task:
- name: set the services yml file as a var
ansible.builtin.include_vars:
file: service.yml
name: services
- name: Apply local FW rules
ansible.windows.win_powershell:
script: |
New-NetFirewallRule -DisplayName='{{ item.service_name }}' -LocalPort '{{ item.port }}' -Direction '{{ item.direction }} -Protocol '{{ item.protocol }} -Action Allow
loop: "{{ services }}"
Looking for a pointer or what kind of data pre-processing we need to do in order to break out this array into a dictonary for use within the loop
So far we've tried a mix of various differnt combinations with limited success. at one point we were able to pass the entire line as an object to POwershell, but that dosen't work becsue we need each comma seperated item as it's own independent value.