1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00
Commit graph

232 commits

Author SHA1 Message Date
Benjamin Schubert
9aedda4443
Fix idempotency checks when using userns (#599)
Previously, this would only mark the userns as expected when `uidmap`
or `gidmap` is passed. However, in the case `userns` is passed, this
is also expected to be set.

Signed-off-by: Benjamin Schubert <contact@benschubert.me>
2023-07-31 20:55:03 +03:00
Sergey
296faf6154
CI: fix podman play job (#594)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-05-30 22:31:58 +03:00
Sergey
45e1de2bfe
podman-pod: Fix idempotency for pods in 4.4.x versions (#593)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-05-30 19:52:51 +03:00
nishipy
ab64d5f953
Update podman_image to specify CPU arch when pulling image (#578)
* Add test to sprcify CPU arch when pulling image

Signed-off-by: nishipy <goodisonev4@gmail.com>

* Update to specify CPU arch when pulling image

Signed-off-by: nishipy <goodisonev4@gmail.com>

* Add document for specifying arch

Signed-off-by: nishipy <goodisonev4@gmail.com>

* Fix for idempotency

Signed-off-by: nishipy <goodisonev4@gmail.com>

* Update plugins/modules/podman_image.py

Signed-off-by: nishipy <goodisonev4@gmail.com>

---------

Signed-off-by: nishipy <goodisonev4@gmail.com>
2023-04-15 13:49:16 +03:00
Sergey
4149dece62
Fix CI for newest Ansible branch 2.16 (#575)
Also include same file for next 3 releases...
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-04-05 20:46:47 +03:00
Sergey
d5f7655464
Support SHA256 tag for podman images (#570)
Fix #569
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-04-03 23:56:11 +03:00
Sergey
0332db2aad
Change yes/no to true/false in the modules (#561)
Fix #560
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-03-08 23:28:52 +02:00
Sergey
8f5842dea6
Add idempotency for restart-policy for containers (#548)
Fix: #440

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-02-12 13:00:00 +02:00
Sergey
c4bc7ccada
Fix idempotency for pods with uidmap and gidmap (#546)
Fix #543

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2023-02-12 01:42:20 +02:00
Roberto Alfieri
7d1d016fe9
added podman_prune module (#538)
* added podman-prune module


---------

Signed-off-by: Roberto Alfieri <ralfieri@redhat.com>
Signed-off-by: Roberto Alfieri <me@rebtoor.com>
2023-01-31 02:22:57 +02:00
linxside
a762dc63d0
Fix undesirable splitting of IPv6 host addresses (#533)
* fix: over splitting for ipv6 addresses

Signed-off-by: linxside <git@linux-inside.de>

* test: add test cases for ipv6 oversplitting

Signed-off-by: linxside <git@linux-inside.de>

Signed-off-by: linxside <git@linux-inside.de>
2022-12-13 03:50:40 +02:00
Sergey
2498c52f26
Fix network tests for Podman v4 (#527)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-11-29 01:37:55 +02:00
Sergey
f8a70fe5b0
Fix podman logout tests for v4 (#526)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-11-29 00:41:17 +02:00
Sergey
4f6ed89607
Run CI jobs with newer podman 4 (#525)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-11-29 00:02:24 +02:00
Sergey
5198b726fb
Delete systemd files when container/pod is deleted (#508)
Fix #489

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-11-10 17:13:45 +02:00
Sergey
05dc08c201
Add example unittest for container lib (#505)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-11-01 00:39:46 +02:00
Sergey
c952149603
Add unittests for Ansible Podman modules (#504)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-10-31 23:16:45 +02:00
CyberFox001
6cf118e7a9
Podman generate systemd (#498)
* Start a new Ansible module: podman_generate_systemd

This module, when finished, will let user generate a systemd .service
unit file from a pod or a container.

If a pod is specified, then the .service file is made for the pod and
its containers.

This commit is only the beginning, with two empty functions and the
base for a Python script.

* podman_generate_systemd : Remove not needed import from __future__

* podman_generate_systemd : Import AnsibleModule and json

* podman_generate_systemd : Build podman comand from user parameters

* podman_generate_systemd : Run the podman command and manage error

* podman_generate_systemd : Manage writing of systemd files, if needed

* podman_generate_systemd : In generate_systemd(), return needed infos

In case of success in generate_systemd() function, return:
- A boolean, indicate if the state of the target systemd is modified
- A copy of the systemd unit content

* podman_generate_systemd : Write run_module() function

This function:
- Build the list of parameters user can use
- Build a default result dictionary
- Build the Ansible Module
- Generate the systemd units (with generate_systemd())
- Return the result, with module.exit_json

* podman_generate_systemd : In main(), call run_module()

* podman_generate_systemd: Return podman command, and remove debug param

The run podman command is now returned by the module, and the "debug"
option is removed.

* podman_generate_systemd: Use more direct #! to python interpreter

The run podman command is now returned by the module, and the "debug"
option is removed.

* podman_generate_systemd: Write DOCUMENTATION variable

* podman_generate_systemd: Write EXAMPLES variable

* podman_generate_systemd: Write RETURN variable

* podman_generate_systemd: Fix typo

* podman_generate_systemd: 'restart_policy, remove default

* podman_generate_systemd: Fix missing "command" return when error

When error in command execution, generate_systemd() was not returning
the command. Now it's done.

* podman_generate_systemd: Remove unnecessary return in case of fail

In generate_systemd(), in case of fail in executing the podman
command, we call module.fail_json() then we return the usual data of
generate_systemd() function.

But module.fail_json() will stop the execution of the module, so it's
not necessary to return a value from generate_systemd() after calling
module.fail_json().

* podman_generate_systemd: Remove TODO

* podman_generate_systemd: Add missing double lines between functions

* podman_generate_systemd: More readability in EXAMPLES variable

* podman_generate_systemd: EXAMPLES, add minimum podman version

When a module option require a minimum Podman version, I indicate
this required version in option description.

For example: The module option `start_timeout` use the Podman option
`--start-timout`, which was introduced in Podman 4.0.0. So, I add in
the description of `start_timeout`: Only with Podman 4.0.0 and above

Options with this information:
- start_timeout
- restart_sec
- wants
- after
- requires

* podman_generate_systemd: EXAMPLES, fix type

* podman_generate_systemd: Simpler code for wants, after and requires

`after`, `wants` and `requires` are of type list. So, no need to
test their type and manage the case where they are of type string.

* podman_generate_systemd, generate_systemd(): Improve returned command

Improve how the used Podman command, returned by generate_systemd(),
is built. Instead of print a list in a formatted string, I join the
list elements with a space char as separator.

* podman_generate_systemd: Add support for the `env` option

Add, to the podman_generate_systemd module, the support for the `env`
option. This commit include the code, the option definition for the
module, the modification of the DOCUMENTATION variable and the add of
an usage example of this new option in the EXAMPLE variable.

* podman_generate_systemd: Write the integration test

* generate_systemd: Fix of the integration test and the --env command option

On the module, I now use the command option `-e=` for the definition
of environment variables. Because the option `--env` give an error
from Podman.

Also, fix errors in the integration test for this module.

* podman_generate_systemd: Add __future__ and __metaclass__ in the module

* podman_generate_systemd: Add author github ID

* podman_generate_systemd: Use argspec type path instead of str for dest option

In the module argspec, I now use the type `path` instead of `str` for
the option `dest`. `os.path.expanduser()` is no more necessary.

* podman_generate_systemd: remove all trailing whitespaces

* podman_generate_systemd: Remove type hint for compatibility with older Python

* podman_generate_systemd: Fix Documentation

Add a default for option `new` and fix typo in `use_names` option name.

* podman_generate_systemd: restart_policy option, new choices

The choice `no` is replaced by `no-restart`

* podman_generate_systemd: dest option in documentation, set type as path

Instead of str

* DNM add CI bits for new module tests

Made by sshnaidm.

* podman_generate_systemd: Better use of fail_json()

First: When calling the method fail_json(), name the `msg` argument to
avoid confusion.

Second: In case of calling fail_json(), I now return the same
arguments than the ones returned by a success: `changed`,
`systemd_units` and `podman_command`.

For future refactoring: Instead of calling fail_json() inside
generate_systemd(), raise custom exceptions and manage calling
fail_json() or exit_json() outside of generate_systemd().

* podman_generate_systemd: Add utf-8

* podman_generate_systemd: Remove `required: false` for DOCUMENTATION var

* podman_generate_systemd: DOCUMENTATION var, use bool instead of yes/no

* podman_generate_systemd: Remove non-necessary check of restart_policy option

The possible choices for this options are set in `ansible_spec` and
will be checked by AnsibleModule code. So, no need to check manually:
`ansible_spec` won't be anything other that the possible choices.

* podman_generate_systemd: On module params, use direct access to dict

Use `module.params['']` instead of `module.params.get('')`.

Because all module's options are defined with the `argument_spec`, the
options used here exist in the params. And if the user don't set
them, the value of the option is `None`.

* podman_generate_systemd: use shlex join for command_str

* podman_generate_systemd: use same quotes for messages

* podman_generate_systemd: Replace f-strings with .format(), for Python 2

* podman_generate_systemd: Revert usage of shlex

It add weird quotes around command options like `-e='ENV_VAR=value'`.

* podman_generate_systemd: Podman command build, more Python 2 compatible

Don't use any more the asterisk to add command options to the command.

* podman_generate_systemd: Better check-mode management

Now, when check mode is enabled, the module report "changed" is
something would be changed, but w/o actually doing anything.

* podman_generate_systemd: remove all trailing whitespaces

Co-authored-by: Sébastien Gendre <seb@k-7.ch>
2022-10-31 20:51:29 +02:00
Yuriy Gabuev
dbdac4a52b
podman_image: add file parameter for Containerfile location (#492)
* `podman_image`: correct `path` parameter description

The `path` parameter is the last parameter when running `podman build
...`. As specified in the manpage, it is defined as the build context,
and not necessarily should it contain the Containerfile.

Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com>

* `podman_image`: add `file` parameter for Containerfile location

Add the `file` parameter to `podman_image` module which mirrors the
`--file` command line argument for `podman build ...`. This parameter
specifies the location of the Containerfile to use in case it should be
different from the one contained in the build context directory.

Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com>

* `podman_image`: add integration tests for `file` parameter

Add tests to ensure that:
- building from a directory without a Containerfile (or Dockerfile)
  fails
- specifying the location of Containerfile with `file` parameter works

Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com>

Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com>
2022-10-25 17:48:14 +03:00
Sergey
bf67c7e078
Improve idempotency for devices mount of rootless podman (#487)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-28 12:39:15 +03:00
Sagi Shnaidman
409369c9fc Add shellcheck sanity ignore list for 2.15
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-21 02:40:05 +03:00
Sergey
03f19dfe25
Prepare tests to use custom executable, part 5 (#477)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-04 22:03:29 +03:00
Sergey
9c1cd62b6f
Prepare tests to use custom executable, part 4 (#476)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-04 21:47:33 +03:00
Sergey
d21b6c0326
Prepare tests to use custom executable, part 3 (#475)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-04 21:43:00 +03:00
Sergey
51ce943a63
Prepare tests to use custom executable, part 2 (#474)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-04 21:28:13 +03:00
Sergey
e9d746728d
Prepare tests to use custom executable, part 1 (#473)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-04 21:09:04 +03:00
Sergey
bd0f6f9bc4
Improve networks idempotency for v4 (#471)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-02 19:33:16 +03:00
Nikita Tokarchuk
9068baeb99
podman_container should ensure image by using os path if rootfs is used (#458)
* Check image with os path if rootfs is used

Signed-off-by: Nikita Tokarchuk <nikita@tokarch.uk>

* Take into account rootfs usage while evaluating a diff

Signed-off-by: Nikita Tokarchuk <nikita@tokarch.uk>

* Always compare rootfs image diffparam as strict

Signed-off-by: Nikita Tokarchuk <nikita@tokarch.uk>

* Reverse image labels getter to ignore the value if None

Signed-off-by: Nikita Tokarchuk <nikita@tokarch.uk>

* Add tests to check podman rootfs containers

Signed-off-by: Nikita Tokarchuk <nikita@tokarch.uk>

Signed-off-by: Nikita Tokarchuk <nikita@tokarch.uk>
2022-08-12 06:26:16 +03:00
Sergey
3596833a7d
Remove LC_ALL=C from podman tests (#452)
Ansible requires en_US.UTF-8 from 2.14 version.

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-07-14 12:26:28 +03:00
Sergey
33580c8991
Fix building image with buildah and become (#451)
Probably we hit a bug in CI:
https://github.com/containers/buildah/issues/3887
Unset envs to prevent error "sd-bus call: Transport endpoint is not connected"

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-07-14 11:47:50 +03:00
Sergey
2c88b822cf
Set localte in CI tests to en_US.UTF-8 (#450)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-07-14 11:35:47 +03:00
Sagi Shnaidman
75198ae574 Fix pod network idempotency
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-07-01 10:23:12 +03:00
Sagi Shnaidman
6c862b29e7 Fix pods list retrieve
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-07-01 10:23:12 +03:00
Sergey
25b9516488
Allow specify podman_network options MTU and VLAN separately (#435)
Before that it didn't work when only one option set.

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-06-08 19:37:06 +03:00
nishipy
acedce8b4b
Update podman_image to remove image with image id (#434)
* Update to remove image with image id.

Signed-off-by: nishipy <goodisonev4@gmail.com>
2022-06-08 18:51:25 +03:00
Sergey
e5d6136694
Change network attribute from str to list in pods #414 #416 (#417)
* Change network attribute from str to list in pods

Signed-off-by: André Cirne <dumahk21@gmail.com>

* Fix tests

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Co-authored-by: André Cirne <dumahk21@gmail.com>
2022-04-25 02:15:29 +03:00
MasterWaldo
b51dc5c814
Loop over image names when multiple images present in archive (#413)
Signed-off-by: Cory Prelerson <cprelerson42@gmail.com>
2022-04-24 22:38:53 +03:00
Sergey
fefc7e461f
Remove idempotency for log level (#404)
Since Podman changes its defaults very often and it's impossible
to track and identify every time what is current log level, let's
remove idempotency for this parameter for now.

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-03-29 14:15:16 +03:00
Sergey
91bd219067
Fix sanity issues with a new Ansible version (#405)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-03-29 11:47:42 +03:00
Sergey
aa4c3223d2
Fix podman collection for Podman version 4 (#398)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-03-17 21:56:19 +02:00
Sergey
ecf4c1c52d
Fix CI for podman container tests (#386)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-03-08 17:31:29 +02:00
Sergey
23fde625f6
Strip slashes from volumes (#379)
Fix #372

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-02-17 18:29:51 +02:00
Sergey
547abfea53
Add slirp4netns idempotency for pods (#369)
Fix #367
2022-01-16 23:44:08 +02:00
Aliaksandr Mianzhynski
d185616a72
Update secrets description and add test with secret opts (#363)
* Update secrets description and add test with secret opts

* Make pep happy
2022-01-06 18:08:09 +02:00
Timo Tomasini
9860b78ce5
Fix podman_pod_lib behavior for ports published to multiple IPs (#359)
* Fix podman_pod_lib behavior for ports published to multiple IPs

* Fix IPv6 behavior for pods and add tests

* Fix bind: cannot assign requested address issue with test container
2022-01-03 08:24:51 +02:00
Sergey
05515e8307
Add CI jobs and docs for podman_tag (#347) 2021-11-28 22:31:18 +02:00
Christian Bourque
f2882ecb19
Add podman_tag module #328 (#343)
Fixes #328
Co-authored-by: Christian Bourque <christian.bourque@expretio.com>
2021-11-28 18:02:24 +02:00
Aliaksandr Mianzhynski
3e7f7a00a0
Add secrets driver and driver opts support (#344) 2021-11-26 12:22:36 +02:00
Cédric Jeanneret
a8e81193f4
Allow to actually pass a list of string for "mounts" (#332)
Like "volume", "mount" can be passed multiple times to the container
creation/run, therefore we want to support a list of string, and a
"mounts" alias.
2021-11-09 13:40:40 +02:00
Mike
aa6d538be9
Don't add newlines to secrets (#331)
* prevent run_command from creating new lines
* removes new line from test
2021-11-01 22:22:57 +02:00