mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-27 04:41:26 -07:00
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,6 +229,7 @@ class SwarmNodeManager(DockerBaseClass):
|
||||||
|
|
||||||
if self.parameters.labels_to_remove is not None:
|
if self.parameters.labels_to_remove is not None:
|
||||||
for key in self.parameters.labels_to_remove:
|
for key in self.parameters.labels_to_remove:
|
||||||
|
if self.parameters.labels is not None:
|
||||||
if not self.parameters.labels.get(key):
|
if not self.parameters.labels.get(key):
|
||||||
if node_spec['Labels'].get(key):
|
if node_spec['Labels'].get(key):
|
||||||
node_spec['Labels'].pop(key)
|
node_spec['Labels'].pop(key)
|
||||||
|
@ -238,6 +239,10 @@ class SwarmNodeManager(DockerBaseClass):
|
||||||
"Label '%s' listed both in 'labels' and 'labels_to_remove'. "
|
"Label '%s' listed both in 'labels' and 'labels_to_remove'. "
|
||||||
"Keeping the assigned label value."
|
"Keeping the assigned label value."
|
||||||
% to_native(key))
|
% to_native(key))
|
||||||
|
else:
|
||||||
|
if node_spec['Labels'].get(key):
|
||||||
|
node_spec['Labels'].pop(key)
|
||||||
|
changed = True
|
||||||
|
|
||||||
if changed is True:
|
if changed is True:
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue