8000 fix(docs): update the systemd container guide to use podman's systemd mode by jeffcpullen · Pull Request #4680 · ansible/molecule · GitHub
[go: up one dir, main page]

Skip to content

fix(docs): update the systemd container guide to use podman's systemd mode - #4680

Merged
tanwigeetika1618 merged 3 commits into
ansible:mainfrom
jeffcpullen:docs/systemd-container-native
Aug 7, 2026
Merged

tanwigeetika1618 merged 3 commits into
ansible:mainfrom
jeffcpullen:docs/systemd-container-native

Conversation

@jeffcpullen
@jeffcpullen jeffcpullen commented Aug 5, 2026 •
Copy link
Copy Markdown
Contributor

Part of #4679.

What

Rewrites docs/guides/systemd-container.md to show the current way to run a systemd-capable test container. The old guide configured systemd through a platforms: block (command: /sbin/init plus tmpfs and a /sys/fs/cgroup volume mount) driven by the Docker driver, which now lives in the external molecule-plugins collection rather than in Molecule.

Rather than introduce a second, competing scenario, the rewrite builds on the existing Using podman containers example, whose create.yml is already driven by inventory variables (container_image, container_command, container_systemd, container_capabilities, container_privileged). Making that scenario systemd-capable is an inventory change, not a new create.yml: point each host at an init image, and set two shared group variables in the same inventory file:

# inventory/hosts.yml, under the molecule group's vars:
container_command: /sbin/init
container_systemd: always

The guide then swaps the example's OS-checking converge and verify: converge applies the role under test (include_role), and verify asserts the service that role manages is active. Extended privileges reuse the example's container_capabilities / container_privileged.

Why

Testing a role that manages services needs systemd running as PID 1, which a plain container does not provide. As written, the guide points readers at a Docker-driver configuration that Molecule no longer ships.

Verification

I built the scenario the guide describes on top of the Using podman containers example: its exact create.yml, destroy.yml, and cleanup.yml, the systemd inventory changes above, and the converge/verify playbooks shown in the guide. converge.yml applies your_role; the proof scenario stands that in with a small role that installs and starts a unit, the way a real service-managing role would. The inventory has two hosts so the guide is exercised across distributions: ubi10 (registry.access.redhat.com/ubi10/ubi-init:latest) and centos-stream10 (quay.io/centos/centos:stream10). Environment: Molecule 26.6.0 on Python 3.14, containers.podman 1.20.2.

molecule test passes the full sequence on both hosts and is idempotent:

molecule test, full sequence, exit 0, both hosts
INFO     [default > create] Executing
PLAY [Create container instances] **********************************************
TASK [Create containers from inventory] ****************************************
changed: [localhost] => (item=ubi10)
changed: [localhost] => (item=centos-stream10)
INFO     [default > converge] Executing
PLAY [Converge] ****************************************************************
TASK [Apply the role under test] ***********************************************
included: your_role for ubi10, centos-stream10
TASK [your_role : Install the demo unit] ***************************************
TASK [your_role : Enable and start the unit] ***********************************
ubi10                      : ok=3    changed=2    unreachable=0    failed=0
centos-stream10            : ok=3    changed=2    unreachable=0    failed=0
INFO     [default > idempotence] Executing
PLAY [Converge] ****************************************************************
ubi10                      : ok=3    changed=0    unreachable=0    failed=0
centos-stream10            : ok=3    changed=0    unreachable=0    failed=0
INFO     [default > verify] Executing
PLAY [Verify] ******************************************************************
TASK [Confirm systemd is running the managed service] **************************
    "msg": "demo.service is active"
    "msg": "demo.service is active"
ubi10                      : ok=2    changed=0    unreachable=0    failed=0
centos-stream10            : ok=2    changed=0    unreachable=0    failed=0
INFO     [default > cleanup] Executing
INFO     [default > destroy] Executing
SCENARIO RECAP *****************************************************************
default                   : actions=8  successful=7  disabled=0  skipped=0  missing=0  failed=0

Both hosts run the role, are idempotent (changed=0 on the second pass), and verify.yml asserts the managed service is active via service_facts on each.

The guide tells readers to override container_command to the image's init. That instruction is load-bearing, so I confirmed the failure it prevents: with container_command left at the example's default (sleep 1d) and only container_systemd: always set, the role's service task fails because systemd is not PID 1:

Without the container_command override, converge fails as documented
TASK [your_role : Enable and start the unit] ***********************************
fatal: [ubi10]: FAILED! => {"changed": false, "msg": "failure 1 during daemon-reload:
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to system scope bus via local transport: Host is down"}

ansible-lint is clean at the production profile (run with containers.podman installed from requirements.yml):

ansible-lint, clean at the production profile
Passed: 0 failure(s), 0 warning(s) in 11 files processed of 11 encountered.
Last profile that met the validation criteria was 'production'.

tox -e docs renders the guide with no errors of its own; the Jinja in the YAML examples is wrapped in {% raw %} so the mkdocs-macros plugin renders it. The --strict build currently aborts on one external error, mkdocstrings loading https://docs.ansible.com/projects/ansible/latest/objects.inv (HTTP 429), which is unrelated to this diff and hits real CI identically.

Scope

I kept this to the one guide so it is easy to review. Five other pages still use the legacy platforms:/driver:/provisioner: syntax (docker-rootless, podman-inside-docker, sharing, monolith, and ci.md); I opened #4679 to agree the direction before converting them. I am happy to do them the same way, building and running each, as follow-ups.

Summary by CodeRabbit

  • Documentation
    • Replaced the systemd container guide with instructions for the Podman-based Molecule example.
    • Added configuration guidance for init images, cgroups, capabilities, privileged mode, and seccomp limitations.
    • Documented converge and verification playbooks for applying roles and checking managed services.
    • Added troubleshooting guidance for common systemd container setup and permission issues.

The systemd container guide used the pre ansible-native platforms/driver
model (command: /sbin/init plus tmpfs and a /sys/fs/cgroup volume mount).
Rewrite it for the native model as a delta on the existing "Using podman
containers" example: making that inventory-driven scenario systemd-capable
is an init image per host plus two shared inventory group vars
(container_command: /sbin/init, container_systemd: always). Converge applies
the role under test (include_role) and verify asserts the service it manages
is active. The inventory covers UBI 10 init and CentOS Stream 10. Extended
privileges reuse the example's container_capabilities / container_privileged.

Refs ansible#4679

Assisted-by: Claude (Anthropic)
Signed-off-by: Jeff Pullen <9343691+jeffcpullen@users.noreply.github.com>
@coderabbitai
coderabbitai Bot commented Aug 5, 2026 •
Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The systemd container guide now documents inventory-driven Podman configuration, init images, cgroup requirements, converge and verify playbooks, privilege settings, seccomp limits, security warnings, and troubleshooting steps.

Changes

Systemd container guide

Layer / File(s) Summary
Container configuration
docs/guides/systemd-container.md
The guide uses inventory variables, init images, /sbin/init, and container_systemd: always. It documents cgroup v2 requirements.
Service convergence and verification
docs/guides/systemd-container.md
The guide adds converge and verify playbooks that apply a role and check that demo.service is running, including oneshot units.
Privileges and troubleshooting
docs/guides/systemd-container.md
The guide documents capability and privileged-mode settings, seccomp configuration, security warnings, and common systemd container failures.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: alisonlhart, ansibuddy, cidrblock

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the documentation update to use Podman systemd mode.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jeffcpullen jeffcpullen changed the title docs: update the systemd container guide to use podman's systemd mode fix(docs): update the systemd container guide to use podman's systemd mode Aug 5, 2026
The PR was retitled docs: -> fix(docs): to satisfy the ack label gate, but
the autolabeler only fires on synchronize, not on a title edit. This empty
commit triggers it so the fix label is applied. Squashed away on merge.

Assisted-by: Claude (Anthropic)
Signed-off-by: Jeff Pullen <9343691+jeffcpullen@users.noreply.github.com>
@tanwigeetika1618
Copy link
Copy Markdown
Contributor

Codecov is still pending because this is a docs-only change and there is no source-code coverage for Codecov to report. All other CI checks are passing. As this PR only updates documentation, we're bypassing the Codecov requirement to proceed with the merge.

@shatakshiiii
shatakshiiii enabled auto-merge (squash) August 7, 2026 08:13
@shatakshiiii
shatakshiiii disabled auto-merge August 7, 2026 08:13
@tanwigeetika1618
tanwigeetika1618 merged commit 2927f3f into ansible:main Aug 7, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in 🧰 devtools project board Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants

0