Adding the `always` tag to the tasks in `dyngroups.yml` ensures that hosts will get added to the appropriate groups dynamically, even when running a subset of tasks by targeting specific tags. Ansible will always run tasks with this tag when a tag selection is passed to `ansible-playbook`.
25 lines
669 B
YAML
25 lines
669 B
YAML
- hosts: all
|
|
gather_facts: true
|
|
tasks:
|
|
- name: group hosts by distribution
|
|
group_by:
|
|
key: '{{ ansible_distribution }}'
|
|
changed_when: false
|
|
tags: always
|
|
- name: group hosts by distribution+version
|
|
group_by:
|
|
key: '{{ ansible_distribution }}{{ ansible_distribution_major_version }}'
|
|
changed_when: false
|
|
tags: always
|
|
- name: group hosts by os family
|
|
group_by:
|
|
key: '{{ ansible_os_family }}'
|
|
changed_when: false
|
|
tags: always
|
|
- name: group hosts by virtualization
|
|
group_by:
|
|
key: >-
|
|
{{ ansible_virtualization_type }}-{{ ansible_virtualization_role }}
|
|
changed_when: false
|
|
tags: always
|