2024-09/12/group_by.yml

39 lines
944 B
YAML
Raw Normal View History

2024-09-19 13:00:30 +00:00
---
- hosts:
- all
- localhost
tasks:
- group_by:
key: "sv_pkgsvcmgr_{{ ansible_pkg_mgr }}-{{ ansible_service_mgr }}"
parents:
- "sv_pkgmgr_{{ ansible_pkg_mgr }}"
- group_by:
key: "sv_svcmgr_{{ ansible_service_mgr }}"
- group_by:
key: "sv_mac_{{ '_'.join(ansible_default_ipv4.macaddress.split(':')[5:6]) }}"
- group_by:
key: "sv_net4_{{ ansible_default_ipv4.network }}"
- group_by:
key: "sv_v6int_{{ ansible_default_ipv6.interface|default('nov6') }}"
- group_by:
key: "sv_distri_{{ ansible_distribution }}"
- group_by:
key: "sv_family_{{ ansible_os_family }}"
- group_by:
key: "sv_{{ ansible_virtualization_role }}_{{ ansible_virtualization_type }}"
- hosts: localhost
gather_facts: no
tasks:
- debug:
msg: "{{ groups | dict2items | selectattr('key', 'contains', 'sv_') | list | items2dict }}"