From 00d30a67fbbebd8900bb84304095082f2b5019c1 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 24 Aug 2021 19:56:22 -0500 Subject: [PATCH] base: Enable serial console on KVM VMs Occasionally, VMs running on the main libvirt VM hosts will freeze or otherwise become unavailable via network. Sometimes, when this happens, their normal consoles are unresponsive as well. Having the serial console available as a fallback can sometimes be helpful in recovering from such situations. To ensure the serial console is available on all VMs, we use a "dynamic" group, based on the virtualization type and role of the managed node. All KVM-based virtual machines are included in a group named *kvm-vm*. A play in `base.yml` applies the *serial-console* role to members of this group. --- base.yml | 4 ++++ dyngroups.yml | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/base.yml b/base.yml index 0bf1779..2e44e1e 100644 --- a/base.yml +++ b/base.yml @@ -1,3 +1,7 @@ +- import_playbook: dyngroups.yml - hosts: all roles: - base +- hosts: kvm-guest + roles: + - serial-console diff --git a/dyngroups.yml b/dyngroups.yml index a0f8c5b..e0f2ab1 100644 --- a/dyngroups.yml +++ b/dyngroups.yml @@ -3,4 +3,10 @@ tasks: - name: group hosts by distribution group_by: - key={{ ansible_os_family }} + key: '{{ ansible_os_family }}' + changed_when: false + - name: group hosts by virtualization + group_by: + key: >- + {{ ansible_virtualization_type }}-{{ ansible_virtualization_role }} + changed_when: false