Commit Graph

54 Commits

Author SHA1 Message Date
Felix Fontein
c61c0e24b8
Improve error/warning messages w.r.t. YAML quoting (#1205)
* Remove superfluous conversions/assignments.

* Improve messages.
2025-11-16 12:32:51 +01:00
Felix Fontein
dee138bc4b
Fix typing info. (#1183) 2025-11-06 07:15:05 +01:00
Felix Fontein
be000755fc
Python code modernization, 8/n (#1179)
* Use to_text instead of to_native.

* Remove no longer needed pylint ignores.

* Remove another pylint ignore.

* Remove no longer needed ignore.

* Address redefined-outer-name.

* Address consider-using-with.
2025-10-25 00:36:04 +00:00
Felix Fontein
6ad4bfcd40
Add typing information, 2/n (#1178)
* Add typing to Docker Stack modules. Clean modules up.

* Add typing to Docker Swarm modules.

* Add typing to unit tests.

* Add more typing.

* Add ignore.txt entries.
2025-10-25 01:16:04 +02:00
Felix Fontein
3350283bcc
Add typing information, 1/2 (#1176)
* Re-enable typing and improve config.

* Make mypy pass.

* Improve settings.

* First batch of types.

* Add more type hints.

* Fixes.

* Format.

* Fix split_port() without returning to previous type chaos.

* Continue with type hints (and ignores).
2025-10-23 07:05:42 +02:00
Felix Fontein
c75aa5dd64
Python code modernization, 5/n (#1165)
* Address raise-missing-from.

* Address simplifiable-if-expression.

* Address unnecessary-dunder-call.

* Address unnecessary-pass.

* Address use-list-literal.

* Address unused-variable.

* Address use-dict-literal.
2025-10-12 16:02:27 +02:00
Felix Fontein
cad22de628
Python code modernization, 4/n (#1162)
* Address attribute-defined-outside-init.

* Address broad-exception-raised.

* Address broad-exception-caught.

* Address consider-iterating-dictionary.

* Address consider-using-dict-comprehension.

* Address consider-using-f-string.

* Address consider-using-in.

* Address consider-using-max-builtin.

* Address some consider-using-with.

* Address invalid-name.

* Address keyword-arg-before-vararg.

* Address line-too-long.

* Address no-else-continue.

* Address no-else-raise.

* Address no-else-return.

* Remove broken dead code.

* Make consider-using-f-string changes compatible with older Python versions.

* Python 3.11 and earlier apparently do not like multi-line f-strings.
2025-10-11 23:06:50 +02:00
Felix Fontein
33c8a49191
Fix crashes due to wrong names. (#1161) 2025-10-11 15:29:14 +02:00
Felix Fontein
892e9d9cbd Reorganize imports due to https://github.com/ansible-community/antsibull-nox/pull/136. 2025-10-10 21:19:28 +02:00
Felix Fontein
f7e976f3da
Avoid losing data from events if multiple arrive at the same time. (#1158) 2025-10-10 20:21:21 +02:00
Felix Fontein
e8ec22d3b1
Python code modernization, 3/n (#1157)
* Remove __metaclass__ = type.

for i in $(grep -REl '__metaclass__ = type' plugins/ tests/); do
  sed -e '/^__metaclass__ = type/d' -i $i;
done

* Remove super arguments, and stop inheriting from object.
2025-10-10 08:11:58 +02:00
Felix Fontein
a3efa26e2e
Address some pylint issues (#1155)
* Address cyclic-import.

* Address redefined-builtin.

* Address redefined-argument-from-local.

* Address many redefined-outer-name.

* Address pointless-string-statement.

* No longer needed due to separate bugfix.

* Address useless-return.

* Address possibly-used-before-assignment.

* Add TODOs.

* Address super-init-not-called.

* Address function-redefined.

* Address unspecified-encoding.

* Clean up more imports.
2025-10-09 20:11:36 +02:00
Felix Fontein
117271579e
Make all doc fragments, module utils, and plugin utils private (#1144)
* Make all doc fragments, module utils, and plugin utils private.

* Remove some unused and no longer needed imports.

This hopefully also fixes the CI issues, which do not happen locally for me...

* Fix formatting.

* Try to make CI happy, again.

* Fix imports.

* Lint.
2025-10-07 07:32:33 +02:00
Felix Fontein
d65d37e9e9 Reformat code with black and isort. 2025-10-06 18:34:59 +02:00
Felix Fontein
f45232635c
Python code modernization, 1/n (#1141)
* Remove unicode text prefixes.

* Replace str.format() uses with f-strings.

* Replace % with f-strings, and do some cleanup.

* Fix wrong variable.

* Avoid unnecessary string conversion.
2025-10-06 18:30:54 +02:00
Felix Fontein
1f2817fa20
Prepare 5.0.0 (#1123)
* Bump version to 5.0.0-a1.

* Drop support for ansible-core 2.15 and 2.16.

* Remove Python 2 and early Python 3 compatibility.
2025-10-05 20:22:50 +02:00
Felix Fontein
82b49c7cf2
Fix wrong replacements. (#1139) 2025-10-04 23:18:11 +02:00
Felix Fontein
1902e0fdf2
Avoid six in plugin code. (#1137) 2025-10-04 21:51:59 +02:00
Felix Fontein
769d15de63
Reformat documentation with 'andebox yaml-doc' (#1020)
* Reformat documentation with 'andebox yaml-doc'.

* Revert unwanted changes.

* Fix too long lines.

* Fix broken quotes.

* Forgot two line breaks.
2024-12-28 16:40:50 +01:00
Felix Fontein
f69536ef3b Improve language. 2024-12-28 14:30:49 +01:00
Felix Fontein
f7823ea626
Prepare 4.0.0 release. (#971) 2024-10-18 21:01:49 +02:00
Felix Fontein
c3aceebd7d
Docker* connection plugins: add working_dir and privileged options (#943)
* Add working_dir option.

* Add privileged option.

* Add basic tests.

* Also test privileged.
2024-07-25 20:35:32 +00:00
Felix Fontein
7464002bc3
Docker* connection plugins: allow to pass extra environment variables when running commands (#940)
* Allow to pass extra environment variables when running commands.

* Make compatible with older Python.

* Remove env and ini sources for extra_env.
2024-07-25 21:26:15 +02:00
Felix Fontein
205867e392
Avoid using the deprecated selectors compat module utils. (#871) 2024-05-25 09:00:18 +02:00
Felix Fontein
36c118d154
Deprecate ssl_version. (#853) 2024-05-11 15:53:19 +02: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
024bdec919
Use semantic markup (#645)
* Use semantic markup.

* Linting.

* Define docsite targets.

* Forgot one env var.

* Add array stubs.
2023-06-22 07:01: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
54a3dc151d
Remove unneccessary imports (#575)
* Remove unneccessary imports.

* Add noqas.
2023-02-09 15:25:45 +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
18091193de
Fix error handling. (#546) 2023-01-05 09:42:42 +01:00
Felix Fontein
2261dff49f
Document attributes (#497)
* Add 'docker' action group attribute.

* Compatibility with older ansible-core releases.

* Fix typo.

* Docment standard attributes.

* Improve docs.

* Add shortcuts for common combinations.
2022-11-06 21:15:09 +01: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
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
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
Brian Coca
6679eee41e
docker connection: handle version and docker_args (#327)
* handle version and docker_args

* Remove breaking change.

* Add changelog fragment.

* Fix unit tests.

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-04-25 20:35:33 +02:00
Felix Fontein
3c7c496e67
Implement connection reset. (#312) 2022-03-22 07:13:39 +01:00
Felix Fontein
b353a39ada
Adjust docker_api plugin to ansible-core 2.13. (#308) 2022-03-22 07:11:32 +01:00
Felix Fontein
421b712812
docker connection plugin: simplify actual_user handling code (#311)
* Simplify actual_user handling code.

* Forgot self.
2022-03-22 07:11:14 +01:00
Brian Coca
37a3264042
docker connection plugin: fix config docs and update to use config system (#297)
* fix config docs and update to use config system

 wean off play_context which did not have the correct data in all cases

* moar fixes

* Update plugins/connection/docker.py

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

* updated for backwards compat

* badmergeresolution

* makeitworks

* attempt to fix unit test

* mocking it# No more than 50 chars. #### 50 chars is here: #

* Update plugins/connection/docker.py

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

* Update plugins/connection/docker.py

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

* Update plugins/connection/docker.py

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

* Update plugins/connection/docker.py

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

* Update plugins/connection/docker.py

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

* Update plugins/connection/docker.py

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

* nomock

* remove bad paste

* properly load connection to initialize config

* initizlie docker args

* Fix bugs.

* Call _set_conn_data() when needed.

* Cache result of _get_docker_remote_user() now that it is called multiple times per task.

* Fix unit tests.

* list.clear() is Python 3...

* Add changelog.

* Call _set_conn_data() also in _connect().

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-03-21 19:19:14 +01:00
Felix Fontein
4b235a2607
Prepare for distutils.version being removed in Python 3.12 (#258)
* Prepare for distutils.version being removed in Python 2.12.

* Fix copy'n'paste error.

* Fix import.

* Re-add Loose prefix.

* Fix Python version typo.

* Improve formulation.

* Move message into own line.

* Fix casing, now that the object is no longer called Version.
2021-12-24 11:28:35 +01:00
Felix Fontein
93ea131f30
Get rid of distutils.spawn. (#257) 2021-12-24 11:27:23 +01:00
Jeff Goldschrafe
d224752cf1
Minor fixes to nsenter connection plugin (#249)
* Minor fixes to nsenter connection plugin

- Ensure the nsoption_pid option is retrieved in _connect instead of
  __init__ to prevent a crasher due to initialization order
- Replace the use of --all-namespaces with specific namespaces to
  support compatibility with Busybox nsenter (for example, Alpine)

* minor tidy

* Fix PEP8 violation

* Changelog fragment

* Update changelogs/fragments/249-nsenter-fixes.yml

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

Co-authored-by: Jeff Goldschrafe <jeff.goldschrafe@flatiron.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-09 05:53:43 +01:00
Felix Fontein
bed775c4ea
docker_container_exec: improve handling of chdir option (#243)
* Only pass chdir on when it is provided, and prevent this option from being used for Docker SDK for Python < 3.0.0.

* Also fix docker_api connection plugin.
2021-11-30 09:14:34 +01:00
Jeff Goldschrafe
2a9bc7f74e
Add nsenter connection plugin (#173)
* Add nsenter connection plugin

* Fixes

* oops

* Pass file I/O through nsenter, removing volume mount

* minor logging cleanup for consistency's sake

* Fix pylint flag

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Fix note formatting

* Revert string_types change

* Update tests/integration/targets/connection_nsenter/aliases

* Update tests/integration/targets/connection_nsenter/runme.sh

* Apply suggestions from code review

* Update tests/integration/targets/connection_nsenter/runme.sh

* Update tests/integration/targets/connection_nsenter/runme.sh

* Apply suggestions from code review

* Update tests/integration/targets/connection_nsenter/runme.sh

* Update tests/integration/targets/connection_nsenter/aliases

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Update plugins/connection/nsenter.py

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

* Remove specific pipelining support

* Update plugins/connection/nsenter.py

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-08-02 08:17:53 +02:00
Felix Fontein
badcd61a74
Replace ansible.module_utils._text by ansible.module_utils.common.text.converters. (#164) 2021-06-26 13:39:51 +02:00
Felix Fontein
902bcc6193
Pass Docker daemon connection params from inventory to connection plugin (#157)
* Move variable handling to doc fragment, and make them known to module_utils.

* Pass Daemon connection options to connection plugin.

* Add changelog fragment.

* Fix syntax error.

* Forgot 'options:'.
2021-06-22 06:29:56 +02:00
Romain Lalaut
43cbe3095b
docker.py: allow docker versions beginning with 'v' (#76)
* docker.py: allow docker versions with a leading 'v'

* Update changelogs/fragments/76-leading-v-support-in-docker-version.yml

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

Co-authored-by: Felix Fontein <felix@fontein.de>
2021-01-27 14:16:35 +00:00
Felix Fontein
a11f24c3a9
Fix docker_api connection: do not initialize client too early (#63)
* Fix docker_api connection: do not initialize client too early

* Make sure connection plugin tests are also run with Ansible 2.9 and 2.10.
2020-12-27 16:13:40 +01:00
Felix Fontein
8bd33b06c4
docker_api connection plugin (#40)
* Add basic docker_api connection test.

* Split AnsibleDockerClient into module-independent and module-specific part.

* Mention new connection plugin.

* Fix tests.

* Add first version of docker_api connection plugin.

* Linting.

* Fix references.

* Improve connection tests.

* Fix put_file for all Python versions.

* Fix fetch_file.

* Linting.

* Update plugins/connection/docker_api.py

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* Move potential common code to module_utils / plugin_utils.

* Move socket_handler to plugin_utils.

* Fix typo.

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
2020-12-15 20:07:55 +00:00