-
-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new modules/options for Quadlet #671
Comments
Yeah, this is a great idea. We need to think how it's better to implement it to avoid problems we have with systemd and its generation. |
Quadlet supports some types of units (
Then, this module will create a Quadlet file:
After Quadlet files are created, users need to run |
We can use |
I wonder if it's worth to create a translation module, which just dump yaml to quadlet file. Someone that knows quadlet keys, would probably create the file with templates as you said. Just to translate module values to quadlet seems like effort duplication. But I'm not against the idea, probably module docs would be more thorough for people to understand how to write quadlet(?) |
Agreed. This is another option I was thinking of actually. We can add a option such as
I see. It looks better than other ideas to me. I think this is easier for users to understand that as you said the module will create not actual Podman resources (containers, networks, volumes, etc) but quadlet files. |
OK, so let's start summarizing what we need:
Under question: |
We have the map for each state and method to be executed, so it seems we can add a new state ansible-podman-collections/plugins/module_utils/podman/podman_container_lib.py Lines 1744 to 1752 in 45893f4
In general cases, I want to use |
Yeah, as mentioned here I'd like to avoid as possible to trigger systemd in these modules, but seems like the Podman is too tied to it and it's pretty unavoidable. @nishipy would you like to see how to do it in a better way? I think we can use the patch of @nogweii and collaborate on it or to make a new one, he has a lot of things prepared already. |
I am excited about this feature. Has there been any notable progress? I have some experience with Ansible, but never developed a plugin myself, but if you need some help I'll glad to give you hand. |
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Fix containers#671 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
I think I've got the initial version for container and network prepared, please review. It currently creates Quadlet file in given folder, using the usual module configuration. It's possible to add required lines using quadlet_file_path: /tmp/quadlets/quadlet.container
quadlet_options:
- "Label=Test=network"
- "Label=foo=bar" All not supported in Quadlet options are going to "podman_actions": [
"podman run --name container122 --publish 9000:80 --publish 9001:8000 --workdir /bin --env FOO=bar=1 --env BAR=foo --env TEST=1 --env BOOL=False --label somelabel=labelvalue --label otheralbe=othervalue --mount type=devpts,destination=/dev/pts --volume /tmp:/data --detach=True alpine:3.12"
],
"podman_quadlet": "[Container]\nContainerName=container122\nEnvironment=FOO=bar=1\nEnvironment=BAR=foo\nEnvironment=TEST=1\nEnvironment=BOOL=False\nImage=alpine:3.12\nLabel=somelabel=labelvalue\nLabel=otheralbe=othervalue\nMount=type=devpts,destination=/dev/pts\nPublishPort=9000:80\nPublishPort=9001:8000\nVolume=/tmp:/data\nWorkingDir=/bin\n",
"podman_systemd": {
"container-container122": "# container-container122.service\n# autogenerated by Podman 4.8.3\n# Sun Mar 3 18:20:34 IST 2024\n\n[Unit]\nDescription=Podman container-container122.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network-online.target\nAfter=network-online.target\nRequiresMountsFor=/run/user/1000/containers\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nTimeoutStopSec=70\nExecStart=/usr/bin/podman start container122\nExecStop=/usr/bin/podman stop \\\n\t-t 10 container122\nExecStopPost=/usr/bin/podman stop \\\n\t-t 10 container122\nPIDFile=/run/user/1000/containers/overlay-containers/c3d91cde84ed953392e22532e3c168466a24a657262869c84d7c4650d4413892/userdata/conmon.pid\nType=forking\n\n[Install]\nWantedBy=default.target\n"
} Please review and comment, what else is required and desirable? |
Added support for Pod as well |
Great news @sshnaidm !! Firstly, thanks for the effort. I would like to test this, so I can give you some feedback if you want, but I don't know how. Could you point me to the documentation to be able to install your branch into my Ansible project? |
@alorle you can test the code cloning the branch @sshnaidm created, expecting you will end up in the following directory structure.
With that, basic settings and example could be as follow. The example is taken from documentation made in the quadlet addon by @sshnaidm
So basic testing works for me.
I didn't checked the entire routine, but initially looks good. I will check my entire lab-infra as soon as possible and see if I run into some issues. |
Thanks for the extensive hint @knumskull . This weekend I will try it and give some feedback. Thanks again for the hard work!! |
I wonder if we need to add the generation of systemd unit file themselves, or to leave it to |
That is certainly true. The |
I've been testing it this week and it works perfectly. Thanks for the effort!! |
Or, how about adding a parameter like |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind feature
Description
Since Podman 4.7.0, the
podman generate systemd
command has been deprecated. Instead of that, it is recommended to useQuadlet
for running containers and pods under systemd.Now, it's time to consider adding a new module to support Quadlet to run Podman containers under systemd.
More specifically, what we need is:
Under question:
The text was updated successfully, but these errors were encountered: