1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00
ansible-podman-collections/docs/podman_generate_systemd_module.html
Sergey 3087fcc353
Release 1.15.4 (#801)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2024-07-12 11:17:46 +03:00

492 lines
No EOL
42 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta content="2.5.0" name="antsibull-docs" />
<title>containers.podman.podman_generate_systemd module Generate systemd unit from a pod or a container &#8212; Python documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="_static/antsibull-minimal.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="containers.podman.podman_image module Pull images for use by podman" href="podman_image_module.html" />
<link rel="prev" title="containers.podman.podman_export module Export a podman container" href="podman_export_module.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<span class="target" id="ansible-collections-containers-podman-podman-generate-systemd-module"></span><section id="containers-podman-podman-generate-systemd-module-generate-systemd-unit-from-a-pod-or-a-container">
<h1>containers.podman.podman_generate_systemd module Generate systemd unit from a pod or a container<a class="headerlink" href="#containers-podman-podman-generate-systemd-module-generate-systemd-unit-from-a-pod-or-a-container" title="Permalink to this heading"></a></h1>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This module is part of the <a class="reference external" href="https://galaxy.ansible.com/ui/repo/published/containers/podman/">containers.podman collection</a> (version 1.15.4).</p>
<p>It is not included in <code class="docutils literal notranslate"><span class="pre">ansible-core</span></code>.
To check whether it is installed, run <code class="code docutils literal notranslate"><span class="pre">ansible-galaxy</span> <span class="pre">collection</span> <span class="pre">list</span></code>.</p>
<p>To install it, use: <code class="code docutils literal notranslate"><span class="pre">ansible-galaxy</span> <span class="pre">collection</span> <span class="pre">install</span> <span class="pre">containers.podman</span></code>.
You need further requirements to be able to use this module,
see <a class="reference internal" href="#ansible-collections-containers-podman-podman-generate-systemd-module-requirements"><span class="std std-ref">Requirements</span></a> for details.</p>
<p>To use it in a playbook, specify: <code class="code docutils literal notranslate"><span class="pre">containers.podman.podman_generate_systemd</span></code>.</p>
</div>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#synopsis" id="id1">Synopsis</a></p></li>
<li><p><a class="reference internal" href="#requirements" id="id2">Requirements</a></p></li>
<li><p><a class="reference internal" href="#parameters" id="id3">Parameters</a></p></li>
<li><p><a class="reference internal" href="#notes" id="id4">Notes</a></p></li>
<li><p><a class="reference internal" href="#examples" id="id5">Examples</a></p></li>
<li><p><a class="reference internal" href="#return-values" id="id6">Return Values</a></p></li>
</ul>
</nav>
<section id="synopsis">
<h2><a class="toc-backref" href="#id1" role="doc-backlink">Synopsis</a><a class="headerlink" href="#synopsis" title="Permalink to this heading"></a></h2>
<ul class="simple">
<li><p>Generate systemd .service unit file(s) from a pod or a container</p></li>
<li><p>Support Ansible check mode</p></li>
</ul>
</section>
<section id="requirements">
<span id="ansible-collections-containers-podman-podman-generate-systemd-module-requirements"></span><h2><a class="toc-backref" href="#id2" role="doc-backlink">Requirements</a><a class="headerlink" href="#requirements" title="Permalink to this heading"></a></h2>
<p>The below requirements are needed on the host that executes this module.</p>
<ul class="simple">
<li><p>Podman installed on target host</p></li>
</ul>
</section>
<section id="parameters">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Parameters</a><a class="headerlink" href="#parameters" title="Permalink to this heading"></a></h2>
<table class="longtable ansible-option-table docutils align-default" style="width: 100%">
<thead>
<tr class="row-odd"><th class="head"><p>Parameter</p></th>
<th class="head"><p>Comments</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-after"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-after"><strong>after</strong></p>
<a class="ansibleOptionLink" href="#parameter-after" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Add the systemd unit after (<code class="docutils literal notranslate"><span class="pre">After=</span></code>) option, that ordering dependencies between the list of dependencies and this service.</p>
<p>This option may be specified more than once.</p>
<p>User-defined dependencies will be appended to the generated unit file</p>
<p>But any existing options such as needed or defined by default (e.g. <code class="docutils literal notranslate"><span class="pre">online.target</span></code>) will not be removed or overridden.</p>
<p>Only with Podman 4.0.0 and above</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-container_prefix"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-container-prefix"><strong>container_prefix</strong></p>
<a class="ansibleOptionLink" href="#parameter-container_prefix" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Set the systemd unit name prefix for containers.</p>
<p>If not set, use the default defined by podman, <code class="docutils literal notranslate"><span class="pre">container</span></code>.</p>
<p>Refer to podman-generate-systemd(1) man page for more information.</p>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-dest"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-dest"><strong>dest</strong></p>
<a class="ansibleOptionLink" href="#parameter-dest" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">path</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Destination of the generated systemd unit file(s).</p>
<p>Use <code class="docutils literal notranslate"><span class="pre">/etc/systemd/system</span></code> for the system-wide systemd instance.</p>
<p>Use <code class="docutils literal notranslate"><span class="pre">/etc/systemd/user</span></code> or <code class="docutils literal notranslate"><span class="pre">~/.config/systemd/user</span></code> for use with per-user instances of systemd.</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-env"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-env"><strong>env</strong></p>
<a class="ansibleOptionLink" href="#parameter-env" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">dictionary</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Set environment variables to the systemd unit files.</p>
<p>Keys are the environment variable names, and values are the environment variable values</p>
<p>Only with Podman 4.3.0 and above</p>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-executable"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-executable"><strong>executable</strong></p>
<a class="ansibleOptionLink" href="#parameter-executable" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p><code class="docutils literal notranslate"><span class="pre">Podman</span></code> executable name or full path</p>
<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;podman&quot;</span></code></p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-force"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-force"><strong>force</strong></p>
<a class="ansibleOptionLink" href="#parameter-force" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Replace the systemd unit file(s) even if it already exists.</p>
<p>This works with dest option.</p>
<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
<ul class="simple">
<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">false</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">true</span></code></p></li>
</ul>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-name"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-name"><strong>name</strong></p>
<a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span> / <span class="ansible-option-required">required</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Name of the pod or container to export</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-new"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-new"><strong>new</strong></p>
<a class="ansibleOptionLink" href="#parameter-new" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Generate unit files that create containers and pods, not only start them.</p>
<p>Refer to podman-generate-systemd(1) man page for more information.</p>
<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
<ul class="simple">
<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">false</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">true</span></code></p></li>
</ul>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-no_header"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-no-header"><strong>no_header</strong></p>
<a class="ansibleOptionLink" href="#parameter-no_header" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Do not generate the header including meta data such as the Podman version and the timestamp.</p>
<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
<ul class="simple">
<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">false</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">true</span></code></p></li>
</ul>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-pod_prefix"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-pod-prefix"><strong>pod_prefix</strong></p>
<a class="ansibleOptionLink" href="#parameter-pod_prefix" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Set the systemd unit name prefix for pods.</p>
<p>If not set, use the default defined by podman, <code class="docutils literal notranslate"><span class="pre">pod</span></code>.</p>
<p>Refer to podman-generate-systemd(1) man page for more information.</p>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-requires"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-requires"><strong>requires</strong></p>
<a class="ansibleOptionLink" href="#parameter-requires" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Set the systemd unit requires (Requires=) option.</p>
<p>Similar to wants, but declares a stronger requirement dependency.</p>
<p>Only with Podman 4.0.0 and above</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-restart_policy"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-restart-policy"><strong>restart_policy</strong></p>
<a class="ansibleOptionLink" href="#parameter-restart_policy" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Restart policy of the service</p>
<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
<ul class="simple">
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;no-restart&quot;</span></code></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;on-success&quot;</span></code></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;on-failure&quot;</span></code></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;on-abnormal&quot;</span></code></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;on-watchdog&quot;</span></code></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;on-abort&quot;</span></code></p></li>
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;always&quot;</span></code></p></li>
</ul>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-restart_sec"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-restart-sec"><strong>restart_sec</strong></p>
<a class="ansibleOptionLink" href="#parameter-restart_sec" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">integer</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Configures the time to sleep before restarting a service (as configured with restart-policy).</p>
<p>Takes a value in seconds.</p>
<p>Only with Podman 4.0.0 and above</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-separator"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-separator"><strong>separator</strong></p>
<a class="ansibleOptionLink" href="#parameter-separator" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Systemd unit name separator between the name/id of a container/pod and the prefix.</p>
<p>If not set, use the default defined by podman, <code class="docutils literal notranslate"><span class="pre">-</span></code>.</p>
<p>Refer to podman-generate-systemd(1) man page for more information.</p>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-start_timeout"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-start-timeout"><strong>start_timeout</strong></p>
<a class="ansibleOptionLink" href="#parameter-start_timeout" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">integer</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Override the default start timeout for the container with the given value in seconds.</p>
<p>Only with Podman 4.0.0 and above</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-stop_timeout"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-stop-timeout"><strong>stop_timeout</strong></p>
<a class="ansibleOptionLink" href="#parameter-stop_timeout" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">integer</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Override the default stop timeout for the container with the given value in seconds.</p>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-use_names"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-use-names"><strong>use_names</strong></p>
<a class="ansibleOptionLink" href="#parameter-use_names" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Use name of the containers for the start, stop, and description in the unit file.</p>
<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
<ul class="simple">
<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">false</span></code></p></li>
<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">true</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
</ul>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-wants"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-parameter-wants"><strong>wants</strong></p>
<a class="ansibleOptionLink" href="#parameter-wants" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>Add the systemd unit wants (<code class="docutils literal notranslate"><span class="pre">Wants=</span></code>) option, that this service is (weak) dependent on.</p>
<p>This option may be specified more than once.</p>
<p>This option does not influence the order in which services are started or stopped.</p>
<p>User-defined dependencies will be appended to the generated unit file</p>
<p>But any existing options such as needed or defined by default (e.g. <code class="docutils literal notranslate"><span class="pre">online.target</span></code>) will not be removed or overridden.</p>
<p>Only with Podman 4.0.0 and above</p>
</div></td>
</tr>
</tbody>
</table>
</section>
<section id="notes">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">Notes</a><a class="headerlink" href="#notes" title="Permalink to this heading"></a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>If you indicate a pod, the systemd units for it and all its containers will be generated</p></li>
<li><p>Create all your pods, containers and their dependencies before generating the systemd files</p></li>
<li><p>If a container or pod is already started before you do a <code class="docutils literal notranslate"><span class="pre">systemctl</span> <span class="pre">daemon-reload</span></code>, systemd will not see the container or pod as started</p></li>
<li><p>Stop your container or pod before you do a <code class="docutils literal notranslate"><span class="pre">systemctl</span> <span class="pre">daemon-reload</span></code>, then you can start them with <code class="docutils literal notranslate"><span class="pre">systemctl</span> <span class="pre">start</span> <span class="pre">my_container.service</span></code></p></li>
</ul>
</div>
</section>
<section id="examples">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Examples</a><a class="headerlink" href="#examples" title="Permalink to this heading"></a></h2>
<div class="highlight-yaml+jinja notranslate"><div class="highlight"><pre><span></span><span class="c1"># Example of creating a container and systemd unit file.</span>
<span class="c1"># When using podman_generate_systemd with new:true then</span>
<span class="c1"># the container needs rm:true for idempotence.</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Create postgres container</span>
<span class="w"> </span><span class="nt">containers.podman.podman_container</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres</span>
<span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">docker.io/library/postgres:latest</span>
<span class="w"> </span><span class="nt">rm</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="w"> </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">created</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Generate systemd unit file for postgres container</span>
<span class="w"> </span><span class="nt">containers.podman.podman_generate_systemd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres</span>
<span class="w"> </span><span class="nt">new</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="w"> </span><span class="nt">no_header</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="w"> </span><span class="nt">dest</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">/etc/systemd/system</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Ensure postgres container is started and enabled</span>
<span class="w"> </span><span class="nt">ansible.builtin.systemd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">container-postgres</span>
<span class="w"> </span><span class="nt">daemon_reload</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="w"> </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">started</span>
<span class="w"> </span><span class="nt">enabled</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="c1"># Example of creating a container and integrate it into systemd</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">A postgres container must exist, stopped</span>
<span class="w"> </span><span class="nt">containers.podman.podman_container</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres_local</span>
<span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">docker.io/library/postgres:latest</span>
<span class="w"> </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">stopped</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Systemd unit files for postgres container must exist</span>
<span class="w"> </span><span class="nt">containers.podman.podman_generate_systemd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres_local</span>
<span class="w"> </span><span class="nt">dest</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">~/.config/systemd/user/</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Postgres container must be started and enabled on systemd</span>
<span class="w"> </span><span class="nt">ansible.builtin.systemd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">container-postgres_local</span>
<span class="w"> </span><span class="nt">scope</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">user</span>
<span class="w"> </span><span class="nt">daemon_reload</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="w"> </span><span class="nt">state</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">started</span>
<span class="w"> </span><span class="nt">enabled</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
<span class="c1"># Generate the unit files, but store them on an Ansible variable</span>
<span class="c1"># instead of writing them on target host</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Systemd unit files for postgres container must be generated</span>
<span class="w"> </span><span class="nt">containers.podman.podman_generate_systemd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres_local</span>
<span class="w"> </span><span class="nt">register</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres_local_systemd_unit</span>
<span class="c1"># Generate the unit files with environment variables sets</span>
<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Systemd unit files for postgres container must be generated</span>
<span class="w"> </span><span class="nt">containers.podman.podman_generate_systemd</span><span class="p">:</span>
<span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres_local</span>
<span class="w"> </span><span class="nt">env</span><span class="p">:</span>
<span class="w"> </span><span class="nt">POSTGRES_USER</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_app</span>
<span class="w"> </span><span class="nt">POSTGRES_PASSWORD</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">example</span>
<span class="w"> </span><span class="nt">register</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgres_local_systemd_unit</span>
</pre></div>
</div>
</section>
<section id="return-values">
<h2><a class="toc-backref" href="#id6" role="doc-backlink">Return Values</a><a class="headerlink" href="#return-values" title="Permalink to this heading"></a></h2>
<p>Common return values are documented <span class="xref std std-ref">here</span>, the following are the fields unique to this module:</p>
<table class="longtable ansible-option-table docutils align-default" style="width: 100%">
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="return-podman_command"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-return-podman-command"><strong>podman_command</strong></p>
<a class="ansibleOptionLink" href="#return-podman_command" title="Permalink to this return value"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>A copy of the podman command used to generate the systemd unit(s)</p>
<p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> always</p>
<p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-option-sample docutils literal notranslate"><span class="pre">&quot;podman</span> <span class="pre">generate</span> <span class="pre">systemd</span> <span class="pre">my_webapp&quot;</span></code></p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="return-systemd_units"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-generate-systemd-module-return-systemd-units"><strong>systemd_units</strong></p>
<a class="ansibleOptionLink" href="#return-systemd_units" title="Permalink to this return value"></a><p class="ansible-option-type-line"><span class="ansible-option-type">dictionary</span></p>
</div></td>
<td><div class="ansible-option-cell"><p>A copy of the generated systemd .service unit(s)</p>
<p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> always</p>
<p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-option-sample docutils literal notranslate"><span class="pre">{&quot;container-postgres_local&quot;:</span> <span class="pre">&quot;</span> <span class="pre">#Content</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">systemd</span> <span class="pre">.servec</span> <span class="pre">unit</span> <span class="pre">for</span> <span class="pre">postgres_local</span> <span class="pre">container&quot;,</span> <span class="pre">&quot;pod-my_webapp&quot;:</span> <span class="pre">&quot;</span> <span class="pre">#Content</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">systemd</span> <span class="pre">.servec</span> <span class="pre">unit</span> <span class="pre">for</span> <span class="pre">my_webapp</span> <span class="pre">pod&quot;}</span></code></p>
</div></td>
</tr>
</tbody>
</table>
<section id="authors">
<h3>Authors<a class="headerlink" href="#authors" title="Permalink to this heading"></a></h3>
<ul class="simple">
<li><p>Sébastien Gendre (&#64;CyberFox001)</p></li>
</ul>
</section>
<section id="collection-links">
<h3>Collection links<a class="headerlink" href="#collection-links" title="Permalink to this heading"></a></h3>
<ul class="ansible-links">
<li><span><a aria-role="button" class="ansible-link reference external" href="https://github.com/containers/ansible-podman-collections/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" rel="noopener external" target="_blank">Issue Tracker</a></span></li>
<li><span><a aria-role="button" class="ansible-link reference external" href="https://github.com/containers/ansible-podman-collections" rel="noopener external" target="_blank">Repository (Sources)</a></span></li>
</ul>
</section>
</section>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">Python</a></h1>
<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="podman_container_module.html">containers.podman.podman_container module Manage podman containers</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_container_exec_module.html">containers.podman.podman_container_exec module Executes a command in a running container.</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_container_info_module.html">containers.podman.podman_container_info module Gather facts about containers using podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_containers_module.html">containers.podman.podman_containers module Manage podman containers in a batch</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_export_module.html">containers.podman.podman_export module Export a podman container</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">containers.podman.podman_generate_systemd module Generate systemd unit from a pod or a container</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_image_module.html">containers.podman.podman_image module Pull images for use by podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_image_info_module.html">containers.podman.podman_image_info module Gather info about images using podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_import_module.html">containers.podman.podman_import module Import Podman container from a tar file.</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_load_module.html">containers.podman.podman_load module Load image from a tar file.</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_login_module.html">containers.podman.podman_login module Login to a container registry using podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_login_info_module.html">containers.podman.podman_login_info module Return the logged-in user if any for a given registry</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_logout_module.html">containers.podman.podman_logout module Log out of a container registry using podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_network_module.html">containers.podman.podman_network module Manage podman networks</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_network_info_module.html">containers.podman.podman_network_info module Gather info about podman networks</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_play_module.html">containers.podman.podman_play module Play kubernetes YAML file using podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_pod_module.html">containers.podman.podman_pod module Manage Podman pods</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_pod_info_module.html">containers.podman.podman_pod_info module Gather info about podman pods</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_prune_module.html">containers.podman.podman_prune module Allows to prune various podman objects</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_runlabel_module.html">containers.podman.podman_runlabel module Run given label from given image</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_save_module.html">containers.podman.podman_save module Saves podman image to tar file</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_search_module.html">containers.podman.podman_search module Search for remote images using podman</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_secret_module.html">containers.podman.podman_secret module Manage podman secrets</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_secret_info_module.html">containers.podman.podman_secret_info module Gather info about podman secrets</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_tag_module.html">containers.podman.podman_tag module Add an additional name to a local image</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_volume_module.html">containers.podman.podman_volume module Manage Podman volumes</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_volume_info_module.html">containers.podman.podman_volume_info module Gather info about podman volumes</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="podman_unshare_become.html">containers.podman.podman_unshare become Run tasks using podman unshare</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="buildah_connection.html">containers.podman.buildah connection Interact with an existing buildah container</a></li>
<li class="toctree-l1"><a class="reference internal" href="podman_connection.html">containers.podman.podman connection Interact with an existing podman container</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="podman_export_module.html" title="previous chapter">containers.podman.podman_export module Export a podman container</a></li>
<li>Next: <a href="podman_image_module.html" title="next chapter">containers.podman.podman_image module Pull images for use by podman</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 7.0.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
|
<a href="_sources/podman_generate_systemd_module.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>