aruba: use the hostname, not the FQDN

This commit is contained in:
jeltz 2022-09-05 11:52:12 +02:00
parent 1d4534f19c
commit 89d22feba1
Signed by: jeltz
GPG key ID: 800882B66C0C3326
2 changed files with 7 additions and 1 deletions

View file

@ -8,6 +8,7 @@ class FilterModule:
def filters(self): def filters(self):
return { return {
"remove_domain_suffix": remove_domain_suffix, "remove_domain_suffix": remove_domain_suffix,
"hostname": hostname,
"ipaddr_sort": ipaddr_sort, "ipaddr_sort": ipaddr_sort,
} }
@ -17,6 +18,11 @@ def remove_domain_suffix(name):
return parent.to_text() return parent.to_text()
def hostname(fqdn):
name = dns.name.from_text(fqdn)
return name.relativize(name.parent()).to_text()
def ipaddr_sort(addrs, types, unknown_after=True): def ipaddr_sort(addrs, types, unknown_after=True):
check_types = { check_types = {
"global": attrgetter("is_global"), "global": attrgetter("is_global"),

View file

@ -1,6 +1,6 @@
{{ ansible_managed | comment(decoration="; ") }} {{ ansible_managed | comment(decoration="; ") }}
hostname {{ aruba__hostname | truncate(32) | enquote }} hostname {{ aruba__hostname | hostname | truncate(32) | enquote }}
include-credentials include-credentials