From 3ff86a5cad21e9c79b2463075c1bc06418f03225 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 9 Dec 2019 13:39:02 +0100 Subject: [PATCH] docker_* modules: fix various errors in argument specs (#65632) * Fix various errors in docker module argument specs. * Adjust PR #. * Fix option name. * Fix username/password requirements for docker_login. (cherry picked from commit e9cec0262dfceed3d7cb212d7c831e4fd827b647) --- changelogs/fragments/65632-docker-argspec-fixup.yml | 3 +++ lib/ansible/modules/cloud/docker/docker_image.py | 2 +- lib/ansible/modules/cloud/docker/docker_image_info.py | 2 +- lib/ansible/modules/cloud/docker/docker_login.py | 10 ++++------ lib/ansible/modules/cloud/docker/docker_stack.py | 2 +- lib/ansible/modules/cloud/docker/docker_swarm.py | 1 - .../modules/cloud/docker/docker_swarm_service.py | 3 --- .../targets/docker_image/tasks/tests/options.yml | 2 +- 8 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 changelogs/fragments/65632-docker-argspec-fixup.yml diff --git a/changelogs/fragments/65632-docker-argspec-fixup.yml b/changelogs/fragments/65632-docker-argspec-fixup.yml new file mode 100644 index 00000000000..a9742610248 --- /dev/null +++ b/changelogs/fragments/65632-docker-argspec-fixup.yml @@ -0,0 +1,3 @@ +bugfixes: +- "docker_image - fix validation of build options." +- "docker_login - fix error handling when ``username`` or ``password`` is not specified when ``state`` is ``present``." diff --git a/lib/ansible/modules/cloud/docker/docker_image.py b/lib/ansible/modules/cloud/docker/docker_image.py index f8cfa6e8b2c..e8e2be91849 100644 --- a/lib/ansible/modules/cloud/docker/docker_image.py +++ b/lib/ansible/modules/cloud/docker/docker_image.py @@ -808,7 +808,7 @@ class ImageManager(DockerBaseClass): def main(): argument_spec = dict( source=dict(type='str', choices=['build', 'load', 'pull', 'local']), - build=dict(type='dict', suboptions=dict( + build=dict(type='dict', options=dict( cache_from=dict(type='list', elements='str'), container_limits=dict(type='dict', options=dict( memory=dict(type='int'), diff --git a/lib/ansible/modules/cloud/docker/docker_image_info.py b/lib/ansible/modules/cloud/docker/docker_image_info.py index f3c3b79ccb3..57912f961ac 100644 --- a/lib/ansible/modules/cloud/docker/docker_image_info.py +++ b/lib/ansible/modules/cloud/docker/docker_image_info.py @@ -37,9 +37,9 @@ options: - An image name or a list of image names. Name format will be C(name[:tag]) or C(repository/name[:tag]), where C(tag) is optional. If a tag is not provided, C(latest) will be used. Instead of image names, also image IDs can be used. + - If no name is provided, a list of all images will be returned. type: list elements: str - required: yes extends_documentation_fragment: - docker diff --git a/lib/ansible/modules/cloud/docker/docker_login.py b/lib/ansible/modules/cloud/docker/docker_login.py index 8a2377322c2..85dfbd8bee7 100644 --- a/lib/ansible/modules/cloud/docker/docker_login.py +++ b/lib/ansible/modules/cloud/docker/docker_login.py @@ -28,7 +28,6 @@ description: - Running in check mode will perform the authentication without updating the config file. options: registry_url: - required: False description: - The registry URL. type: str @@ -38,16 +37,15 @@ options: - url username: description: - - The username for the registry account + - The username for the registry account. + - Required when I(state) is C(present). type: str - required: yes password: description: - - The plaintext password for the registry account + - The plaintext password for the registry account. + - Required when I(state) is C(present). type: str - required: yes email: - required: False description: - "The email address for the registry account." type: str diff --git a/lib/ansible/modules/cloud/docker/docker_stack.py b/lib/ansible/modules/cloud/docker/docker_stack.py index 4f38cc8aa1f..ea1042dc80d 100644 --- a/lib/ansible/modules/cloud/docker/docker_stack.py +++ b/lib/ansible/modules/cloud/docker/docker_stack.py @@ -215,7 +215,7 @@ def main(): 'prune': dict(type='bool', default=False), 'with_registry_auth': dict(type='bool', default=False), 'resolve_image': dict(type='str', choices=['always', 'changed', 'never']), - 'state': dict(tpye='str', default='present', choices=['present', 'absent']), + 'state': dict(type='str', default='present', choices=['present', 'absent']), 'absent_retries': dict(type='int', default=0), 'absent_retries_interval': dict(type='int', default=1) }, diff --git a/lib/ansible/modules/cloud/docker/docker_swarm.py b/lib/ansible/modules/cloud/docker/docker_swarm.py index 304c2b12b85..4fd4c875c41 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm.py @@ -76,7 +76,6 @@ options: Note that removing requires Docker SDK for Python >= 2.4.0. - Set to C(inspect) to display swarm informations. type: str - required: yes default: present choices: - present diff --git a/lib/ansible/modules/cloud/docker/docker_swarm_service.py b/lib/ansible/modules/cloud/docker/docker_swarm_service.py index 8330e5a3bc8..359f84972e6 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm_service.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm_service.py @@ -55,7 +55,6 @@ options: description: - Name of the file containing the config. Defaults to the I(config_name) if not specified. type: str - required: yes uid: description: - UID of the config file's owner. @@ -194,7 +193,6 @@ options: - Service image path and tag. - Corresponds to the C(IMAGE) parameter of C(docker service create). type: str - required: yes labels: description: - Dictionary of key value pairs. @@ -640,7 +638,6 @@ options: - C(present) - Asserts the existence of a service matching the name and provided configuration parameters. Unspecified configuration parameters will be set to docker defaults. type: str - required: yes default: present choices: - present diff --git a/test/integration/targets/docker_image/tasks/tests/options.yml b/test/integration/targets/docker_image/tasks/tests/options.yml index 1ff729c6fae..8f72bd0abd6 100644 --- a/test/integration/targets/docker_image/tasks/tests/options.yml +++ b/test/integration/targets/docker_image/tasks/tests/options.yml @@ -276,7 +276,7 @@ name: "{{ iname }}" build: path: "{{ role_path }}/files" - dockefile: "EtcHostsDockerfile" + dockerfile: "EtcHostsDockerfile" pull: no etc_hosts: some-custom-host: "127.0.0.1"