docker_node: labels operation fails when parameter 'labels' is None (#52662)
* docker_node: Fix for situation where labels parameter is None * docker_node: Fix for situation where labels parameter is None and labels are not removed
This commit is contained in:
parent
6f91bccf78
commit
67f14772b1
1 changed files with 11 additions and 6 deletions
|
@ -229,15 +229,20 @@ class SwarmNodeManager(DockerBaseClass):
|
|||
|
||||
if self.parameters.labels_to_remove is not None:
|
||||
for key in self.parameters.labels_to_remove:
|
||||
if not self.parameters.labels.get(key):
|
||||
if self.parameters.labels is not None:
|
||||
if not self.parameters.labels.get(key):
|
||||
if node_spec['Labels'].get(key):
|
||||
node_spec['Labels'].pop(key)
|
||||
changed = True
|
||||
else:
|
||||
self.client.module.warn(
|
||||
"Label '%s' listed both in 'labels' and 'labels_to_remove'. "
|
||||
"Keeping the assigned label value."
|
||||
% to_native(key))
|
||||
else:
|
||||
if node_spec['Labels'].get(key):
|
||||
node_spec['Labels'].pop(key)
|
||||
changed = True
|
||||
else:
|
||||
self.client.module.warn(
|
||||
"Label '%s' listed both in 'labels' and 'labels_to_remove'. "
|
||||
"Keeping the assigned label value."
|
||||
% to_native(key))
|
||||
|
||||
if changed is True:
|
||||
if not self.check_mode:
|
||||
|
|
Loading…
Reference in a new issue