ansible / ansible.builtin / v2.16.0 / module / group_by Create Ansible groups based on facts | "added in version" 0.9 of ansible.builtin" Authors: Jeroen Hoekx (@jhoekx) This plugin has a corresponding action plugin.ansible.builtin.group_by (v2.16.0) — module
pip
Install with pip install ansible-core==2.16.0
Use facts to create ad-hoc groups that can be used later in a playbook.
This module is also supported for Windows targets.
- name: Create groups based on the machine architecture ansible.builtin.group_by: key: machine_{{ ansible_machine }}
- name: Create groups like 'virt_kvm_host' ansible.builtin.group_by: key: virt_{{ ansible_virtualization_type }}_{{ ansible_virtualization_role }}
- name: Create nested groups ansible.builtin.group_by: key: el{{ ansible_distribution_major_version }}-{{ ansible_architecture }} parents: - el{{ ansible_distribution_major_version }}
- name: Add all active hosts to a static group ansible.builtin.group_by: key: done
key: description: - The variables whose values will be used as groups. required: true type: str parents: default: all description: - The list of the parent groups. elements: str type: list version_added: '2.4' version_added_collection: ansible.builtin