Commit Graph

180 Commits

Author SHA1 Message Date
Felix Fontein
d8297df7d0
Fix docker_image's build.args (#456)
* Add tests for build.args.

* Fix bug: store build args in correct dict

* Add changelog fragment.

* Update copyright notice.
2022-08-16 22:37:51 +02:00
Felix Fontein
ad05773e34
Fix docs fragment. (#460) 2022-08-16 21:54:56 +02:00
Felix Fontein
b720c8f486
Forgot to update copied version of deprecation notice. (#453) 2022-08-15 08:01:42 +02: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
a50257381f
Fix docker_plugin crash when handling plugin options (#447)
* Fix docker_plugin crash when handling plugin options.

* Try to add tests.
2022-08-12 19:29:45 +02:00
Felix Fontein
f513ba2c59
Fix error formatting bug. (#448) 2022-08-12 13:53:59 +02:00
Felix Fontein
be58ccc13f
Normalize booleans in all other plugins and modules. (#440) 2022-08-10 21:25:10 +02:00
Felix Fontein
1bf8da2390
Normalize booleans in docker_container docs. (#439) 2022-08-09 18:32:05 +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
42789818be
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
bc6757d3b8
Fix docs. (#436) 2022-08-04 14:23:52 +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
f16c4e1147

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
bb11197ee3

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
56dd6de7df

Co-authored-by: Milas Bowman <milas.bowman@docker.com>

* transport: fix ProxyCommand for SSH conn

Cherry-picked from
4e19cc48df

Co-authored-by: Guy Lichtman <glicht@users.noreply.github.com>

* ssh: do not create unnecessary subshell on exec

Cherry-picked from
bb40ba051f

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
d9298647d9

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
adf5a97b12

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
05e143429e

Co-authored-by: Milas Bowman <milas.bowman@docker.com>

* build: trim trailing whitespace from dockerignore entries

Cherry-picked from
3ee3a2486f

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
Felix Fontein
9c5d562c0e
Fix bug when TLS is used (#432)
* Fix bug when TLS is used.

* Add HTTP/HTTPS connection test.
2022-07-26 08:25:53 +02:00
Felix Fontein
a4539a309e
Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#430)
* Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml.

* ignore.txt lines cannot be empty or contain only a comment.

* Cleanup.

* This particular __init__.py seems to be crucial.

* Try extra newline.

* Markdown comments are a real mess. I hope this won't break Galaxy...

* More licenses.

* Add sanity test.

* Skip some files, lint.

* Make sure there is a copyright line everywhere.

* Also check for copyright line in sanity tests.

* Remove colon after 'Copyright'.

* Normalize lint script.

* Avoid colon after 'Copyright' in lint script.

* Improve license checker.

* Update README.md

Co-authored-by: Maxwell G <9920591+gotmax23@users.noreply.github.com>

* Remove superfluous space.

* Referencing target instead of symlink

Co-authored-by: Maxwell G <9920591+gotmax23@users.noreply.github.com>
2022-07-20 07:45:33 +02:00
Felix Fontein
e26890a909
Implement platform parameter for docker_container, first version. (#426) 2022-07-15 17:14:57 +02:00
Felix Fontein
5d0a036819
docker_container: add image_comparison parameter (#428)
* Add image_comparison parameter.

* Forgot version_added.
2022-07-15 17:14:40 +02:00
Felix Fontein
37c868e192
Add support for cgroupns_mode parameter. (#427) 2022-07-15 17:14:23 +02:00
Felix Fontein
77e63e2cca
Rewrite docker_container to use Docker API directly (#422)
* Begin experiments for docker_container rewrite.

* Continued.

* We support API >= 1.25 only anyway.

* Continued.

* Fix bugs.

* Complete first basic implementation.

* Continuing.

* Improvements and fixes.

* Continuing.

* More 'easy' options.

* More options.

* Work on volumes and mounts.

* Add more options.

* The last option.

* Copy over.

* Fix exposed ports.

* Fix bugs.

* Fix command and entrypoint.

* More fixes.

* Fix more bugs.

* ci_complete

* Lint, fix Python 2.7 bugs, work around ansible-test bug.

ci_complete

* Remove no longer applicable test.

ci_complete

* Remove unnecessary ignore.

ci_complete

* Start with engine driver.

* Refactoring.

* Avoid using anything Docker specific from self.client.

* Refactor.

* Add Python 2.6 ignore.txt entries for ansible-core < 2.12.

* Improve healthcheck handling.

* Fix container removal logic.

* ci_complete

* Remove handling of older Docker SDK for Pyhon versions from integration tests.

* Avoid recreation if a pure update is possible without losing the diff data.

* Cover the case that blkio_weight does not work.

* Update plugins/module_utils/module_container/docker_api.py

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Improve memory_swap tests.

* Fix URLs in changelog fragment.

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
2022-07-15 07:24:14 +02:00
Felix Fontein
04121b5882
Rewrite docker_plugin to not use the Docker SDK for Python (#429)
* Rewrite the docker_plugin module to use the low-level client from Docker SDK for Python.

* Rewrite to no longer use the Docker SDK for Python.

* Remove Docker SDK for Python version from tests.
2022-07-14 16:29:37 +02:00
Felix Fontein
58211153db
Improve README (#418)
* List missing plugins.

* Fix short description.

* Improve section on requirements.

* Apply suggestions from code review

Co-authored-by: Don Naro <dnaro@redhat.com>

Co-authored-by: Don Naro <dnaro@redhat.com>
2022-07-07 13:56:48 +02:00
Felix Fontein
da9252a67e
Rewrite the docker_api connection plugin (#414)
* Rewrite the docker_api connection plugin.

* Improve formulation.

* Improve error messages.
2022-07-06 21:48:55 +02:00
Felix Fontein
23a90668c9
Rewrite the docker_containers inventory plugin (#413)
* Rewrite the docker_containers inventory plugin.

* Improve error messages.
2022-07-06 21:48:32 +02:00
Felix Fontein
c3a76007d0
Rewrite the docker_volume_info module (#412)
* Rewrite the docker_volume_info module.

* Improve error messages.
2022-07-06 21:48:22 +02:00
Felix Fontein
6869eaf869
Rewrite the docker_volume module (#411)
* Rewrite the docker_volume module.

* Improve error messages.
2022-07-06 21:48:16 +02:00
Felix Fontein
e60ce69102
Rewrite the docker_prune module (#410)
* Rewrite the docker_prune module.

* Improve error messages.
2022-07-06 21:47:43 +02:00
Felix Fontein
18fdd04782
Rewrite the docker_network_info module (#409)
* Rewrite the docker_network_info module.

* Improve error messages.
2022-07-06 21:47:37 +02:00
Felix Fontein
4c026307fb
Rewrite the docker_network module (#408)
* Rewrite the docker_network module.

* Update plugins/modules/docker_network.py

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Improve error messages.

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
2022-07-06 21:47:32 +02:00
Felix Fontein
a406b08981
Rewrite the docker_login module (#407)
* Rewrite the docker_login module.

* Improve error messages.
2022-07-06 21:47:27 +02:00
Felix Fontein
f82c8401c2
Rewrite the docker_image_load module (#406)
* Rewrite the docker_image_load module.

* Improve error messages.
2022-07-06 21:46:19 +02:00
Felix Fontein
e4f3402035
Rewrite the docker_image_info module (#405)
* Rewrite the docker_image_info module.

* Improve error messages.
2022-07-06 21:46:14 +02:00
Felix Fontein
4f2f45b953
Rewrite the docker_image module (#404)
* Rewrite the docker_image module.

* Improve error messages.
2022-07-06 21:46:02 +02:00
Felix Fontein
9e168b75cf
Rewrite the docker_host_info module (#403)
* Rewrite the docker_host_info module.

* Improve error messages.
2022-07-06 21:45:57 +02:00
Felix Fontein
37ff980a44
Rewrite the docker_container_info module (#402)
* Rewrite the docker_container_info module.

* Improve error messages.

* Remove wrong requirement.
2022-07-06 21:45:51 +02:00
Felix Fontein
1101997844
Rewrite the docker_container_exec module (#401)
* Rewrite docker_container_exec.

* Improve error messages.
2022-07-06 21:45:44 +02:00
Felix Fontein
9e57f29b3b
Refactoring. (#415) 2022-07-03 13:28:11 +02:00
Felix Fontein
623786c659
Implement all remaining deprecations for 3.0.0 (#400)
* Remove support for Ansible 2.9 and ansible-base 2.10.

* Remove Ansible 2.9 compatiblity code.

* Remove docker-compose from EE.

* Drop support for Python 2.6. Stop advertising docker-py for Python 2.6.

* Drop support for API versions 1.20 to 1.24.

* Fix condition.
2022-07-02 17:13:53 +02:00
Felix Fontein
4d508b4c37
Vendor API connection code from Docker SDK for Python (#398)
* Vendor parts of the Docker SDK for Python

This is a combination of the latest git version
(a48a5a9647)
and the version before Python 2.7 support was removed
(650aad3a5f),
including some modifications to work with Ansible module_utils's
system (i.e. third-party imports are guarded, and errors are
reported during runtime through a new exception
MissingRequirementException).

* Create module_utils and plugin_utils for working with the vendored code.

The delete call cannot be called delete() since that method already exists from requests.

* Vendor more code from Docker SDK for Python.

* Adjust code from common module_utils.

* Add unit tests from Docker SDK for Python.

* Make test compile with Python 2.6, but skip them on Python 2.6.

* Skip test that requires a network server.

* Add changelog.

* Update changelogs/fragments/398-docker-api.yml

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Minimum API version is 1.25.

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
2022-07-02 16:40:44 +02:00
Felix Fontein
21d112bddb
Unvendor distutils.version (#271)
* Unvendor distutils.version.

* Document breaking change.

* Update comment, add StrictVersion.
2022-07-02 15:06:58 +02:00
Felix Fontein
bc64aef5ca Revert "Revert "Remove deprecated functionality. (#363)""
This reverts commit e6d597b539.
2022-07-02 14:28:31 +02:00
Felix Fontein
6206976dbb Revert "Revert "Remove deprecations from docker_container, bump collection version to 3.0.0 (#399)""
This reverts commit 57e19ca596.
2022-07-02 14:28:27 +02:00
Felix Fontein
e6d597b539 Revert "Remove deprecated functionality. (#363)"
This reverts commit 209aeb57fd.
2022-07-02 14:18:53 +02:00
Felix Fontein
57e19ca596 Revert "Remove deprecations from docker_container, bump collection version to 3.0.0 (#399)"
This reverts commit 49ce0a3cb1.
2022-07-02 14:18:48 +02:00
Felix Fontein
49ce0a3cb1
Remove deprecations from docker_container, bump collection version to 3.0.0 (#399)
* Remove deprecated features in docker_container.

* Bump collection version to 3.0.0.

* Remove 'published_ports: all' tests.
2022-07-01 19:16:22 +02:00
Felix Fontein
209aeb57fd
Remove deprecated functionality. (#363) 2022-07-01 19:02:22 +02:00
Felix Fontein
f41d7ac1b8
Move common utility code to plugins.module_utils.util (#390)
* Move common utility code to plugins.module_utils.util.

* Also adjust plugins.

* Fix import.
2022-06-20 18:39:13 +02:00
Felix Fontein
a44e0736cf
Improve API version handling. (#389) 2022-06-20 07:34:38 +02:00
seffyB
6ff739390e
Update docker_container.py (#378)
##### Correct Typo in the word compatibility
Change all occurrences of `compatiblity` to be `compatibility` as it looks to be a typo.
For example, when running a task with `command_handling: compatiblity` an error will be thrown stating an invalid value


##### ISSUE TYPE
- Docs Pull Request

+label: docsite_pr
2022-06-01 07:38:51 +02:00
Garrit Franke
9c33aa5d12
Remove trailing space (#375)
* Remove trailing space

* Update plugins/modules/docker_compose.py

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-27 10:31:15 +02:00
Rodrigo Candido Gryzinski
497c2fda91
Add image_label_mismatch parameter to docker_container (#370)
* Add image_label_mismatch to docker_container

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* Test image_label_mismatch error message

* Add change fragment for image_label_mismatch

* Break long line in docker_container.py for pep-8 compliance

* pep8 compliance

* Update changelogs/fragments/370-add-image-label-mismatch.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix: add expected_labels to parameters_map in docker_container

* Apply suggestions from code review

* Apply suggestions from code review

* Update tests/integration/targets/docker_container/tasks/tests/options.yml

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-24 08:35:33 +02:00
Felix Fontein
401a76ff00
docker_container: fail if there are too many parts in a parsed port (#367)
* Fail if there are too many parts in a parsed port.

* Add tests.

* Prevent bad parsing.
2022-05-22 17:20:05 +02:00