Felix Fontein
4bab9a6b0e
Fix idempotency of docker_compose_v2_pull. ( #814 )
2024-03-13 13:20:11 +01:00
Felix Fontein
6aea7efed9
Improve parsing of warnings and errors ( #811 )
...
* Add logfmt message parser.
* Parse logfmt formatted warnings.
* Follow-up for #810 .
* Fix handling of warning and error messages.
* Make Python 2 compatible.
* Linting. Improving tests.
2024-03-03 13:38:55 +00:00
Felix Fontein
37e28b62d3
Do not fail on non-fatal errors. ( #810 )
2024-02-28 21:43:30 +01:00
Felix Fontein
45d32d53c9
Do not consider 'Waiting' events as changes/actions. ( #804 )
2024-02-23 19:58:40 +01:00
Felix Fontein
6f5d67860c
docker_compose_v2: ignore some pull events ( #803 )
...
* Ignore some pull events.
* Adjust tests.
2024-02-23 18:24:16 +01:00
Felix Fontein
6366464812
docker_container: allow pull=never, and make check mode behavior configurable ( #797 )
...
* Allow to configure behavior of pull=true in check mode.
* Change pull to option that accepts some strings as well, such as pull=never.
* Adjust values.
2024-02-14 22:49:22 +01:00
Felix Fontein
7b554082ea
Improve parsing. ( #786 )
2024-02-01 17:52:31 +00:00
Felix Fontein
b5d085bb88
Parse build events from stderr. ( #779 )
2024-01-25 06:40:32 +01:00
Felix Fontein
eebb73a503
docker_compose_v2: add files option ( #775 )
...
* Add files option.
* Shorten lines.
2024-01-24 07:15:00 +01:00
Felix Fontein
b2a79d9eb7
Add docker_image_export module ( #774 )
...
* Add docker_image_export module.
* Add basic tests.
* Add more seealsos.
2024-01-22 22:03:38 +01:00
Felix Fontein
fcf608b334
Add networks[].mac_address option. ( #763 )
2024-01-20 14:23:12 +01:00
Felix Fontein
ac41379119
Fix archive idempotency. ( #765 )
2024-01-20 14:12:55 +01:00
Felix Fontein
6082efc855
Improve docs sharing for docker_compose_v2* modules; fix examples and return docs for docker_compose_v2_pull ( #761 )
...
* Move more common documentation to docs fragment.
* Fix examples and return values for docker_compose_v2_pull.
* Remove ignore.
2024-01-17 07:53:44 +01:00
Felix Fontein
ab73061a5f
Also check for compose.yaml and compose.yml, and do not require the Compose file to be an actual file. ( #759 )
2024-01-16 19:03:29 +01:00
Felix Fontein
307dc4045a
Add docker_compose_v2_pull module ( #751 )
...
* Add docker_compose_v2_pull module.
* Improve and extend parsing of events.
* Add ignores.
* --policy is only available since Compose 2.22.0.
2024-01-13 14:36:26 +01:00
Felix Fontein
8ca5e2f810
Extract more common code and docs fragment for Docker Compose. ( #748 )
2024-01-07 18:17:10 +01:00
Felix Fontein
cb4dd2fed1
docker_compose_v2: move some code to module_utils ( #747 )
...
* Move some code to module_utils.
* Add unit tests.
Test cases are auto-generated from integration test logs.
* Rename ResourceEvent → Event.
2024-01-07 16:17:31 +01:00
Felix Fontein
4a5293503e
Rename ca_cert option to ca_path ( #744 )
...
* Rename ca_cert option to ca_path.
* Two more.
2024-01-06 17:03:39 +01:00
Felix Fontein
762ce3e1cf
Remove 'debug' parameter from new CLI modules. Move log writing to single function. ( #740 )
2024-01-02 21:10:59 +01:00
Felix Fontein
2caa77c032
Remove superfluous timeout argument. ( #737 )
2024-01-02 14:05:27 +01:00
Felix Fontein
ce7402dc9f
Add docker_image_build module. ( #735 )
2024-01-02 09:21:45 +01:00
Felix Fontein
199d9e50d3
Fix Unix socket path. ( #736 )
2024-01-01 22:53:58 +01:00
Felix Fontein
c4c347c626
Add proper platform handling. ( #705 )
2023-12-10 09:03:32 +01:00
Felix Fontein
b3ef5f5196
Clean up vendored Docker SDK for Python TLS handling code. ( #722 )
2023-12-09 23:19:36 +01:00
Felix Fontein
26772304f9
Do not accept tls_hostname for Docker SDK for Python 7.0.0+. ( #721 )
2023-12-09 23:16:03 +01:00
Felix Fontein
3aa1ddcca0
Docker SDK for Python 7+: make sure that ssl_version is not passed, and error out if it was explicitly set ( #715 )
...
* Do not accept ssl_version for Docker SDK for Python 7.0.0+.
* Add changelog fragment.
* Generally avoid sending None values to TLSConfig. Potentially prevents similar errors in the future, assuming the users do not pass values in.
* Python 2.6 compatibility.
2023-12-09 17:59:06 +00:00
Felix Fontein
907dc28f73
Deprecate default 'ignore' of 'image_name_mismatch'. ( #703 )
2023-12-07 12:32:50 +01:00
Felix Fontein
d8cef6c71e
docker_container: refactoring preparing better comparisons ( #713 )
...
* Always get the container's image as well to allow get_value() to use that one too.
* Allow options and engines to overwrite comparison functions.
* Do not fail if image (by ID) cannot be found.
* Allow to control when container image is needed.
* Pass option to compare function.
* Allow to pass the host info for retrieving a value.
* Add changelog fragment.
2023-12-05 07:26:11 +01:00
Felix Fontein
1c66f880ee
Fix typos, improve markup, improve scenario guide ( #699 )
...
* Fix typos.
* Improve markup.
* Mention missing 'new' modules in scenario guide.
2023-10-29 08:30:24 +01:00
Felix Fontein
4d9b85c975
Update vendored Docker SDK for Python code ( #694 )
...
* vendored Docker SDK for Python code: volume: added support for bind propagation
https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation
Cherry-picked from https://github.com/docker/docker-py/commit/bea63224e028226085c85caecace6480fe0aa6b0
Co-authored-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de >
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
* vendored Docker SDK for Python code: fix: eventlet compatibility
Check if poll attribute exists on select module instead of win32 platform check
The implementation done in #2865 is breaking usage of docker-py library within eventlet.
As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll ) and eventlet select removal advice (eventlet/eventlet#608 (comment)), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`.
Fixes https://github.com/docker/docker-py/issues/3131
Cherry-picked from https://github.com/docker/docker-py/commit/78439ebbe1aae77ff0fd9b666894d80807182e28
Co-authored-by: Mathieu Virbel <mat@meltingrocks.com >
* vendored Docker SDK for Python code: fix: use response.text to get string rather than bytes
Adjusted from https://github.com/docker/docker-py/commit/0618951093bf3116af482c6dfb983219c5684343
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com >
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
* vendored Docker SDK for Python code: Fix missing asserts or assignments
Cherry-picked from https://github.com/docker/docker-py/commit/0566f1260cd6f89588df2128ec4e86e8266e5d74
Co-authored-by: Aarni Koskela <akx@iki.fi >
---------
Co-authored-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de >
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
Co-authored-by: Mathieu Virbel <mat@meltingrocks.com >
Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com >
Co-authored-by: Aarni Koskela <akx@iki.fi >
2023-10-08 18:16:27 +02:00
Felix Fontein
1660bf4104
vendored Docker SDK for Python code: update to latest version ( #619 )
...
* socket: fix for errors on pipe close in Windows (https://github.com/docker/docker-py/pull/3099 )
Need to return data, not size. By returning an empty
string, EOF will be detected properly since `len()`
will be `0`.
Fixes https://github.com/docker/docker-py/issues/3098 .
Cherry-picked from https://github.com/docker/docker-py/commit/f84623225e0227adde48ffd8f2e1cafb1f9aa38d
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
* socket: use poll() instead of select() except on Windows (https://github.com/docker/docker-py/pull/2865 )
Fixes https://github.com/docker/docker-py/issues/2278 , which was originally addressed in https://github.com/docker/docker-py/pull/2279 , but was not
properly merged. Additionally it did not address the problem
of poll not existing on Windows. This patch falls back on the
more limited select method if host system is Windows.
Cherry-picked from https://github.com/docker/docker-py/commit/a02ba743338c27fd9348af2cf7767b140501734d
Co-authored-by: Tyler Westland <tylerofthewest@gmail.com >
* api: respect timeouts on Windows named pipes (https://github.com/docker/docker-py/pull/3112 )
Cherry-picked from https://github.com/docker/docker-py/commit/9cadad009e6aa78e15d752e2011705d7d91b8d2e
Co-authored-by: Imogen <59090860+ImogenBits@users.noreply.github.com >
* Add URL to changelog.
* api: avoid socket timeouts when executing commands (https://github.com/docker/docker-py/pull/3125 )
Only listen to read events when polling a socket in order
to avoid incorrectly trying to read from a socket that is
not actually ready.
Cherry-picked from https://github.com/docker/docker-py/commit/c5e582c413a4a3a9eff6ee8208d195f657ffda94
Co-authored-by: Loïc Leyendecker <loic.leyendecker@gmail.com >
---------
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
Co-authored-by: Tyler Westland <tylerofthewest@gmail.com >
Co-authored-by: Imogen <59090860+ImogenBits@users.noreply.github.com >
Co-authored-by: Loïc Leyendecker <loic.leyendecker@gmail.com >
2023-05-20 19:35:56 +02:00
Felix Fontein
d7f7e44b9e
Make sure plugins/module_utils/socket_handler.py works when Docker SDK for Python is not installed. ( #620 )
2023-05-15 21:43:31 +02:00
Felix Fontein
245ab76b09
Warn that SSLSocket cannot send close_notify TLS alerts ( #621 )
...
* Warn that SSLSocket cannot send close_notify TLS alerts.
* Improve formulation.
Co-authored-by: Don Naro <dnaro@redhat.com >
---------
Co-authored-by: Don Naro <dnaro@redhat.com >
2023-05-15 21:41:23 +02:00
Felix Fontein
39f2e9b9c4
Make compatible with requests 2.29.0 and urllib3 2.0 ( #613 )
...
* Make compatible with requests 2.29.0.
* This fix should also work with urllib3 2.0 according to urllib3 maintainer.
* Add changelog fragment.
* We still need the constraint for CI until Docker SDK for Python has a new release with a fix.
* Make modifications to response_class as small as possible.
* Revert "We still need the constraint for CI until Docker SDK for Python has a new release with a fix."
This reverts commit 698d544a1e08308e8bf8b4e56ab78c5079f9a17b.
* The pip coming with the ansible-core 2.11 alpine3 image seems to be too old.
2023-05-05 22:09:02 +02:00
Felix Fontein
a426232523
Fix imports. ( #585 )
2023-02-12 22:09:02 +01:00
Felix Fontein
983b2b4783
exec: fix file handle leak with container.exec_* APIs ( https://github.com/docker/docker-py/pull/2320 ) ( #582 )
...
Requests with stream=True MUST be closed or else the connection will
never be returned to the connection pool. Both ContainerApiMixin.attach
and ExecApiMixin.exec_start were leaking in the stream=False case.
exec_start was modified to follow attach for the stream=True case as
that allows the caller to close the stream when done (untested).
Tested with:
# Test exec_run (stream=False) - observe one less leak
make integration-test-py3 file=models_containers_test.py' -k test_exec_run_success -vs -W error::ResourceWarning'
# Test exec_start (stream=True, fully reads from CancellableStream)
make integration-test-py3 file=api_exec_test.py' -k test_execute_command -vs -W error::ResourceWarning'
After this change, one resource leak is removed, the remaining resource
leaks occur because none of the tests call client.close().
Fixes https://github.com/docker/docker-py/issues/1293
(Regression from https://github.com/docker/docker-py/pull/1130 )
Cherry-picked from https://github.com/docker/docker-py/commit/34e6829dd40e99e9ba47ea02fcfabda09e08d36e
Co-authored-by: Peter Wu <pwu@cloudflare.com >
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
2023-02-12 08:29:28 +01:00
Kristof Mattei
d2f551fc5d
fix: fix tmpfs_size and tmpfs_mode not being set ( #580 )
...
* fix: fix tmpfs_size and tmpfs_mode not being set
* fix: wrong file
* fix: add changelog fragment
* fix: update changelog fragment to match formatting
Co-authored-by: Felix Fontein <felix@fontein.de >
---------
Co-authored-by: Felix Fontein <felix@fontein.de >
2023-02-10 14:05:09 +01:00
Felix Fontein
54a3dc151d
Remove unneccessary imports ( #575 )
...
* Remove unneccessary imports.
* Add noqas.
2023-02-09 15:25:45 +01:00
Felix Fontein
4e6ac335f3
Improve envvar fallback handling. ( #554 )
2023-01-13 06:37:04 +01:00
Felix Fontein
e198e4ab43
Add docker_container_copy_into module ( #545 )
...
* Move copying functionality to module_utils.
* Add docker_container_copy_into module.
* Use new module in other tests.
* Fix copyright and attributes.
* Improve idempotency, improve stat code.
* Document and test when a stopped container works.
* Improve owner/group detection error handling when container is stopped.
* Fix formulation.
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com >
* Improve file comparison.
* Avoid reading whole file at once.
* Stream when fetching files from daemon.
* Fix comment.
* Use read() instead of read1().
* Stream files when copying into container.
* Linting.
* Add force parameter.
* Simplify library code.
* Linting.
* Add content and content_is_b64 options.
* Make force=false work as for copy module: only copy if the destination does not exist.
* Improve docs.
* content should be no_log.
* Implement diff mode.
* Improve error handling.
* Lint and improve.
* Set owner/group ID to avoid ID lookup (which fails in paused containers).
* Apply suggestions from code review
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com >
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com >
2023-01-09 11:52:29 +01:00
Felix Fontein
3a40112a76
Remove timeout when waiting for container to finish. ( #527 )
2022-12-08 22:15:42 +01:00
Felix Fontein
2957138153
latest docker-py bugfix (npipe) ( #513 )
...
* socket: handle npipe close on Windows (https://github.com/docker/docker-py/pull/3056 )
Fixes https://github.com/docker/docker-py/issues/3045
Cherry-picked from https://github.com/docker/docker-py/commit/30022984f6445fbc322cbe97bb99aab1ddb1e4fd
Co-authored-by: Nick Santos <nick.santos@docker.com >
* Add changelog fragment.
Co-authored-by: Nick Santos <nick.santos@docker.com >
2022-12-01 06:59:05 +01:00
iamjpotts
166d485216
Make image archive/save idempotent, using image id and repo tags as keys ( #500 )
2022-11-30 23:45:36 +01:00
Felix Fontein
edf0d3ec99
Make kill_signal accept strings. ( #506 )
2022-11-28 22:10:07 +01:00
Felix Fontein
5b31f17016
Add image_name_mismatch option. ( #488 )
2022-11-01 19:48:58 +00:00
Felix Fontein
51d5744cb0
docker_container: deprecate ignore_image and purge_networks ( #487 )
...
* Deprecate ignore_image and purge_networks.
* Fix YAML.
* Simple replacement doesn't work in this case.
2022-11-01 19:57:56 +01:00
Felix Fontein
f7cf12555c
docker_container: fix env_file option ( #452 )
...
* Add better tests for env and env_file.
* Make sure that non-container options are also passed to preprocessing code.
* Add changelog fragment.
* Add env_file override test.
2022-08-15 07:45:59 +02:00
Felix Fontein
74134eda33
Fix docker_container tests ( #441 )
...
* Add diff output to figure out a bit more why the test fails.
* Make sure that both images have been pulled in advance.
* Dump the correct image.
* Allow tty test to fail in certain circumstances.
2022-08-08 23:23:23 +02:00
Felix Fontein
1e4633a606
For Python > 2, always use shutil.which instead of custom Windows helper code. ( #438 )
...
This is related to
https://github.com/docker/docker-py/commit/42789818bed5d86b487a030e2e60b02bf0cfa284
in the sense that for Python > 2, we also exclusively use shutil.which now,
but we do not remove the helper function since we need it for Python 2 on Windows.
Co-authored-by: Daniel Möller <n1ngu@riseup.net >
Co-authored-by: Daniel Möller <n1ngu@riseup.net >
2022-08-08 20:58:12 +02:00
Felix Fontein
ae708a7333
Vendored Docker SDK for Python updates ( #434 )
...
* utils: fix IPv6 address w/ port parsing
This was using a deprecated function (`urllib.splitnport`),
ostensibly to work around issues with brackets on IPv6 addresses.
Ironically, its usage was broken, and would result in mangled IPv6
addresses if they had a port specified in some instances.
Usage of the deprecated function has been eliminated and extra test
cases added where missing. All existing cases pass as-is. (The only
other change to the test was to improve assertion messages.)
Cherry-picked from
https://github.com/docker/docker-py/commit/f16c4e1147c81afd822fe72191f0f720cb0ba637
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
* client: fix exception semantics in _raise_for_status
We want "The above exception was the direct cause of the following exception:" instead of "During handling of the above exception, another exception occurred:"
Cherry-picked from
https://github.com/docker/docker-py/commit/bb11197ee3407798a53c50e43aa994fe8cd9c8e7
Co-authored-by: Maor Kleinberger <kmaork@gmail.com >
* tls: use auto-negotiated highest version
Specific TLS versions are deprecated in latest Python, which
causes test failures due to treating deprecation errors as
warnings.
Luckily, the fix here is straightforward: we can eliminate some
custom version selection logic by using `PROTOCOL_TLS_CLIENT`,
which is the recommended method and will select the highest TLS
version supported by both client and server.
Cherry-picked from
https://github.com/docker/docker-py/commit/56dd6de7dfad9bedc7c8af99308707ecc3fad78e
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
* transport: fix ProxyCommand for SSH conn
Cherry-picked from
https://github.com/docker/docker-py/commit/4e19cc48dfd88d0a9a8bdbbe4df4357322619d02
Co-authored-by: Guy Lichtman <glicht@users.noreply.github.com >
* ssh: do not create unnecessary subshell on exec
Cherry-picked from
https://github.com/docker/docker-py/commit/bb40ba051fc67605d5c9e7fd1eb5f9aa3e0fb501
Co-authored-by: liubo <liubo@uniontech.com >
* ssh: reject unknown host keys when using Python SSH impl
In the Secure Shell (SSH) protocol, host keys are used to verify the identity of remote hosts. Accepting unknown host keys may leave the connection open to man-in-the-middle attacks.
Do not accept unknown host keys. In particular, do not set the default missing host key policy for the Paramiko library to either AutoAddPolicy or WarningPolicy. Both of these policies continue even when the host key is unknown. The default setting of RejectPolicy is secure because it throws an exception when it encounters an unknown host key.
Reference: https://cwe.mitre.org/data/definitions/295.html
NOTE: This only affects SSH connections using the native Python SSH implementation (Paramiko), when `use_ssh_client=False` (default). If using the system SSH client (`use_ssh_client=True`), the host configuration
(e.g. `~/.ssh/config`) will apply.
Cherry-picked from
https://github.com/docker/docker-py/commit/d9298647d91c52e1ee9ac448e43a7fea1c69bdbe
Co-authored-by: Audun Nes <audun.nes@gmail.com >
* lint: fix deprecation warnings from threading package
Set `daemon` attribute instead of using `setDaemon` method that
was deprecated in Python 3.10.
Cherry-picked from
https://github.com/docker/docker-py/commit/adf5a97b1203623ae47bf7aa1367b6bb7c261980
Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com >
* api: preserve cause when re-raising error
Use `from e` to ensure that the error context is propagated
correctly.
Cherry-picked from
https://github.com/docker/docker-py/commit/05e143429e892fb838bbff058391456ba3d0a19c
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
* build: trim trailing whitespace from dockerignore entries
Cherry-picked from
https://github.com/docker/docker-py/commit/3ee3a2486fe75ed858f8a3defe0fc79b2743d5df
Co-authored-by: Clément Loiselet <clement.loiselet@capgemini.com >
* Improve formulation, also mention the security change as a breaking change.
Co-authored-by: Milas Bowman <milas.bowman@docker.com >
Co-authored-by: Maor Kleinberger <kmaork@gmail.com >
Co-authored-by: Guy Lichtman <glicht@users.noreply.github.com >
Co-authored-by: liubo <liubo@uniontech.com >
Co-authored-by: Audun Nes <audun.nes@gmail.com >
Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com >
Co-authored-by: Clément Loiselet <clement.loiselet@capgemini.com >
2022-07-31 17:09:18 +02:00