Comments (10)
I have added the --format json
option in containers/podman#7329. This will be included in podman v2.1.
$ podman generate systemd --format json ad352b0cb348
{
"container-ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667": "# container-ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667.service\n# autogenerated by Podman 2.1.0-dev\n# Mon Sep 14 20:26:09 CEST 2020\n\n[Unit]\nDescription=Podman container-ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network.target\nAfter=network-online.target\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nExecStart=/home/paul/go/src/github.com/containers/libpod/bin/podman start ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667\nExecStop=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667\nExecStopPost=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667\nPIDFile=/run/user/1000/containers/overlay-containers/ad352b0cb348cd28d097dae8902a444e5fca1aacd834698018aa482437b8f667/userdata/conmon.pid\nKillMode=none\nType=forking\n\n[Install]\nWantedBy=multi-user.target default.target\n"
}
Output for a pod:
$ bin/podman generate systemd --format json pod
{
"container-6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268": "# container-6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268.service\n# autogenerated by Podman 2.1.0-dev\n# Mon Sep 14 20:37:28 CEST 2020\n\n[Unit]\nDescription=Podman container-6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network.target\nAfter=network-online.target\nBindsTo=pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f.service\nAfter=pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f.service\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nExecStart=/home/paul/go/src/github.com/containers/libpod/bin/podman start 6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268\nExecStop=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268\nExecStopPost=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268\nPIDFile=/run/user/1000/containers/overlay-containers/6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268/userdata/conmon.pid\nKillMode=none\nType=forking\n\n[Install]\nWantedBy=multi-user.target default.target\n",
"container-a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a": "# container-a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a.service\n# autogenerated by Podman 2.1.0-dev\n# Mon Sep 14 20:37:28 CEST 2020\n\n[Unit]\nDescription=Podman container-a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network.target\nAfter=network-online.target\nBindsTo=pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f.service\nAfter=pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f.service\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nExecStart=/home/paul/go/src/github.com/containers/libpod/bin/podman start a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a\nExecStop=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a\nExecStopPost=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a\nPIDFile=/run/user/1000/containers/overlay-containers/a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a/userdata/conmon.pid\nKillMode=none\nType=forking\n\n[Install]\nWantedBy=multi-user.target default.target\n",
"pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f": "# pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f.service\n# autogenerated by Podman 2.1.0-dev\n# Mon Sep 14 20:37:28 CEST 2020\n\n[Unit]\nDescription=Podman pod-9c478a337035daffc68d0a0618bfce0ec97ff9612a3face59302ad51b539101f.service\nDocumentation=man:podman-generate-systemd(1)\nWants=network.target\nAfter=network-online.target\nRequires=container-6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268.service container-a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a.service\nBefore=container-6ae41af23d0292450901204a29227e0420c081a1a71b89429142d5aa719a5268.service container-a3aeb4ccd27b3b66a5786982da65da9ee59a9c1da1e70951ce99b53a0542361a.service\n\n[Service]\nEnvironment=PODMAN_SYSTEMD_UNIT=%n\nRestart=on-failure\nExecStart=/home/paul/go/src/github.com/containers/libpod/bin/podman start 7443127611f85a0f2fbe7a5a33d94b262717e040295a1c33134775b991240b30\nExecStop=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 7443127611f85a0f2fbe7a5a33d94b262717e040295a1c33134775b991240b30\nExecStopPost=/home/paul/go/src/github.com/containers/libpod/bin/podman stop -t 10 7443127611f85a0f2fbe7a5a33d94b262717e040295a1c33134775b991240b30\nPIDFile=/run/user/1000/containers/overlay-containers/7443127611f85a0f2fbe7a5a33d94b262717e040295a1c33134775b991240b30/userdata/conmon.pid\nKillMode=none\nType=forking\n\n[Install]\nWantedBy=multi-user.target default.target\n"
}
from ansible-podman-collections.
This is an open source project, you're welcome to send a patch.
from ansible-podman-collections.
I'd be keen for this functionality too, likewise using shell
from ansible-podman-collections.
@Klaas- , I think we'd better to make it as a separate module. Even if we integrate it into podman_container
, it's always good to have it separately in case you need just to generate files for existing containers.
You can just parse output of command, it's actually the text of systemd file, like we do here with version for example: https://github.com/containers/ansible-podman-collections/blob/master/plugins/modules/podman_container.py#L1777-L1778
def _get_podman_version(self):
# pylint: disable=unused-variable
rc, out, err = self.module.run_command(
[self.module.params['executable'], b'--version'])
if rc != 0 or not out or "version" not in out:
self.module.fail_json(msg="%s run failed!" % self.module.params['executable'])
return out.split("version")[1].strip()
from ansible-podman-collections.
@sshnaidm using the stdout output works for a single container, my main focus for now is getting awx to work (and that is a pod with multiple containers). I looked at the output, that's a concatination of the multiple service files without a real seperator if I did not misread the output :) I was going to suggest to add a json output or something like that but go is not really my language :D
from ansible-podman-collections.
@Klaas- you're right, there is no visible delimiter. We can try to rely on comments, which are first lines in the file like:
# pod-mypod.service
# autogenerated by Podman 1.8.1
# Wed Apr 8 22:16:40 IDT 2020
But it'll be a guess.
Can you point me please to pod configuration with AWX?
I'm not sure Podman team will adopt JSON for a file output, might be challenging with multiline and indentation. But for a visible and well defined delimiter I think would be reasonable to ask.
from ansible-podman-collections.
@sshnaidm I'm currently working on getting the current version to work ikke-t/awx_pod#7 is what I'm using for now, but I want to replace the podman role with something working smoother :)
from ansible-podman-collections.
@Klaas- hi, any work in progress about generation of systemd files?
I think to start systemd files generation for pods and containers, also play_kube functionality. I wonder if you made something or maybe have use cases for this. I think it's worth to add automatic generation of systemd units and their installation.
from ansible-podman-collections.
@sshnaidm hi, no I haven't worked on it more. For now I my primary usecase is the awx_pod and that is using https://github.com/ikke-t/podman-container-systemd - I would like to see this implemented here but I haven't found the time yet :D
from ansible-podman-collections.
any updates here? Right now I'm using the shell module to create systemd files.
from ansible-podman-collections.
Related Issues (20)
- Alias parameters "stop_timeout" and "time" for podman generate systemd HOT 3
- rootless always want to change the user HOT 3
- Incorrect documentation for `podman_image_info` return value HOT 1
- containers.podman.podman_secret fails if identical secret was create in playbook before HOT 1
- podman_network not idempotent when disable_dns is explicitly set
- No values returned from podman_container_exec on failures HOT 3
- `AttributeError: 'list' object has no attribute 'get'` trying to use collection on recent Fedora (podman 5.0?) HOT 2
- Env in container exec are wrongly double quoted HOT 2
- podman_container: pasta network breaks idempotency
- podman_login: why are tlsverify certdir mutually exclusive? HOT 6
- podman_pod_info raises JSONDecodeError for non-existant pod HOT 3
- Pushing an image with `/` in the name to a remote registry does not work HOT 4
- Issues pulling images with similar tags (cannot pull one with a shorter left substring than a pre-existing image) HOT 2
- podman network: support for "--route" option HOT 1
- podman_container: support for "--pull" option HOT 4
- Absent state with quadlet should remove quadlet file as well as podman resource. HOT 3
- Wrong Podman Secret Creation Behavior HOT 3
- Support shm-size when specifying a pod
- Pod not idemponent when port is bound to 0.0.0.0/ maybe same as issue #679
- quadlet creates wrong healthcheck command for container HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-podman-collections.