From 5eff04940361c0f8a9e98264065505f0fa371ca9 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 2 Nov 2020 09:24:29 -0700 Subject: [PATCH] Try ipaddr filter from collection Going forward, many of the filters and code that used to be in ansible core were moved to collections. We use the ipaddr filter in a few places so in order to support newer versions, we need to try to load the collection version first before falling back to the legacy one in ansible <=2.9 Change-Id: If1d273da61041fa4b7b9f4430264acda1d3841e8 --- .../ansible_plugins/action/tripleo_all_nodes_data.py | 5 ++++- tripleo_ansible/ansible_plugins/action/tripleo_iptables.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tripleo_ansible/ansible_plugins/action/tripleo_all_nodes_data.py b/tripleo_ansible/ansible_plugins/action/tripleo_all_nodes_data.py index ea61295da..30634ae40 100644 --- a/tripleo_ansible/ansible_plugins/action/tripleo_all_nodes_data.py +++ b/tripleo_ansible/ansible_plugins/action/tripleo_all_nodes_data.py @@ -46,7 +46,10 @@ import traceback from ansible.errors import AnsibleError from ansible.plugins.action import ActionBase -from ansible.plugins.filter import ipaddr +try: + from ansible_collections.ansible.netcommon.plugins.filter import ipaddr +except ImportError: + from ansible.plugins.filter import ipaddr from ansible.utils.display import Display diff --git a/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py b/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py index 24ec70f7d..0512845f2 100644 --- a/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py +++ b/tripleo_ansible/ansible_plugins/action/tripleo_iptables.py @@ -50,7 +50,10 @@ EXAMPLES = """ from ansible.plugins.action import ActionBase -from ansible.plugins.filter import ipaddr +try: + from ansible_collections.ansible.netcommon.plugins.filter import ipaddr +except ImportError: + from ansible.plugins.filter import ipaddr from ansible.utils.display import Display