docker_container and docker_network: avoid None errors (#65018)

* Avoid None errors.

* Add changelog.
This commit is contained in:
Felix Fontein 2019-11-24 13:39:27 +01:00 committed by ansibot
parent f4d45ffdff
commit 63b94fca7e
3 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- "docker_container - fix network idempotence comparison error."
- "docker_network - fix idempotence comparison error."

View file

@ -2284,7 +2284,7 @@ class Container(DockerBaseClass):
))
else:
diff = False
network_info_ipam = network_info.get('IPAMConfig', {})
network_info_ipam = network_info.get('IPAMConfig') or {}
if network.get('ipv4_address') and network['ipv4_address'] != network_info_ipam.get('IPv4Address'):
diff = True
if network.get('ipv6_address') and network['ipv6_address'] != network_info_ipam.get('IPv6Address'):

View file

@ -562,6 +562,8 @@ class DockerNetworkManager(object):
self.results['changed'] = True
def is_container_connected(self, container_name):
if not self.existing_network:
return False
return container_name in container_names_in_network(self.existing_network)
def connect_containers(self):