From 648e0652d54c47633d66f00ee032cadc0ee8a06e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 20 Jan 2024 14:06:29 +0100 Subject: [PATCH] mac_address no longer works with Docker API v1.44+. (#764) --- plugins/modules/docker_container.py | 1 + .../docker_container/tasks/tests/options.yml | 82 ++++++++++--------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index 5590483a4..7135f5943 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -524,6 +524,7 @@ mac_address: description: - Container MAC address (for example, V(92:d0:c6:0a:29:33)). + - Note that the global container-wide MAC address is deprecated and no longer used since Docker API version 1.44. type: str memory: description: diff --git a/tests/integration/targets/docker_container/tasks/tests/options.yml b/tests/integration/targets/docker_container/tasks/tests/options.yml index 9766d0688..b6b35706e 100644 --- a/tests/integration/targets/docker_container/tasks/tests/options.yml +++ b/tests/integration/targets/docker_container/tasks/tests/options.yml @@ -3010,46 +3010,48 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau ## mac_address ##################################################### #################################################################### -- name: mac_address - docker_container: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - name: "{{ cname }}" - mac_address: 92:d0:c6:0a:29:33 - state: started - register: mac_address_1 - -- name: mac_address (idempotency) - docker_container: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - name: "{{ cname }}" - mac_address: 92:d0:c6:0a:29:33 - state: started - register: mac_address_2 - -- name: mac_address (change) - docker_container: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - name: "{{ cname }}" - mac_address: 92:d0:c6:0a:29:44 - state: started - force_kill: true - register: mac_address_3 - -- name: cleanup - docker_container: - name: "{{ cname }}" - state: absent - force_kill: true - diff: false - -- assert: - that: - - mac_address_1 is changed - - mac_address_2 is not changed - - mac_address_3 is changed +- when: docker_api_version is version('1.44', '<') + block: + - name: mac_address + docker_container: + image: "{{ docker_test_image_alpine }}" + command: '/bin/sh -c "sleep 10m"' + name: "{{ cname }}" + mac_address: 92:d0:c6:0a:29:33 + state: started + register: mac_address_1 + + - name: mac_address (idempotency) + docker_container: + image: "{{ docker_test_image_alpine }}" + command: '/bin/sh -c "sleep 10m"' + name: "{{ cname }}" + mac_address: 92:d0:c6:0a:29:33 + state: started + register: mac_address_2 + + - name: mac_address (change) + docker_container: + image: "{{ docker_test_image_alpine }}" + command: '/bin/sh -c "sleep 10m"' + name: "{{ cname }}" + mac_address: 92:d0:c6:0a:29:44 + state: started + force_kill: true + register: mac_address_3 + + - name: cleanup + docker_container: + name: "{{ cname }}" + state: absent + force_kill: true + diff: false + + - assert: + that: + - mac_address_1 is changed + - mac_address_2 is not changed + - mac_address_3 is changed #################################################################### ## memory ##########################################################