From 087392847d9788d2118137fc9ade8fce0219e69a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 13:40:50 +0200 Subject: [PATCH] Fix CI (docker_container tests fail because of missing ipaddress) (#218) (#219) * Use stdlib ipaddress, resp. install when needed. * Make sure facts on controller are available. (cherry picked from commit f4b1d34357ecaafc9a73c1830e0a27a1f13a5c43) Co-authored-by: Felix Fontein --- .../docker_container/filter_plugins/ipaddr_tools.py | 4 ++-- .../targets/docker_container/tasks/main.yml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py b/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py index 1b809aae..29f6552e 100644 --- a/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py +++ b/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py @@ -18,10 +18,10 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.community.crypto.plugins.module_utils.compat import ipaddress - def _normalize_ipaddr(ipaddr): + # Import when needed, to allow installation of that module in the test setup + import ipaddress return ipaddress.ip_address(ipaddr).compressed diff --git a/tests/integration/targets/docker_container/tasks/main.yml b/tests/integration/targets/docker_container/tasks/main.yml index bbed2817..66e3d7bc 100644 --- a/tests/integration/targets/docker_container/tasks/main.yml +++ b/tests/integration/targets/docker_container/tasks/main.yml @@ -4,6 +4,19 @@ # and should not be used as examples of how to write Ansible roles # #################################################################### +- name: Gather facts on controller + setup: + gather_subset: '!all' + delegate_to: localhost + delegate_facts: true + run_once: true + +- name: Make sure ipaddress is available on controller + pip: + name: ipaddress + delegate_to: localhost + when: hostvars['localhost'].ansible_facts.python.version.major < 3 + # Create random name prefix (for containers, networks, ...) - name: Create random container name prefix set_fact: