From 15e2db49f378e20938e0b77f96d1ea9bd345cedd Mon Sep 17 00:00:00 2001 From: Jeltz Date: Sat, 27 Aug 2022 04:22:15 +0200 Subject: [PATCH] add remove_domain_suffix filter --- ansible.cfg | 1 + filter_plugins/net_utils.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 filter_plugins/net_utils.py diff --git a/ansible.cfg b/ansible.cfg index 6476e6f..b04e116 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -3,6 +3,7 @@ ask_vault_pass = True roles_path = ./roles retry_files_enabled = False inventory = ./hosts +filter_plugins = ./filter_plugins ansible_managed = Ansible managed, modified on %Y-%m-%d %H:%M:%S nocows = 1 forks = 15 diff --git a/filter_plugins/net_utils.py b/filter_plugins/net_utils.py new file mode 100644 index 0000000..082f34d --- /dev/null +++ b/filter_plugins/net_utils.py @@ -0,0 +1,13 @@ +import dns.name + + +class FilterModule: + def filters(self): + return { + "remove_domain_suffix": remove_domain_suffix, + } + + +def remove_domain_suffix(name): + parent = dns.name.from_text(name).parent() + return parent.to_text()