aboutsummaryrefslogtreecommitdiff
path: root/ansible/module_utils
AgeCommit message (Collapse)AuthorFilesLines
2026-09-10Fix trailing comma bug in DockerWorker.generate_tls()Tikhon Masalov1-2/+2
In generate_tls(), tls_cert and tls_key were assigned with trailing commas, which caused them to become single-element tuples (None,) instead of None. This made the if tls_cert: check always true, leading to TypeError when check_file() received a tuple instead of a string path. Remove the trailing commas so tls_cert and tls_key are plain values. Remove TestTLS.setUp(_get_host_timezone) for stable branches: _get_host_timezone does not exist in kolla_container_worker.py on older branches, causing AttributeError in TestTLS setUp. Closes-Bug: #2166845 Change-Id: I06b8876838ee2ec3c20c9a98448fc9e5588f32cd Signed-off-by: Tikhon Masalov <t.masalov@maxima-int.com> (cherry picked from commit 2f8958235bc16a89a33c0711f1dfcb7bca87a1a9)
2026-09-03Fix compare_labels when image doesn't existAlex Welsh2-1/+5
check_image() from kolla_docker_worker returns None when the image doesn't exist locally. This means that when compare_labels tries to read a value from it, it will error out. This chain happens when comparing an image that doesn't exist locally. In the past we didn't hit this because checks ran sequentially and it would exit before hitting this. A recent change [1] means that now all checks run always. This patch fixes the issue in two ways. First, it makes the docker worker return an empty dict from check_image when it doesn't exist. Second, compare_labels now truthy-checks the output before proceeding, and returns straight away if it's False. [1] https://review.opendev.org/c/openstack/kolla-ansible/+/978162 Change-Id: I3c33ac3a474f80bca100005f61c1c0bfedc46170 Signed-off-by: Alex Welsh <alex@stackhpc.com> Closes-Bug: #2166024 (cherry picked from commit ffc50e8d33ade7a0d58ef83b79ed296a28b49608)
2026-08-04Fix Docker cpuset dimension comparisonLoan Harrouin1-0/+8
When enabling cpuset_cpus or cpuset_mems on existing Docker containers, Docker may report the current value as an empty string when no cpuset constraint is configured. These dimensions are cpuset-list strings, not numeric resource values. Compare them as strings in the Docker worker instead of passing them through the numeric dimension comparison logic. Closes-Bug: 2143874 Change-Id: I1b8cd72846b28f556c8f9a0ba114a8af9221e85a Signed-off-by: Loan Harrouin <loan.harrouin@gmail.com> (cherry picked from commit 8304bb3884237bf5aee1c60715d097e88561d56d)
2026-07-01UnicodeDecodeError in PodmanWorker.compare_configEttore Simone1-2/+6
During container config comparison, podman's Docker-compat exec API inconsistently demultiplexes the 8-byte frame headers from the output stream depending on podman version, leaving binary bytes in raw_output. This will raise an "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x?? in position 167: invalid start byte" Closes-Bug: 2153943 Change-Id: Ida1c017f50b9a24b88f8962d304eb015fa357211 Signed-off-by: Ettore Simone <ettore.simone@gmail.com> (cherry picked from commit c99f521356012d5bc42ab3c41a994b67657e86f0)
2026-05-06kolla_container: Return annotation of comparison failuresMichal Nasiadka3-35/+183
Assisted-By: Claude Sonnet 4.6 Change-Id: If6f09c727bc5c7af27786cdc92c998d653dd4ad1 Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
2025-11-29Fix idempotence on podman volume comparisonBertrand Lanson1-38/+54
Due to podman returning all mount option flags in Binds list, The compare_volumes function could not be idempotent because some flags would be skipped everytime, or analyzed when they shouldn't. This new version fixes it by filtering out all default flags from podman for both the requested and current volumes, making comparison accurate. It also takes into account special privileged paths that have the noexec flag added. Closes-bug: #2131039 Change-Id: I173bcb2b1f8c5b81f8395924dfccf73b060100b9 Signed-off-by: Bertrand Lanson <bertrand.lanson@protonmail.com>
2025-11-29Fix podman idempotence on comparing container dimensionsBertrand Lanson1-8/+46
Podman containers are created with default ulimites for RLIMIT_NOFILE and RLIMIT_NPROC that are breaking idempotence for kolla_container in check_container mode. We forbid users from setting them, so we should also ignore them when checking dimensions to make the module idempotent. Closes-bug: #2131038 Change-Id: If71589a666c4a3a8003a3419518fd7e4182c5e2b Signed-off-by: Bertrand Lanson <bertrand.lanson@protonmail.com>
2025-11-29Fix idempotence on comparing capabilities for podmanBertrand Lanson1-0/+36
Currently, we add the AUDIT_WRITE capability for all unprivileged podman containers. This causes a diff because the cap is popped from params before comparing with the running container's actual values. This patch fixes it by overriding compare_cap_add() to normalize capability formats and account for auto-added AUDIT_WRITE, while working around a bug in older Podman versions where AUDIT_WRITE doesn't appear in the inspect API response. Closes-bug: #2133434 Change-Id: I61fc50654fb06e041776fd394f6b1cab2f9903ba Signed-off-by: Bertrand Lanson <bertrand.lanson@protonmail.com>
2025-10-28Bump ansible-core to 2.18/2.19Michal Nasiadka3-8/+15
Bumped collections in requirements-core.yml to Ansible 12 major versions, see [1]. [1]: https://github.com/ansible-community/ansible-build-data/blob/main/12/ansible-12.1.0.yaml Depends-On: https://review.opendev.org/c/openstack/kolla/+/960307 Co-authored-by: Doug Szumski doug@stackhpc.com Change-Id: If8a29052d8a43ffc0fef11514adabb5e4ab9d977 Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
2025-09-25group_vars: Reorganize huge all.yml into smaller filesMichal Nasiadka1-1/+1
This will help us to trigger scenario jobs on changes in given group_vars files. Changes to Zuul config to trigger given scenarios will be posted as a follow-up. Change-Id: I3f17adf655d2d0c1fc2969153dddb0c72b11397a Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
2025-04-28Merge "systemd: Add kolla.target"Zuul1-0/+1
2025-03-27Assign labels to kolla volumesMarek Buch2-8/+39
Kolla volumes do not have assigned any labels, that makes identification and filtering for kolla specific volumes hard. This change allows for easier volume management. Closes-bug: #1630545 Change-Id: I6b536f73433cfc64881ac66e53aa0a5eed709ce6 Signed-off-by: Marek Buch <marek.buch@tietoevry.com>
2025-02-07Move actions to kolla_container_factsIvan Halomi1-24/+0
Move actions responsible for info about containers from kolla_container module to kolla_container_facts. Also fixes a bug with inconsistencies between docker and podman in kolla_container_facts. Closes-bug: #2084878 Change-Id: I1db88e28a828ebf073f018b2bae1d9556ec22807 Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com> Signed-off-by: Martin Hiner <martin.hiner@tietoevry.com> Signed-off-by: Roman KrĨek <roman.krcek@tietoevry.com>
2024-11-28systemd: Add kolla.targetMichal Nasiadka1-0/+1
This should ease the operation of stopping/starting all Kolla containers. Change-Id: I30915409510a4eb3e501e624b864b5ef48f85c75
2024-09-13systemd: Add Wants=docker.service for dockerMichal Nasiadka1-0/+1
In I70dd1751dea6bfc9bb265aeda04b3392e135324c we removed Requires=docker.service and left only After=docker.service. In a case where something starts docker.service that's enough, but if docker.service is disabled or no service is dependent on it - it won't be started. This patch adds Wants=docker.service which will try to start docker.service if it is not started or enabled but does not impose a dependency which causes restart of kolla systemd units when docker.service is restarted (see [1]). Closes-Bug: #2065168 [1]: https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Wants= Change-Id: Ic3acb15f7c6ba7269ef62ccc8895b6bea4fc1f4d
2024-09-05Set KOLLA_SERVICE_NAME in Podman containersMartin Hiner3-16/+14
Fixes issue in PodmanWorker where it didn't set KOLLA_SERVICE_NAME environment variable when creating new container. Additionally, two methods were moved from DockerWorker to ContainerWorker as they are applicable to both engines. Closes-Bug: #2078940 Change-Id: I273444fc828678d3c6803bce1bc8db1c5366b9b6 Signed-off-by: Martin Hiner <martin.hiner@tietoevry.com>
2024-08-21Remove "distutils" libraryleiyashuai2-18/+7
Library "distutils" is deprecated in Python 3.10: https://peps.python.org/pep-0632/ The versions previously referenced using StrictVersion should be old enough that they will not be used in a Dalmatian deployment: - Ansible 2.11 - Docker API 1.42, included since Docker engine 23.0.0 Change-Id: Ie315004715a1cb5a91dd54bc64b0a8fd0af650ec
2024-07-24Merge "Fix podman healtcheck when not enabled"Zuul1-1/+2
2024-07-08Fix podman healtcheck when not enabledIvan Halomi1-1/+2
There was a bug where setting the test command for the health check to 'NONE' would throw an error in podman_worker. This was problematic since K-A uses 'NONE' as an indicator that the health check is not enabled. Closes-Bug: #2071912 Change-Id: I3140bb79eace58b23f579be3da569c502c52c38c Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com>
2024-07-03Merge "Enhanced explanation of volume handling with podman"Zuul1-6/+13
2024-07-02Enhanced explanation of volume handling with podmanIvan Halomi1-6/+13
Add more explanatory documentation why is parsing of volumes needed during creation of container to stay consistent with the documentation inside docker worker. Change-Id: Id7c90a6ec04f4a21a75f2edb39f80a64199b5f86 Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com>
2024-06-27Merge "Fix kolla-ansible systemd restart behaviour"Zuul1-1/+0
2024-06-26Merge "Fix the docker container dimensions comparison for short notation"Zuul1-4/+75
2024-06-26Merge "Support mode in named volumes when using podman"Zuul1-2/+6
2024-06-26Fix the docker container dimensions comparison for short notationPedro Henrique1-4/+75
When using short notations like `1g` or `512m` to define the container dimensions, we are always getting the container to being restarted in each kolla-ansible run, even with no real changes in the container configs. Change-Id: Ic8e2dd42b95a8f5c2141a820c55642a3ed7beabd Closes-Bug: #2070494
2024-06-24Fix kolla-ansible systemd restart behaviourVictor Chembaev1-1/+0
Fix kolla systemd unit template to prevent restart all kolla services with docker.service restart Change-Id: I70dd1751dea6bfc9bb265aeda04b3392e135324c Closes-Bug: 2065168
2024-05-27Fix missing commas in kolla_podman_workerMartin Hiner1-3/+3
List of strings CONTAINER_PARAMS is missing comma separators, which makes it an implicit concatenation of list items that should be separate. Closes-Bug: #2067278 Change-Id: Iec9a8de184481dae058377fa8d7bbd8da729d62c Signed-off-by: Martin Hiner <martin.hiner@tietoevry.com>
2024-04-22CI: Add codespell to pep8Michal Nasiadka2-4/+4
Fix existing spelling errors Change-Id: Ie689cf5a344aaa630a4860448b09242333a8e119
2024-03-29tests: Replace imp with importlib.machineryMichal Nasiadka1-1/+2
It's needed for Python3.12 support, because imp has been dropped [1]. Also shlex dropped s=None support [2]. [1]: https://docs.python.org/3/whatsnew/3.12.html [2]: https://github.com/python/cpython/issues/94352 Change-Id: I23f37897ea08ac708f6df485f699122df647e552
2024-02-27Support mode in named volumes when using podmanWill Szumski1-2/+6
Volumes with a mode specifier were causing the container to fail to start with the error: "Wrong format of volume". ironic-dnsmasq was one services affected by this issue, but you could also hit this issue when using the volume customisation variables. Closes-Bug: #2054834 Change-Id: I848bd2838a17756f1c71b07befe1e3d966f5b6c2
2024-01-05Fix long service restarts while using systemdMichal Arbet1-0/+1
Some containers exiting with 143 instead of 0, but this is still OK. This patch just allows ExitCode 143 (SIGTERM) as fix. Details in bugreport. Services which exited with 143 (SIGTERM): kolla-cron-container.service kolla-designate_producer-container.service kolla-keystone_fernet-container.service kolla-letsencrypt_lego-container.service kolla-magnum_api-container.service kolla-mariadb_clustercheck-container.service kolla-neutron_l3_agent-container.service kolla-openvswitch_db-container.service kolla-openvswitch_vswitchd-container.service kolla-proxysql-container.service Partial-Bug: #2048130 Change-Id: Ia8c85d03404cfb368e4013066c67acd2a2f68deb
2023-11-15Rename kolla_docker to kolla_containerMartin Hiner1-1/+1
Changes name of ansible module kolla_docker to kolla_container. Change-Id: I13c676ed0378aa721a21a1300f6054658ad12bc7 Signed-off-by: Martin Hiner <m.hiner@partner.samsung.com>
2023-11-14Introduce oneshot docker_restart_policyMichal Nasiadka2-5/+5
docker_restart_policy: no causes systemd units to not get created and we use it in CI to disable restarts on services. Introducing oneshot policy to not create systemd unit for oneshot containers (those that are running bootstrap tasks, like db bootstrap and don't need a systemd unit), but still create systemd units for long lived containers but with Restart=No. Change-Id: I9e0d656f19143ec2fcad7d6d345b2c9387551604
2023-10-20Add support of podman deploymentIvan Halomi3-10/+688
This change adds basic deployment based on Podman container manager as an alternative to Docker. Signed-off-by: Ivan Halomi <i.halomi@partner.samsung.com> Signed-off-by: Martin Hiner <m.hiner@partner.samsung.com> Signed-off-by: Petr Tuma <p.tuma@partner.samsung.com> Change-Id: I2b52964906ba8b19b8b1098717b9423ab954fa3d Depends-On: Ie4b4c1cf8fe6e7ce41eaa703b423dedcb41e3afc
2023-08-17systemd: handle running container without systemd unitMichal Nasiadka2-8/+12
MariaDB bootstrap has a phase where the first MariaDB container is running with Galera bootstrap - after a check that WSREP is synced is successful - we restart the container. The bootstrap container is named mariadb and running with docker_restart_policy: "no" - the restarted container should be running in systemd. Before this patch the code created a systemd unit but it was initially stopped - so stopping was always a success - and the container would be killed with SIGKILL on removal (which obviously breaks MariaDB). This patch also improves docker/systemd stops by waiting for real unit/container stop and adds failing CI for containers that are killed with signal 9. Closes-Bug: #2029613 Change-Id: I0a03e509ce228a50e081fcab44d2b4831251190c
2023-03-23Fix restart_container when restart_policy is noMichal Nasiadka1-7/+10
Closes-Bug: #2012654 Change-Id: I9735b4409a48d80851cbc26a9edbf370af1d45bf
2023-02-20Refactor DockerWorker into ContainerWorkerIvan Halomi2-381/+507
Fourth part of patchset: https://review.opendev.org/c/openstack/kolla-ansible/+/799229/ which was suggested to be split into smaller patches. This commit refactors select methods from DockerWorker class into ContainerWorker class. New class contains Docker independent methods also used in Podman introduction and is inteded as a parent class for specific worker classes. Signed-off-by: Ivan Halomi <i.halomi@partner.samsung.com> Co-authored-by: Martin Hiner <m.hiner@partner.samsung.com> Change-Id: I2dd5920410dda053f2dfedc4e2666c56b1a7095a
2023-02-03Do not support dimensions:kernel_memory on Docker API 1.42Michal Nasiadka1-2/+7
It is deprecated in 20.10 and removed in 23.0 (and 23.0 is out) [1], [2]. [1]: https://docs.docker.com/engine/deprecated/#kernel-memory-limit [2]: https://docs.docker.com/engine/api/version-history/#v142-api-changes Change-Id: Ia6fa85172aad7bcd5f958922d3c224ef79882e6c
2023-01-19Add systemd container controlMartin Hiner2-17/+238
This commit adds SystemdWorker class to kolla_docker ansible module. It is used to manage container state via systemd calls. Change-Id: I20e65a6771ebeee462a3aaaabaa5f0596bdd0581 Signed-off-by: Ivan Halomi <i.halomi@partner.samsung.com> Signed-off-by: Martin Hiner <m.hiner@partner.samsung.com>
2022-12-13Remove shebang to properly support venv in ansible-core 2.13+Michal Nasiadka1-2/+0
See https://github.com/ansible/ansible/pull/76677 Change-Id: If822dcfc4c1abf7a22be35ffd90fd05ee46cb0d9
2022-01-06Refactor of kolla_docker into module_utilsMartin1-0/+875
Moved the DockerWorker class from module file into its separate file in module_utils directory for future extension. Unit tests changed accordingly. Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com> Co-authored-by: Martin Hiner <martin.hiner@tietoevry.com> Change-Id: Ia2a471a9a2805e13b2c20dbf8a7297c23231aae3