Offline and air-gapped installs
The playbooks can install and operate pgcli without reaching GitHub, ghcr.io,
Docker Hub or distro mirrors. A single static HTTP directory on the LAN can
serve every artifact: consumers always fetch <base>/<basename>, so one flat
server root is enough.
What the server hosts
| Variable | Artifact | Consumed by |
|---|---|---|
pgcli_images_http_url |
podman save tarballs produced by make container-images-export |
pgcli role during install; pg_addon / pg_ha_haproxy lazily |
pgcli_install_binary_url |
pg binary — raw file or pgcli_<version>_linux_amd64.tar.gz |
pgcli role |
pgcli_podman_binary_url |
podman-launcher binary |
pgcli role when /usr/local/bin/podman is missing |
pgcli_download_mirror |
host binaries (juicefs, zerofs, duckdb, Litestream) and DocumentDB DEBs | pg at runtime through PGCLI_DOWNLOAD_MIRROR |
All four are set in group_vars/all/main.yml; the committed template is
group_vars/all/main.yml.example.
Changing the variables
The live file is gitignored. Copy the template on first use, then edit it in place:
Point every family at the same server root, and leave a variable empty to keep the online path for that artifact:
Variable precedence is host_vars/<host>.yml >
group_vars/<group>/main.yml > group_vars/all/main.yml. Override only the
hosts or groups that differ instead of editing all when both online and
offline hosts are managed from the same inventory. pgcli_images is a complete
replacement list, not a merge, so a scenario group that defines its own list
overrides the one in all.
Edits take effect on the next playbook run. The binary is only reinstalled when
pg is missing or pgcli_install_force: true; image tarballs are only fetched
when the tag is absent from the local podman store (or
pgcli_images_force_load: true).
On an air-gapped control node, point pgcli_install_script_src at a local
checkout instead of the GitHub raw URL:
The role then copies the script to the target host; only an http(s):// value
is downloaded on the host.
Egress proxy
When hosts reach the internet only through a forward proxy (for example a
Privoxy add-on on a connected machine), set the global pgcli_proxy_url
instead of — or alongside — the LAN mirror. Proxy startup, the full variable
set, NO_PROXY rules, manual SSH usage and verification are covered in
Egress proxy.
Starting the server with pg http
To export every image and wire the server up to Ansible step by step, see Offline image server. The rest of this page places that server in the context of all offline artifacts.
pg http is pgcli’s built-in static file server. It runs as a detached host
process (no container) and supports HEAD/Range requests, which the image
loader and its pre-checks rely on.
- If the requested port is busy, the next free port is used (up to 100
attempts). Check
pg http statusand keep the URLs ingroup_vars/allconsistent with the port actually bound. - The server is detached and survives the terminal that started it. It does
not start at boot unless enabled:
pg autostart enable --http --name http-18080. - There is no authentication. Keep the listener on a trusted network.
--tlsencrypts traffic but does not authenticate clients. - Files must sit directly in the served directory: every consumer requests
<base>/<basename>, with no path prefix.
Container images
make container-images-export exports every image in the Makefile IMAGES
list as images/<repo>_<tag>.tar (: becomes _; the export pins
linux/amd64). The manifest in group_vars/all/main.yml must use exactly
those archive names:
How the list is consumed:
- Entries without
auto_loadare core images. The install play loads them into podman’s local store after checking that each archive is present. auto_load: truewithaddons: [type]marks add-on images. They are loaded on demand by thepg_addonrole when an add-on of a matching type is first created (-in the type name becomes_).pg_ha_haproxyuses the same mechanism for HAProxy.- Setting
pgcli_images_http_urlmakesscripts/install.shrun with--skip-pull; no image is pulled from a registry. - Before changing anything, the install play sends
HEADrequests to the server root and to every core archive, and aborts with the offending names if any is unreachable. Lazy add-on archives are fetched when first needed.
Trim the list to the images a scenario actually uses: the first run on a host
with an empty store transfers only the listed core archives. Keep pgcli-pg
and pgcli-backup; add one entry per add-on type in use (remove auto_load
to preload it during install instead of on first use).
Transferred tarballs are cached on the target host. The cache is kept across runs — only missing images are transferred again — and is safe to delete:
| Layout | Cache directory |
|---|---|
| rootful | /var/cache/pgcli/images |
| rootless | ~/.cache/pgcli/images under the deployment account |
Rootless podman uses a separate image store owned by the deployment account. Images already loaded as root are not visible there, so the rootless install loads its own copy from the offline server.
The pg binary and the podman launcher
pgcli_install_binary_url accepts either a raw pg binary or a release
tarball named pgcli_<version>_linux_amd64.tar.gz. A tarball is extracted and
its top-level pg member is installed to pgcli_install_path
(/usr/local/bin/pg by default); a raw file is copied as-is. In both cases
scripts/install.sh still runs with --skip-binary, so host initialization
(uidmap, /etc/containers/policy.json, user namespaces, SELinux) is not
skipped.
pgcli_podman_binary_url installs the podman-launcher binary as
/usr/local/bin/podman when no podman exists on the host. The launcher fetches
its static podman tree on first use, so a fully air-gapped host still needs
podman pre-installed (distribution package or a pre-seeded launcher state)
before the first podman invocation succeeds.
Runtime downloads: host binaries and DEBs
Some add-ons download assets when they are created, after installation is
already complete. pgcli_download_mirror redirects those downloads: the
playbooks export it as PGCLI_DOWNLOAD_MIRROR to every pg command, and
pgcli rewrites any http(s) asset URL to <mirror>/<basename>. URLs already
under the mirror and non-HTTP paths are left untouched.
Place the upstream assets under their original file names:
| Consumer | Asset basename |
|---|---|
pg addon install juicefs |
juicefs-1.4.1-linux-amd64.tar.gz / juicefs-1.4.1-linux-arm64.tar.gz |
pg addon install zerofs |
zerofs-pgo-multiplatform.tar.gz |
pg addon install duckdb |
duckdb_cli-linux-amd64.zip (1.x, default 1.5.6) or duckdb-cli-linux-amd64.tar.gz (2.x, pinned 2.0.0); amd64 only |
pg sqlite install (Litestream) |
litestream-0.5.17-linux-x86_64.tar.gz (amd64) / litestream-0.5.17-linux-arm64.tar.gz |
pg extension install documentdb |
ubuntu24.04-postgresql-18-documentdb_1.0-0_<arch>.deb and libicu74_74.2-1ubuntu3.1_<arch>.deb |
Behavior and caveats:
- pgcli still verifies pinned SHA-256 digests after downloading, so mirrored files must be byte-identical to the upstream release assets.
- Use pinned versions.
--version latestqueries the GitHub API, which is not redirected by the mirror. - The DocumentDB DEBs are copied into the derived extension image and installed there; the mirror covers exactly these two packages.
- Other catalog extensions are built from the Pigsty DEB repository inside
podman build, whichpgcli_download_mirrordoes not redirect. Withpgcli_proxy_urlset, the build’s apt and curl use that proxy; on a fully air-gapped network, pre-build the derived-extimage on a connected host (or mirror the Pigsty repository and point apt at it on the build host) and distribute the image throughpgcli_images. - Litestream is not an add-on:
pg sqlite installprovisions sqlite3 and the pinned Litestream binary. Setpgcli_sqlite_install: trueon the hosts or groups that use SQLite and thepgclirole runs it during the install play, with the same mirror redirect. sqlite3 itself comes from the distribution package manager, so air-gapped hosts need that package preinstalled (or a local distro mirror). - Outside Ansible, export
PGCLI_DOWNLOAD_MIRRORyourself before running manualpg addon install/pg extension install/pg sqlite installcommands.
Reference file list
The current LAN server is a complete mirror of the default pgcli_images
manifest (44 image tarballs) plus the install binaries and every runtime asset
at the versions pgcli pins. Use it as the authoritative checklist when building
a new server; regenerate the image names with make container-images-export
whenever image tags change.
Each line is <sha256> <filename> (sha256sum format), so a downloaded
directory can be verified with sha256sum -c.
The runtime assets cover every create-time download through
pgcli_download_mirror, at the versions pgcli pins: juicefs 1.4.1
(amd64/arm64), duckdb 1.5.6 and 2.0.0 (amd64 only), Litestream 0.5.17
(x86_64/arm64), zerofs, and the DocumentDB DEBs. Other versions fail the
pinned SHA-256 check, so update the pin in pgcli before mirroring a new
release.
Verifying the setup
Check one archive per family, then run a deployment:
The install play fails before making changes when the server root or a core
archive is unreachable; a HEAD request returning anything other than 200
is treated as missing.