diff --git a/changelogs/fragments/43-docker_container-device_requests.yml b/changelogs/fragments/43-docker_container-device_requests.yml new file mode 100644 index 000000000..4c2a805ac --- /dev/null +++ b/changelogs/fragments/43-docker_container-device_requests.yml @@ -0,0 +1,2 @@ +bugfixes: +- "docker_container - the validation for ``capabilities`` in ``device_requests`` was incorrect (https://github.com/ansible-collections/community.docker/issues/42, https://github.com/ansible-collections/community.docker/pull/43)." diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index bbaece574..f9e42f2e5 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -1438,13 +1438,12 @@ def __init__(self, client): # Make sure that capabilities are lists of lists of strings if dr['capabilities']: for or_index, or_list in enumerate(dr['capabilities']): - for and_index, and_list in enumerate(or_list): - for term_index, term in enumerate(and_list): - if not isinstance(term, string_types): - self.fail( - "device_requests[{0}].capabilities[{1}][{2}][{3}] is not a string".format( - dr_index, or_index, and_index, term_index)) - and_list[term_index] = to_native(term) + for and_index, and_term in enumerate(or_list): + if not isinstance(and_term, string_types): + self.fail( + "device_requests[{0}].capabilities[{1}][{2}] is not a string".format( + dr_index, or_index, and_index)) + or_list[and_index] = to_native(and_term) # Make sure that options is a dictionary mapping strings to strings if dr['options']: dr['options'] = clean_dict_booleans_for_docker_api(dr['options'])