From 06be633265971d3b07c14c1b2c4ac15fbab0a663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 7 Aug 2022 22:40:16 +0200 Subject: [PATCH] Assign hosts to service/component groups --- inventory/06-hosts-in-service-groups.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 inventory/06-hosts-in-service-groups.yml diff --git a/inventory/06-hosts-in-service-groups.yml b/inventory/06-hosts-in-service-groups.yml new file mode 100644 index 0000000..a54ffd1 --- /dev/null +++ b/inventory/06-hosts-in-service-groups.yml @@ -0,0 +1,24 @@ +plugin: constructed +strict: false + +compose: + + # Service instance groups + _inv__instance_group: >- + inv__service ~ '_' ~ inv__instance ~ _inv__managed + + # Service component groups + _inv__component_group: >- + inv__service ~ '_' ~ inv__subcomponent | default( inv__component ) + ~ _inv__managed + +keyed_groups: + + # Create service instance groups inside the main service group. + - prefix: svin + key: _inv__instance_group + parent_group: "svc_{{ inv__service }}" + + # Add the host to the component group + - prefix: svcm + key: _inv__component_group