Grouping subelements

Hi All,

How do I group sublement port under portnames?

  • name: Test flatten - 1
    debug:
    msg: “{{ item[1].port | join(‘,’) }}”
    with_subelements:
  • “{{ new_host_groups }}”
  • portnames

----------------json file —

{
“name”: “sda”,
“portnames”: [
{
“nickname”: “sdap1”,
“port”: “2001000e1e4548956”,
“type”: “fc”
},
{
“nickname”: “sdap2”,
“port”: “2001000e1e656562”,
“type”: “fc”
},
{
“nickname”: “sdap3”,
“port”: “2001000e1ec23434”,
“type”: “fc”
},
{
“nickname”: “gladsto2p4”,
“port”: “2001000e1ec25656”,
“type”: “fc”
}
]
}