Here’s what my template for a Ghost “.container” file looks like today. Ansible will render it with template variables and then Podman will use it to generate a systemd service file like “ghost_my-blog-com.service”.
The generated service file will work like the one that Ghost itself generates, with the benefit that the service will now be containerized.
# MANAGED BY ANSIBLE
[Unit]
Description=Ghost Blog for {{ ghost_fqdn }}
After=network-online.target
# Keys are sorted in alpha-order
[Container]
# The name structure is exactly like what Ghost would create
ContainerName={{ ghost_service_name }}
Image={{ ghost_image }}
# TODO: Currently this is not setup for you and there's no option to disable it either.
# We should do one or the other.
Network={{ ghost_network_name }}.network
# Pick a value within 10.10.*.*.
IP={{ ghost_ip }}
#RunInit=true
# Map the "node" user in the container with UID 1000 inside the container to custom host user.
#UIDMap=1000:{{ ghost_mgr.uid }}
Volume={{ ghost_content_path }}:/var/lib/ghost/content:z
Volume={{ ghost_install_path }}/config.production.json:/var/lib/ghost/config.production.json:z
{#
# systemctl enabled/disable doesn't work on the transient systemd units generated by Quadlet
# Instead, we can add or remove this block to achieve the same effect.
#}
{% if ghost_enabled %}
[Install]
WantedBy=network-online.target
{% endif %}
# vi:ft=systemd
You can see I’m giving each Ghost blog a unique IP and adding to the same network, like “mysql.network”, so they can access a shared MySQL database.