From 9af8e490a3240129089d6711ad21450ac5c60953 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Wed, 15 Mar 2023 01:36:34 +0100 Subject: [PATCH] Use inventory_hostname_short --- tasks/main.yml | 4 ++-- templates/hostname.j2 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index e854ffc..2de67b5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,9 +20,9 @@ line: "{{ item.ip }} {{ item.hosts }}" with_items: - ip: "127.0.0.1" - hosts: "{{ inventory_hostname }} {{ inventory_hostname.split('.')[0] }} localhost localhost.localdomain" + hosts: "{{ inventory_hostname }} {{ inventory_hostname_short }} localhost localhost.localdomain" - ip: "::1" - hosts: "{{ inventory_hostname }} {{ inventory_hostname.split('.')[0] }} localhost localhost.localdomain" + hosts: "{{ inventory_hostname }} {{ inventory_hostname_short }} localhost localhost.localdomain" - import_tasks: "pkg_Alpine.yml" when: ansible_distribution == 'Alpine' diff --git a/templates/hostname.j2 b/templates/hostname.j2 index c2786e3..29be72b 100644 --- a/templates/hostname.j2 +++ b/templates/hostname.j2 @@ -1 +1 @@ -{{ inventory_hostname.split(".")[0] }} \ No newline at end of file +{{ inventory_hostname_short }} \ No newline at end of file