[stable-2.11] Fix ansible-test docker container IP detection..

(cherry picked from commit 14ff5e213c)

Co-authored-by: Matt Clay <matt@mystile.com>
pull/74441/head
Matt Clay 4 years ago
parent 405da50dc7
commit 1df28faad6

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix docker container IP address detection. The ``bridge`` network is no longer assumed to be the default.

@ -112,7 +112,13 @@ def get_docker_container_ip(args, container_id):
networks = network_settings.get('Networks')
if networks:
network_name = get_docker_preferred_network_name(args) or 'bridge'
network_name = get_docker_preferred_network_name(args)
if not network_name:
# Sort networks and use the first available.
# This assumes all containers will have access to the same networks.
network_name = sorted(networks.keys()).pop(0)
ipaddress = networks[network_name]['IPAddress']
else:
# podman doesn't provide Networks, fall back to using IPAddress

Loading…
Cancel
Save