1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-04-05 00:56:52 +00:00
Commit graph

135 commits

Author SHA1 Message Date
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
phong-ngthanh
ed69d3c143
feat: allow empty string for prefixes (#517)
Signed-off-by: zephyros-dev <phong.ngthanh@outlook.com>

Signed-off-by: zephyros-dev <phong.ngthanh@outlook.com>
2022-11-21 18:19:27 +02:00
Sergey
a3f8901c4c
Fix docs issues in podman_image (#507)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-11-02 16:56:24 +02:00
Alessandro Re
1fa3dda67b
docs: added simple extra_args example (#493) 2022-11-01 01:15:40 +02:00
Sergey
9e92a6e90c
Fix podman load module for Podman 4 (#503)
Fix #486
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-10-31 22:23:35 +02:00
Sergey
712c3230b2
Fix example in systemd generate module (#502)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-10-31 21:59:21 +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
bd0f6f9bc4
Improve networks idempotency for v4 (#471)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-02 19:33:16 +03:00
dada513
b72a026328
generate_systemd: implement --wants, --after and --requires (GH-431) (#432)
* generate_systemd: implement --wants, --after and --requires (GH-431)

Signed-off-by: dada513 <dada513@protonmail.com>
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Co-authored-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-09-01 20:28:07 +03:00
Sergey
cecb29222e
Add --sdnotify option for container (#465)
Fix #464

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-08-28 16:42:31 +03:00
Albrecht
08dd7b0ceb
add required argument to example (#461)
Signed-off-by: weichweich <archbelt@posteo.de>
2022-08-08 22:28:15 +03:00
Sergey
e6544bdd0a
Fix PEP8 issue in podman_image (#459)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-07-31 22:47:17 +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
Sagi Shnaidman
542986cd8a Pass errors as a string instead of list 2022-07-01 10:23:12 +03:00
Sergey
2577f5b0f5
Remove distutils as deprecated (#437)
Fix #422
The distutils package is deprecated and slated for removal in Python 3.12

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-06-12 22:54:03 +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
Clemens Lange
b33a657f00
Fix idempotency for podman_login (#430)
Signed-off-by: Clemens Lange <clemens.lange@cern.ch>
2022-06-06 12:18:08 +03:00
Benjamin Schubert
15dae0d9ad
podman_container.py: Fix typo in the documentation (#424)
I believe "prefix" is what was meant here

Signed-off-by: Benjamin Schubert <contact@benschubert.me>
2022-05-22 15:08:16 +03:00
Oscar
20a982b564
Fix play_kube not working when yaml not installed on target (#415) (#419)
Signed-off-by: tcmal <oscar.shrimpton.personal@gmail.com>
2022-05-01 11:48:43 +03:00
Sergey
98c516292f
Fix internal networks idempotency (#421)
Remove logic with internal and dns, since Podman supports it in
recent versions.
Fix #350
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-04-28 00:56:22 +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
Henry78
4afd6bbd18
Podman Pod: Update examples to use quotes when publishing ports to avoid them being intrepreted as scalars. #394 (#401)
Signed-off-by: Henry <henry78@gmx.at>
2022-03-24 11:46:54 +02: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
Axel Dahlberg
4a7d64bb43
fix(network) fix issue when missing plugins entry (#392)
Signed-off-by: Axel Dahlberg <git@valleymnt.com>
2022-03-14 13:41:28 +02:00
Rubik's Dot
d024e91216
fix check for read-only change of root image (#393)
The --read-only option is not checked for changes between runs of
ansible thus the container is not recreated if the user changes
the root image between read-write to read-only.

Default for the read_only variable set to False in line with
documentation and so that later checks are simplified.

This is a fix for bug #383.

Signed-off-by: Andrew <rubiksdot@grue.cc>

Co-authored-by: Andrew <rubiksdot@grue.cc>
2022-03-14 12:54:12 +02:00
Sergey
527ccacf01
Add --requires option (#378)
Fix #374
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2022-02-17 18:53:37 +02:00
Sergey
4f3a84f4e5
Add new options for pod module (#361) 2022-01-13 15:10:05 +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
Radovan Dražný
42dc5be784
Handle tlsverify correctly in podman_login (#365) 2022-01-06 17:00:10 +02:00
Joerg Kastning
6ba6c01229
Add a second example to podman_pod_module.html (#346)
Added a second example
2021-11-29 00:13:31 +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
zephyros
e6d2e86e35
Add documentations for generate_systemd (#336) 2021-11-19 16:04:06 +02:00
Luca Beltrame
cef7bdbea0
Support --new in generate_systemd (#334)
* Support --new in generate_systemd

Fixes #318.

* Add docs
2021-11-18 14:35:42 +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
Sean Sullivan
e90eb325ae
Update error message when pull set to false (#327) 2021-10-19 02:01:52 +03:00
Sergey
4982579c79
Add skip option for podman secret (#324) 2021-10-12 13:56:04 +03:00
Jad Kik
15cd7623af
Add support for network-alias flag (#314)
* Add support for network-alias flag
* Ignore idempotency assert in tests

Co-authored-by: Sagi Shnaidman <sshnaidm@redhat.com>
2021-10-03 22:18:31 +03:00
Sergey
3f3cdab506
Add .service extension to systemd files (#310) 2021-09-23 09:50:16 +03:00
Bruno Marsal
8d48e30721
Fix suboption key in podman_container/podman_pod for generate_systemd documentation (#305)
* fix suboption key in podman_container -> generate_systemd documentation

As of this line 5b3f8a4d3d/plugins/module_utils/podman/common.py (L66) it should be "path", not "file"

* fix suboption key in podman_pod -> generate_systemd documentation
2021-09-19 13:54:50 +03:00
Sergey
5b3f8a4d3d
Add aliases for image load/save (#303)
To be compatible with docker_image_load module add 'path' options
as aliases.
2021-09-17 22:36:07 +03:00
Sergey
5d37e1ee22
Add systemd generation for pods (#299) 2021-09-15 02:44:06 +03:00
Sergey
24329ce5d3
Generate systemd service files for containers (#298) 2021-09-13 17:13:15 +03:00
Sergey
53338e7ec0
Add podman import/export containers modules (#297) 2021-09-12 17:01:38 +03:00
Sergey
ff4e26bbac
Podman image load module (#296) 2021-09-06 02:42:34 +03:00