From 32e9d3ee84f488ef2c1b519aa645b883c5757226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Thu, 18 Jan 2018 10:53:29 +0100 Subject: [PATCH] Fix ansible warning group and host with same name Ansible warns us that our generate inventory use the same name for a group and a host: [WARNING]: Found both group and host with same name: undercloud It doesn't make much sense to have an 'undercloud' group with just the 'undercloud' host in it. Skip group creation in the generated inventory when the group name matches the name of the sole group host. Change-Id: I77bf3de7b2bfc7787a07d748ba28f9ff448a71ab --- roles/tripleo-inventory/tasks/inventory.yml | 1 - roles/tripleo-inventory/templates/inventory.j2 | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/roles/tripleo-inventory/tasks/inventory.yml b/roles/tripleo-inventory/tasks/inventory.yml index 43952ad73..5b7631bf4 100644 --- a/roles/tripleo-inventory/tasks/inventory.yml +++ b/roles/tripleo-inventory/tasks/inventory.yml @@ -85,7 +85,6 @@ - name: Add undercloud vm to inventory add_host: name: undercloud - groups: undercloud ansible_host: '{{ undercloud_ip }}' ansible_fqdn: undercloud ansible_user: '{{ undercloud_user }}' diff --git a/roles/tripleo-inventory/templates/inventory.j2 b/roles/tripleo-inventory/templates/inventory.j2 index 88df3355e..2a91cbd8a 100644 --- a/roles/tripleo-inventory/templates/inventory.j2 +++ b/roles/tripleo-inventory/templates/inventory.j2 @@ -25,7 +25,7 @@ # BEGIN Autogenerated groups {% for group in groups %} -{% if group not in ['ungrouped', 'all'] %} +{% if group not in ['ungrouped', 'all'] and not (groups[group]|length == 1 and groups[group][0] == group) %} [{{ group }}] {% for host in groups[group] %} {{ host }}