This is the multi-page printable view of this section. .
Module: INFRA
- 1: Configuration
- 2: Parameters
- 3: Playbook
- 4: Monitoring
- 5: Metrics
- 6: FAQ
- 7: Administration
Configuration | Administration | Playbooks | Monitoring | Parameters
Overview
Each Pigsty deployment includes infrastructure components that serve managed nodes and database clusters:
| Component | Port | Description |
|---|---|---|
| Nginx | 80/443 | Web service portal, local repo, and unified entry point |
| Grafana | 3000 | Visualization platform for monitoring dashboards and data apps |
| VictoriaMetrics | 8428 | Time-series database with VMUI, compatible with Prometheus API |
| VictoriaLogs | 9428 | Centralized log database, receives structured logs from Vector |
| VictoriaTraces | 10428 | Tracing and event storage for slow SQL / request tracing |
| VMAlert | 8880 | Alert rule evaluator, triggers alerts based on VictoriaMetrics metrics |
| AlertManager | 9059 | Alert aggregation and dispatch, receives notifications from VMAlert |
| BlackboxExporter | 9115 | ICMP/TCP/HTTP blackbox probing |
| DNSMASQ | 53 | DNS server for internal domain resolution |
| Chronyd | 123 | NTP time server |
| PostgreSQL | 5432 | CMDB and default database |
| Ansible | - | Runs playbooks, orchestrates all infrastructure |
In Pigsty, the PGSQL module uses some services on INFRA nodes, specifically:
- Database cluster/host node domains depend on DNSMASQ on INFRA nodes for resolution.
- Installing software on database nodes uses the local yum/apt repo hosted by Nginx on INFRA nodes.
- VictoriaMetrics on INFRA nodes collects and stores database cluster and node metrics. Access them through VMUI / PromQL.
- Vector collects database and node runtime logs and sends them to VictoriaLogs on INFRA nodes. Search these logs in Grafana.
- VMAlert evaluates alert rules based on metrics in VictoriaMetrics and forwards events to Alertmanager.
- Users initiate management of database nodes from Infra/Admin nodes using Ansible or other tools:
- Execute cluster creation, scaling, instance/cluster recycling
- Create business users, databases, modify services, HBA changes;
- Execute log collection, garbage cleanup, backup, inspections, etc.
- Database nodes sync time from the NTP server on INFRA/ADMIN nodes by default
- If no dedicated cluster exists, the HA component Patroni uses etcd on INFRA nodes as the HA DCS.
- If no dedicated cluster exists, the backup component pgbackrest uses MinIO on INFRA nodes as an optional centralized backup repository.
Nginx
Nginx provides access to all Pigsty WebUI services. It uses port 80 on the admin node by default.
Nginx exposes infrastructure WebUIs, including Grafana, VictoriaMetrics (VMUI), AlertManager, and HAProxy traffic management pages. It also serves static files, including yum/apt repositories.
Nginx exposes built-in Web services through subpaths under i.pigsty by default. The infra_portal configuration also lets Nginx route requests to upstream components by domain name.
If you use other domains or public domains, you can modify them here:
Pigsty strongly recommends using domain names to access Pigsty UI systems rather than direct IP+port access, for these reasons:
- Domains simplify HTTPS encryption and centralize access through Nginx. They also simplify request auditing and authentication integration.
- Some components only listen on 127.0.0.1 by default, so they can only be accessed through Nginx proxy.
- Domain names are easier to remember and provide additional configuration flexibility.
Without internet domains or local DNS, add static resolution records on the client. Use /etc/hosts on MacOS/Linux or C:\Windows\System32\drivers\etc\hosts on Windows.
Nginx configuration parameters are at: Configuration: INFRA - NGINX
Local Software Repository
Pigsty creates a local software repository during installation to accelerate subsequent software installation.
Nginx serves this repository. Its default directory is /www/pigsty, and its URL is http://i.pigsty/pigsty.
A Pigsty offline bundle is a compressed prebuilt RPM/APT repository directory. The current source uses SOW to create repositories. If /www/pigsty/repo_complete exists, Pigsty treats the local repository as complete and skips upstream downloads. This file contains SHA-256 checksums. It is not an empty marker.
The repo definition file is at /www/pigsty.repo, accessible by default via http://${admin_ip}/pigsty.repo
You can also use the file local repo directly without Nginx:
Local repository configuration parameters are at: Configuration: INFRA - REPO
Victoria Observability Suite
Pigsty v4 replaces Prometheus/Loki with the VictoriaMetrics family. These components provide integrated monitoring, logging, and tracing:
- VictoriaMetrics listens on port
8428by default. Access VMUI athttps://i.pigsty/vmetrics/. Its API is compatible with Prometheus. You can also configure a dedicated domain ininfra_portal. - VMAlert evaluates alert rules in
/infra/rules/*.yml, listens on port8880, and sends alert events to Alertmanager. - VictoriaLogs listens on port
9428. Query logs throughhttps://i.pigsty/vlogs/. All nodes run Vector by default to send structured system logs, PostgreSQL logs, and other logs to VictoriaLogs. - VictoriaTraces listens on port
10428for slow SQL / Trace collection. Grafana accesses it as a Jaeger datasource. - Alertmanager listens on port
9059. Manage alert notifications athttps://i.pigsty/alertmgr/. To use a dedicated domain, configurea.pigstyininfra_portal. Configure SMTP, Webhook, or another receiver to send notifications. - Blackbox Exporter listens on port
9115by default for Ping/TCP/HTTP probing, accessible viahttps://i.pigsty/blackbox/.
For more information, see: Configuration: INFRA - VICTORIA and Configuration: INFRA - PROMETHEUS.
Grafana
Grafana is the core of Pigsty’s WebUI. It listens on port 3000 by default. Access it through https://i.pigsty/ui/ or directly at IP:3000. To use a dedicated domain, configure g.pigsty in infra_portal.
Pigsty includes preconfigured VictoriaMetrics / Logs / Traces datasources: vmetrics-*, vlogs-*, and vtraces-*. It also includes many dashboards with URL-based navigation to help locate problems quickly.
Grafana also serves as a general low-code visualization platform. Pigsty installs plugins such as ECharts and victoriametrics-datasource by default. Use these plugins to build monitoring dashboards or inspection reports.
Grafana configuration parameters are at: Configuration: INFRA - GRAFANA.
Ansible
Pigsty installs Ansible on the meta node by default. Ansible uses declarative configuration and idempotent playbooks. These features reduce system maintenance complexity.
DNSMASQ
DNSMASQ provides DNS resolution services within the environment. Domain names from other modules are registered with the DNSMASQ service on INFRA nodes.
DNS records are placed by default in the /etc/dnsmasq.d/pigsty/ directory on all INFRA nodes.
DNSMASQ configuration parameters are at: Configuration: INFRA - DNS
Chronyd
NTP service synchronizes time across all nodes in the environment (optional)
NTP configuration parameters are at: Configuration: NODES - NTP
PostgreSQL
Pigsty’s metadata database (CMDB) usually runs on PostgreSQL, listening on port 5432 by default. It stores Pigsty metadata and backs several built-in applications.
For details, see the PGSQL module and Configuration: INFRA - META.
Configuration
To install INFRA on a node, add it to the infra inventory group. Assign an instance number with infra_seq.
Then use the infra.yml playbook to initialize the INFRA module on the nodes.
Administration
Here are some administration tasks related to the INFRA module:
Install/Uninstall Infra Module
infra-rm.yml has no deletion safeguard. Without tags, it removes infra_data, nginx_data, nginx_home (default: /www), and /var/lib/grafana.
If you only need to stop services or deregister targets, use tags. See Playbooks for the complete removal scope.
Manage Local Software Repository
You can use the following playbook subtasks to manage the local yum repo on Infra nodes:
The most commonly used commands are:
Manage Infrastructure Components
You can use the following playbook subtasks to manage various infrastructure components on Infra nodes:
Other commonly used tasks include:
Playbooks
Pigsty provides three playbooks related to the INFRA module:
infra.yml: Initialize pigsty infrastructure on infra nodesinfra-rm.yml: Remove infrastructure components from infra nodesdeploy.yml: Deploy the NODE, INFRA, ETCD, MINIO, and PGSQL core chain in one pass
infra.yml
The INFRA module playbook infra.yml initializes pigsty infrastructure on INFRA nodes
Executing this playbook completes the following tasks
- Configure meta node directories and environment variables
- Download and build a local software repository to accelerate subsequent installation. (If using offline package, skip download phase)
- Add the current meta node as a regular node under Pigsty management
- Deploy infrastructure components including VictoriaMetrics/Logs/Traces, VMAlert, Grafana, Alertmanager, Blackbox Exporter, etc.
This playbook executes on INFRA nodes by default
- Pigsty uses the current node executing this playbook as Pigsty’s INFRA node and ADMIN node by default.
- During configuration, Pigsty marks the current node as the Infra/Admin node. It replaces
10.10.10.10in templates with the current node’s primary IP address. - Besides initiating management and hosting infrastructure, this node is no different from a regular managed node.
- In single-node installation, ETCD is also installed on this node to provide DCS service
Notes about this playbook
- This playbook is idempotent. Repeated execution wipes infrastructure components on meta nodes.
- To preserve historical monitoring data, first set
vmetrics_clean,vlogs_clean,vtraces_cleantofalse. - If
/www/pigsty/repo_completeexists, the playbook skips internet downloads. Full execution takes about 5-8 minutes, depending on machine configuration. - Downloading directly from upstream internet sources without offline package may take 10-20 minutes depending on your network conditions.
infra-rm.yml
The INFRA module playbook infra-rm.yml removes pigsty infrastructure from INFRA nodes
Common subtasks include:
Full execution has no deletion safeguard and removes infra_data, nginx_data, nginx_home (default: /www), and /var/lib/grafana. Back up any data you need before running it.
deploy.yml
The deploy.yml playbook deploys the NODE, INFRA, ETCD, MINIO, and PGSQL core chain on all nodes in one pass. Optional modules such as Docker, Redis, Kafka, native MySQL, JUICE, and VIBE require their own playbooks.
This playbook is described in more detail in Playbook: One-Time Installation.
Monitoring
Pigsty Home: Pigsty monitoring system homepage
INFRA Overview: Pigsty infrastructure self-monitoring overview
Nginx Instance: Nginx metrics and logs
Grafana Instance: Grafana metrics and logs
VictoriaMetrics Instance: VictoriaMetrics scraping, querying, and storage metrics
VMAlert Instance: Alert rule evaluation and queue status
Alertmanager Instance: Alert aggregation, notification pipelines, and Silences
VictoriaLogs Instance: Log ingestion rate, query load, and index hits
VictoriaTraces Instance: Trace/KV storage and Jaeger interface
Logs Instance: Node log search based on Vector + VictoriaLogs
CMDB Overview: CMDB visualization
ETCD Overview: etcd metrics and logs
Parameters
The INFRA module has the following 10 parameter groups.
META: Pigsty metadataCA: Self-signed PKI/CA infrastructureINFRA_ID: Infrastructure portal, Nginx domainsREPO: Local software repositoryINFRA_PACKAGE: Infrastructure software packagesNGINX: Nginx web serverDNS: DNSMASQ domain serverVICTORIA: VictoriaMetrics / Logs / Traces suitePROMETHEUS: Alertmanager and Blackbox ExporterGRAFANA: Grafana observability suite
For the latest default values, types, and hierarchy, please refer to the Parameter Reference to stay consistent with the Pigsty version.
1 - Configuration
Configuration Guide
INFRA primarily provides monitoring infrastructure. It is optional for PostgreSQL databases.
INFRA failures typically do not affect PostgreSQL cluster operation. Exceptions apply if you manually configure dependencies on INFRA DNS/NTP services.
One INFRA node is sufficient for most scenarios. For production HA, we recommend 2-3 INFRA nodes.
ETCD, which PostgreSQL HA requires, can share nodes with INFRA to use resources more efficiently.
More than 3 INFRA nodes provide little extra benefit. More ETCD nodes, such as 5, can improve DCS availability.
Configuration Examples
Add node IP addresses to the infra inventory group. Assign an INFRA instance number with infra_seq.
Default single INFRA node config:
During configuration, Pigsty replaces 10.10.10.10 with the current node’s primary IP address by default.
Run infra.yml to initialize the INFRA module on these nodes.
More Nodes
Two INFRA nodes config:
Three INFRA nodes config (with params):
INFRA High Availability
Most INFRA components have no state or share identical state. Thus, load balancing is the main HA requirement.
Use a Keepalived L2 VIP or HAProxy L4 load balancing for HA. We recommend an L2 VIP where nodes share an accessible L2 network.
Config example:
Set VIP-related params and modify service endpoints in infra_portal.
Nginx Configuration
See Nginx Parameter Config and Tutorial: Nginx.
Local Repo Configuration
DNS Configuration
See DNS Parameter Config and Tutorial: DNS.
NTP Configuration
See NTP Parameter Config.
2 - Parameters
The INFRA module deploys Pigsty infrastructure. This includes the local software repository, Nginx, DNSMasq, VictoriaMetrics, VictoriaLogs, Grafana, Alertmanager, and Blackbox Exporter. It also deploys other monitoring and alerting components.
Pigsty v4.x replaces Prometheus with VictoriaMetrics and Loki with VictoriaLogs for observability.
| Section | Description |
|---|---|
META | Pigsty metadata: version, admin IP, region, language, proxy |
CA | Self-signed CA certificate management |
INFRA_ID | Infrastructure node identity and service portal |
REPO | Local software repository configuration |
INFRA_PACKAGE | Infrastructure node package installation |
NGINX | Nginx web server and reverse proxy configuration |
DNS | DNSMasq DNS server configuration |
VICTORIA | VictoriaMetrics/Logs/Traces observability stack |
PROMETHEUS | Alertmanager and Blackbox Exporter |
GRAFANA | Grafana visualization platform configuration |
Parameter Overview
META parameters define Pigsty metadata, including version string, admin node IP, repository mirror region, default language, and proxy settings.
| Parameter | Type | Level | Description |
|---|---|---|---|
version | string | G | Pigsty version string |
admin_ip | ip | G | Admin node IP address |
region | enum | G | Upstream mirror region: default,china,europe |
language | enum | G | Default language: en or zh |
proxy_env | dict | G | Global proxy environment variables |
CA parameters configure Pigsty’s self-signed CA certificate management, including CA creation, CA name, and certificate validity.
| Parameter | Type | Level | Description |
|---|---|---|---|
ca_create | bool | G | Allow creation if the CA private key is missing? Default true |
ca_cn | string | G | CA CN name, fixed as pigsty-ca |
cert_validity | interval | G | Certificate validity, default 20 years |
INFRA_ID parameters define infrastructure node identity, including node sequence number, service portal configuration, and data directory.
| Parameter | Type | Level | Description |
|---|---|---|---|
infra_seq | int | I | Infrastructure node sequence, REQUIRED |
infra_portal | dict | G | Infrastructure services exposed via Nginx portal |
infra_data | path | G | Infrastructure data directory, default /data/infra |
infra_services | service[] | G | Built-in home navigation entries |
infra_extra_services | service[] | G | Additional home navigation entries, default [] |
REPO parameters configure the local software repository, including repository enable switch, directory paths, upstream source definitions, and packages to download.
| Parameter | Type | Level | Description |
|---|---|---|---|
repo_enabled | bool | G/I | Create local repo on this infra node? |
repo_home | path | G | Repo home directory, default /www |
repo_name | string | G | Repo name, default pigsty |
repo_endpoint | url | G | Repo access endpoint: domain or ip:port |
repo_remove | bool | G/A | Remove existing upstream repo definitions? |
repo_modules | string | G/A | Enabled upstream repo modules, comma separated |
repo_upstream | upstream[] | G | Upstream repo definitions |
repo_packages | string[] | G | Packages to download from upstream |
repo_extra_packages | string[] | G/C/I | Extra packages to download |
repo_url_packages | string[] | G | Extra packages downloaded via URL |
INFRA_PACKAGE parameters define RPM/DEB packages to install on infrastructure nodes.
| Parameter | Type | Level | Description |
|---|---|---|---|
infra_packages | string[] | G | Packages to install on infra nodes |
NGINX parameters configure Nginx web server and reverse proxy, including enable switch, ports, SSL mode, certificates, and basic authentication.
| Parameter | Type | Level | Description |
|---|---|---|---|
nginx_enabled | bool | G/I | Enable Nginx on this infra node? |
nginx_clean | bool | G/A | Clean existing Nginx config during init? |
nginx_exporter_enabled | bool | G/I | Enable nginx_exporter on this infra node? |
nginx_exporter_port | port | G | nginx_exporter listen port, default 9113 |
nginx_sslmode | enum | G | Nginx SSL mode: disable,enable,enforce |
nginx_cert_validity | duration | G | Nginx self-signed cert validity, default 397d |
nginx_home | path | G | Nginx content dir, default /www, symlink to nginx_data |
nginx_data | path | G | Nginx actual data dir, default /data/nginx |
nginx_users | dict | G | Nginx basic auth users: username-password dict |
nginx_port | port | G | Nginx listen port, default 80 |
nginx_ssl_port | port | G | Nginx SSL listen port, default 443 |
certbot_sign | bool | G/A | Sign cert with certbot? |
certbot_email | string | G/A | Certbot notification email address |
certbot_options | string | G/A | Certbot extra command line options |
DNS parameters configure DNSMasq DNS server, including enable switch, listen port, and dynamic DNS records.
| Parameter | Type | Level | Description |
|---|---|---|---|
dns_enabled | bool | G/I | Setup dnsmasq on this infra node? |
dns_port | port | G | DNS server listen port, default 53 |
dns_records | string[] | G | Dynamic DNS records resolved by dnsmasq |
VICTORIA parameters configure the VictoriaMetrics/Logs/Traces observability stack, including enable switches, ports, and data retention policies.
| Parameter | Type | Level | Description |
|---|---|---|---|
vmetrics_enabled | bool | G/I | Enable VictoriaMetrics on this infra node? |
vmetrics_clean | bool | G/A | Clean VictoriaMetrics data during init? |
vmetrics_port | port | G | VictoriaMetrics listen port, default 8428 |
vmetrics_scrape_interval | interval | G | Global scrape interval, default 10s |
vmetrics_scrape_timeout | interval | G | Global scrape timeout, default 8s |
vmetrics_options | arg | G | VictoriaMetrics extra CLI options |
vlogs_enabled | bool | G/I | Enable VictoriaLogs on this infra node? |
vlogs_clean | bool | G/A | Clean VictoriaLogs data during init? |
vlogs_port | port | G | VictoriaLogs listen port, default 9428 |
vlogs_options | arg | G | VictoriaLogs extra CLI options |
vtraces_enabled | bool | G/I | Enable VictoriaTraces on this infra node? |
vtraces_clean | bool | G/A | Clean VictoriaTraces data during init? |
vtraces_port | port | G | VictoriaTraces listen port, default 10428 |
vtraces_options | arg | G | VictoriaTraces extra CLI options |
vmalert_enabled | bool | G/I | Enable VMAlert on this infra node? |
vmalert_port | port | G | VMAlert listen port, default 8880 |
vmalert_options | arg | G | VMAlert extra CLI options |
PROMETHEUS parameters configure Alertmanager and Blackbox Exporter, providing alert management and network probing capabilities.
| Parameter | Type | Level | Description |
|---|---|---|---|
blackbox_enabled | bool | G/I | Setup blackbox_exporter on this infra node? |
blackbox_port | port | G | blackbox_exporter listen port, default 9115 |
blackbox_options | arg | G | blackbox_exporter extra CLI options |
alertmanager_enabled | bool | G/I | Setup alertmanager on this infra node? |
alertmanager_port | port | G | AlertManager listen port, default 9059 |
alertmanager_options | arg | G | alertmanager extra CLI options |
exporter_metrics_path | path | G | Exporter metrics path, default /metrics |
GRAFANA parameters configure the Grafana visualization platform, including enable switch, port, admin credentials, and data source configuration.
| Parameter | Type | Level | Description |
|---|---|---|---|
grafana_enabled | bool | G/I | Enable Grafana on this infra node? |
grafana_port | port | G | Grafana listen port, default 3000 |
grafana_clean | bool | G/A | Clean Grafana data during init? |
grafana_admin_username | username | G | Grafana admin username, default admin |
grafana_admin_password | password | G | Grafana admin password, default pigsty |
grafana_auth_proxy | bool | G | Enable Grafana auth proxy? |
grafana_pgurl | url | G | External PostgreSQL URL for Grafana persistence |
grafana_view_password | password | G | Grafana metadb PG datasource password |
META
This section defines Pigsty deployment metadata: version string, admin node IP address, repository mirror region, default language, and HTTP(S) proxy for downloading packages.
version
name: version, type: string, level: G
Pigsty version string. The current source default is v4.5.0.
Pigsty uses this version string internally for feature control and content rendering. Do not modify this parameter arbitrarily.
Pigsty uses semantic versioning, and the version string typically starts with the character v, e.g., v4.5.0.
admin_ip
name: admin_ip, type: ip, level: G
Admin node IP address, default is the placeholder IP address: 10.10.10.10
This parameter identifies the admin node. It usually points to the first Pigsty node, which is the control node.
The default value 10.10.10.10 is a placeholder that will be replaced with the actual admin node IP address during configure.
Many parameters reference this parameter, such as:
Pigsty replaces ${admin_ip} in these parameters with the actual admin_ip value. This lets you specify different admin nodes for different nodes.
region
name: region, type: enum, level: G
Upstream mirror region. The options are default, china, and europe. The default is default.
If you select another region, Pigsty looks for its matching baseurl in repo_upstream. If found, it uses that URL instead of the default baseurl.
If the region is china, Pigsty tries Chinese mirrors to accelerate downloads. If a repository has no China mirror, Pigsty uses its default upstream mirror.
For repo_url_packages, Pigsty also changes repo.pigsty.io to repo.pigsty.cc to use domestic mirrors.
language
name: language, type: enum, level: G
Default language. The options are en (English) and zh (Chinese). The default is en.
This parameter affects the language preference of some Pigsty-generated configurations and content, such as the initial language setting of Grafana dashboards.
For Chinese content, we recommend that you set this parameter to zh.
proxy_env
name: proxy_env, type: dict, level: G
Global proxy environment variables for package downloads. The default sets no_proxy, which lists addresses that should bypass the proxy:
When installing from the Internet in mainland China, certain packages may be blocked. You can use a proxy to solve this problem.
If you use the Docker module, Pigsty also writes these proxy settings to the Docker Daemon configuration file.
If you run ./configure with -x, Pigsty reads the proxy settings from the current environment. It writes them to the generated pigsty.yaml file.
CA
Pigsty uses self-signed CA certificates to support advanced security features such as HTTPS access, PostgreSQL SSL connections, etc.
ca_create
name: ca_create, type: bool, level: G
Specifies whether to create a CA private key if it is missing. The default is true.
When set to true, Pigsty creates a new CA private key if files/pki/ca/ca.key is absent. If ca.crt is absent, it uses the existing or newly created private key to issue the CA certificate.
If you already have a CA public-private key pair, you can copy them to the files/pki/ca directory:
files/pki/ca/ca.crt: CA public key certificatefiles/pki/ca/ca.key: CA private key file
Pigsty reuses an existing CA key pair. If the private key is absent and this parameter is false, deployment stops with an error. If only ca.crt is missing, Pigsty still reissues it with the existing private key. Always back up and restore the matching ca.key and ca.crt together to avoid a certificate/key mismatch.
Keep and back up the new CA private key during deployment. You need it to issue certificates later.
Note: Pigsty v3.x used
ca_methodwith valuescreate/recreate/copy. Version v4.x replaces it with the booleanca_create.
ca_cn
name: ca_cn, type: string, level: G
CA CN (Common Name). It is fixed at pigsty-ca. We do not recommend changes.
You can use the following command to view the Pigsty CA certificate details on a node:
cert_validity
name: cert_validity, type: interval, level: G
Validity period for issued certificates. The default is 7300d, or 20 years. This is sufficient for most scenarios.
This parameter affects the validity of all certificates issued by the Pigsty CA, including:
- PostgreSQL server certificates
- Patroni API certificates
- etcd server/client certificates
- Other internal service certificates
Note: nginx_cert_validity separately controls the validity of Nginx HTTPS certificates. Modern browsers impose stricter website certificate limits: a maximum of 397 days.
INFRA_ID
Infrastructure identity and portal definition.
infra_seq
name: infra_seq, type: int, level: I
Infrastructure node sequence number. This identity parameter is REQUIRED and has no default. Set it explicitly on each infrastructure node.
This parameter uniquely identifies each infrastructure node. Typically, use positive integers starting at 1.
Example configuration:
infra_portal
name: infra_portal, type: dict, level: G
Infrastructure services exposed via Nginx portal. The v4.x default value is very concise:
Pigsty configures reverse proxies for the enabled components automatically. Usually, you only need to define the home domain name.
Each record has a key and a value dictionary. The key, name, identifies the component. The value defines these parameters:
name: REQUIRED, specifies the name of the Nginx server- Default record:
homeis a fixed name, please do not modify it. - Used as part of the Nginx configuration file name, corresponding to:
/etc/nginx/conf.d/<name>.conf - Nginx servers without a
domainfield will not generate configuration files but will be used as references.
- Default record:
domain: OPTIONAL for a reference-only entry. It is REQUIRED to expose a service through Nginx and specifies its domain name.- In Pigsty self-signed Nginx HTTPS certificates, the domain will be added to the SAN field of the Nginx SSL certificate
- Pigsty web page cross-references will use the default domain name here
endpoint: Upstream server address for a reverse proxy. Usually, use it as an alternative topath.${admin_ip}can be used as a placeholder in the configuration and will be dynamically replaced withadmin_ipduring deployment- Default reverse proxy servers use endpoint.conf as the configuration template
- Reverse proxy servers can also configure
websocketandschemaparameters
path: Local directory for a file server. Usually, use it as an alternative toendpoint.- Local web servers use path.conf as the configuration template
- Local web servers can also configure the
indexparameter to enable file index pages
certbot: Certbot certificate name; if configured, Certbot will be used to apply for certificates- If servers share a certbot value, Pigsty combines their certificate requests. This value becomes the certificate name.
cert: Certificate file path; if configured, will override the default certificate pathkey: Certificate key file path; if configured, will override the default certificate key pathwebsocket: Whether to enable WebSocket support- Only reverse proxies can use this parameter. If enabled, it permits upstream WebSocket connections.
schema: Protocol used by the upstream server; if configured, will override the default protocol- Default is http; if configured as https, it will force HTTPS connections to the upstream server
index: Whether to enable file index pages- Only local file servers can use this parameter. If enabled, autoindex generates directory index pages.
log: Nginx log file path- If specified, Nginx writes access logs to this file. Otherwise, the server type determines the default log file.
- Reverse proxy servers use
/var/log/nginx/<name>.logas the default log file path - Local web servers use the default Access log
conf: Nginx template filename- Specifies a configuration template in roles/infra/templates/nginx or templates/nginx.
- Takes precedence over automatic selection by
home/path/endpoint. Development sources also have specialized site templates such asrepo.conf,beta.conf,demo.conf,pgext.conf, andpgweb.conf; see Development Maintenance Reference. - If this parameter is not specified, the default configuration template will be used
cache_dir: Portal cache directory. When nonempty, the role creates it with ownernginx:nginxand mode0750. Directory management was added to development sources on 2026-09-01 and is absent from thev4.5.0release.domains: Additional domain list included in Certbot’s domain set. Development sources since 2026-09-01 also include it in SANs when issuing new self-signed certificates. Whether the template listens for these aliases still depends on itsserver_name.config: Nginx configuration code block- Configuration text directly injected into the Nginx Server configuration block
enforce_https: Redirect HTTP to HTTPS- Global configuration can be specified via nginx_sslmode: enforce
- This setting does not affect the default home server. For compatibility, that server always listens on both ports 80 and 443.
infra_data
name: infra_data, type: path, level: G
Infrastructure data directory, default value is /data/infra.
This directory is used to store data files for infrastructure components, including:
- VictoriaMetrics time series database data
- VictoriaLogs log data
- VictoriaTraces trace data
- Other infrastructure component persistent data
We recommend a separate data disk for this directory. This simplifies management and expansion.
infra_services
name: infra_services, type: service[], level: G
Built-in navigation entries on the Pigsty home page. Current defaults include Metrics, Logs, Traces, Monitor Targets, Alert Rules, Alert Manager, CA Certificate, Software Repo, and Explain Visualizer.
Each item can use name, url, desc, and icon, plus the Chinese display fields name_cn and desc_cn. This parameter replaces the entire default list. To append entries, use infra_extra_services.
infra_extra_services
name: infra_extra_services, type: service[], level: G
Navigation entries appended to infra_services. The default is [], and each item uses the same structure as infra_services. For example:
REPO
This section is about local software repository configuration. Pigsty enables a local software repository (APT/YUM) on infrastructure nodes by default.
During initialization, Pigsty downloads packages and dependencies from the internet. repo_packages specifies the packages, and repo_upstream specifies the upstream repositories. The destination is {{ nginx_home }} / {{ repo_name }}, which defaults to /www/pigsty. The total software and dependency size is approximately 1GB.
The current package candidate is SOW 0.3.0. The source uses SOW to generate RPM/APT metadata. After a successful build, repo_complete is both a SHA-256 manifest and a completion marker. When it is present, Pigsty skips downloading and rebuilding by default and uses the existing repository. Force a rebuild with ./infra.yml -t repo_build -e repo_build=true.
Both repo_create and cache_create run sow create --pigsty directly. They do not fall back to createrepo_c or dpkg-scanpackages.
Older offline bundles or local repositories might lack SOW. First, refresh the media or install SOW from the Pigsty INFRA repository.
If package downloads are too slow, set a proxy with proxy_env for the initial download. You can also download a prebuilt offline package. This is a local repository built on the same operating system.
repo_enabled
name: repo_enabled, type: bool, level: G/I
Specifies whether to create a local repository on this infrastructure node. The default is true, which creates a repository on every Infra node.
With multiple infrastructure nodes, you can keep repositories on only 1-2 nodes. Set this parameter to false elsewhere to avoid duplicate downloads and builds.
repo_home
name: repo_home, type: path, level: G
Local software repository home directory, defaults to Nginx’s root directory: /www.
On a fresh installation, if this path does not exist, the role creates a symlink to nginx_data. Existing directories and symlinks are preserved unchanged. We generally recommend that you preserve this value. If you change it, keep it consistent with nginx_home.
repo_name
name: repo_name, type: string, level: G
Local repository name, default is pigsty. Changing this repository name is not recommended.
The final repository path is {{ repo_home }}/{{ repo_name }}, defaulting to /www/pigsty.
repo_endpoint
name: repo_endpoint, type: url, level: G
Endpoint used by other nodes to access this repository, default value: http://${admin_ip}:80.
Pigsty starts Nginx on infrastructure nodes at ports 80/443 by default, providing local software repository (static files) service.
Adjust this parameter after changes to nginx_port or nginx_ssl_port. Also adjust it if the infrastructure node differs from the control node.
If you use a domain name, you can add resolution in node_default_etc_hosts, node_etc_hosts, or dns_records.
repo_remove
name: repo_remove, type: bool, level: G/A
Specifies whether to remove existing upstream repository definitions during a local repository build. The default is true.
When this parameter is enabled, all existing repository files in /etc/yum.repos.d will be moved and backed up to /etc/yum.repos.d/backup. On Debian systems, /etc/apt/sources.list and /etc/apt/sources.list.d are removed and backed up to /etc/apt/backup.
Pigsty does not control the content of existing operating-system sources. Pigsty-validated upstream sources can improve package download speed and success rate.
Some EL/Deb-compatible variants use private sources for many packages. If you need to preserve existing upstream repository definitions, set this parameter to false.
repo_modules
name: repo_modules, type: string, level: G/A
Which upstream repository modules will be added to the local software source, default value: infra,node,pgsql
When Pigsty attempts to add upstream repositories, it filters entries in repo_upstream based on this parameter’s value. Only entries whose module field matches this parameter’s value will be added to the local software source.
During the build stage, infra is automatically added to the effective module list so SOW can be installed. This bootstrap dependency is restored even if a user overrides repo_modules without infra.
Modules are comma-separated. Available module lists can be found in the repo_upstream definitions; common modules include:
local: Local Pigsty repositoryinfra: Infrastructure packages (Nginx, Docker, etc.)node: OS base packagespgsql: PostgreSQL-related packagesextra: Extra PostgreSQL extensionsdocker: Docker-relatedredis: Redis-relatedmongo: MongoDB-relatedmysql: MySQL-related- etc…
repo_upstream
name: repo_upstream, type: upstream[], level: G
Upstream package sources for the local repository build. This parameter has no direct default. If unset, Pigsty loads repo_upstream_default from roles/node_id/vars. It selects the definition for the current node’s operating-system family.
Pigsty provides complete upstream repository definitions for currently supported OS versions (EL 8/9/10, Debian 12/13, Ubuntu 22/24/26), including:
- OS base repositories (BaseOS, AppStream, EPEL, etc.)
- PostgreSQL official PGDG repository
- Pigsty extension repository
- Various third-party software repositories (Docker, Nginx, Grafana, etc.)
Each upstream repository definition contains the following fields:
RPM upstream repositories retain native DNF module filtering by default. Set meta.module_hotfixes only on a repository that must actually replace an EL module stream. Clients use module_hotfixes=1 for Pigsty’s aggregated local repository. Pigsty no longer generates artificial modules.yaml / ModuleMD metadata.
Users typically don’t need to modify this parameter unless they have special repository requirements. For detailed repository definitions, refer to the configuration files for corresponding operating systems in the roles/node_id/vars/ directory.
repo_packages
name: repo_packages, type: string[], level: G
String array of packages to download with their dependencies. Each entry is a space-separated package list. Downloads use repotrack or apt download.
This parameter has no direct default. If unset, Pigsty loads repo_packages_default from roles/node_id/vars:
Each element in this parameter will be translated according to the package_map in the above files, based on the specific OS distro major version. For example, on EL systems it translates to:
By convention, repo_packages contains packages independent of the PostgreSQL major version, including Infra, Node, and PGDG Common packages. Put version-specific kernels and extensions in repo_extra_packages. This simplifies PostgreSQL major-version changes.
repo_extra_packages
name: repo_extra_packages, type: string[], level: G/C/I
Additional packages to download without changing repo_packages. These are typically specific to a PostgreSQL major version. The default is an empty list.
If not explicitly defined, Pigsty will load the default from the repo_extra_packages_default variable defined in roles/node_id/vars:
Pigsty translates these package names. It replaces $v with pg_version, the current PostgreSQL major version. The default version is 18.
The pgsql-main here translates on EL systems to:
Users can typically specify PostgreSQL major version-related packages here without affecting the other PG version-independent packages defined in repo_packages.
repo_url_packages
name: repo_url_packages, type: object[] | string[], level: G
Packages downloaded directly from the Internet using URLs, default is an empty array: []
You can use URL strings directly as array elements in this parameter, or use object structures to explicitly specify URLs and filenames.
The region variable affects this parameter. For mainland China, Pigsty automatically changes repo.pigsty.io URLs to repo.pigsty.cc.
INFRA_PACKAGE
These RPM/DEB packages are installed only on INFRA nodes.
infra_packages
name: infra_packages, type: string[], level: G
Packages to install on Infra nodes. Each array entry is a space-separated package list.
The default varies by platform. If unset, Pigsty loads infra_packages_default from the matching file under roles/node_id/vars. It selects the file by operating-system version and CPU architecture.
For example, the current mapping for EL 9 x86_64 is:
The current mapping for Debian 13 x86_64 is:
Note: v4.x uses the VictoriaMetrics suite to replace Prometheus and Loki, so the package list differs significantly from v3.x.
NGINX
Nginx proxies Pigsty web services, including the Home Page, Grafana, and VictoriaMetrics. It also proxies optional tools such as PGWeb, Jupyter Lab, Pgadmin, and Bytebase. It serves static resources and reports, including pev, schemaspy, and pgbadger.
Nginx also serves the local Yum/Apt repository, which stores and distributes Pigsty packages.
nginx_enabled
name: nginx_enabled, type: bool, level: G/I
Specifies whether to enable Nginx on this Infra node. The default is true.
Nginx is a core component of Pigsty infrastructure, responsible for:
- Providing local software repository service
- Reverse proxying Grafana, VictoriaMetrics, and other web services
- Hosting static files and reports
nginx_clean
name: nginx_clean, type: bool, level: G/A
Specifies whether to delete existing Nginx configuration during initialization. The default is false.
If set to true, Pigsty deletes all configuration files under /etc/nginx/conf.d/ during Nginx initialization. This starts with an empty configuration directory.
If you’re deploying for the first time or want to completely rebuild Nginx configuration, you can set this parameter to true.
nginx_exporter_enabled
name: nginx_exporter_enabled, type: bool, level: G/I
Specifies whether to enable nginx_exporter on this infrastructure node. The default is true.
If this option is disabled, the /nginx health check stub will also be disabled. Consider disabling this when your Nginx version doesn’t support this feature.
nginx_exporter_port
name: nginx_exporter_port, type: port, level: G
nginx_exporter listen port, default value is 9113.
nginx_exporter is used to collect Nginx operational metrics for VictoriaMetrics to scrape and monitor.
nginx_sslmode
name: nginx_sslmode, type: enum, level: G
Nginx SSL operating mode. The options are disable, enable, and enforce. The default, enable, enables SSL but does not require it.
disable: Only listen on the port specified bynginx_portto serve HTTP requests.enable: Also listen on the port specified bynginx_ssl_portto serve HTTPS requests.enforce: All links will be rendered to usehttps://by default- Also redirect port 80 to port 443 for non-default servers in
infra_portal
- Also redirect port 80 to port 443 for non-default servers in
nginx_cert_validity
name: nginx_cert_validity, type: duration, level: G
Nginx self-signed certificate validity, default value is 397d (approximately 13 months).
The default follows the modern browser limit of 397 days for website certificates. We do not recommend longer validity because browsers can reject these certificates.
nginx_home
name: nginx_home, type: path, level: G
Nginx server static content directory, default: /www
This is a symlink that actually points to the nginx_data directory. This directory contains static resources and software repository files.
Avoid unnecessary changes to this parameter. If changed, keep it consistent with repo_home.
nginx_data
name: nginx_data, type: path, level: G
Nginx actual data directory, default is /data/nginx.
This directory stores Nginx static files. The nginx_home symlink points to it.
We recommend a data disk for this directory to simplify management of large package files.
nginx_users
name: nginx_users, type: dict, level: G
Nginx Basic Authentication user dictionary, default is an empty dictionary {}.
Format is { username: password } key-value pairs, for example:
These users can be used to protect certain Nginx endpoints that require authentication.
nginx_port
name: nginx_port, type: port, level: G
Nginx HTTP listen port. The default is 80. We recommend that you keep the default.
If port 80 is occupied, you can use another port. Also update repo_endpoint to match the new port.
nginx_ssl_port
name: nginx_ssl_port, type: port, level: G
Nginx SSL listen port. The default is 443. We recommend that you keep the default.
certbot_sign
name: certbot_sign, type: bool, level: G/A
Specifies whether Certbot signs Nginx certificates during installation. The default is false.
If set to true, Pigsty uses Certbot to request free Let’s Encrypt SSL certificates automatically. The nginx role does this during infra.yml and deploy.yml.
For an infra_portal entry with certbot set, Pigsty requests a certificate for its domain. The certbot value becomes the certificate name.
If multiple servers or domains share the same certbot value, Pigsty combines them in one request. It uses that value as the certificate name.
Enabling this option requires:
- A public domain resolves to the current node’s public IP and provides access to the node.
- The current node can access the Let’s Encrypt API interface
This option is disabled by default. After installation, run make cert manually if needed. It calls the generated /etc/nginx/sign-cert script to request or update certificates with Certbot.
certbot_email
name: certbot_email, type: string, level: G/A
Email address for receiving certificate expiration reminder emails, default value is your@email.com.
When certbot_sign is set to true, it’s recommended to provide this parameter. Let’s Encrypt will send reminder emails to this address when certificates are about to expire.
certbot_options
name: certbot_options, type: string, level: G/A
Additional configuration parameters passed to certbot, default value is an empty string.
Use this parameter for extra Certbot command-line options. For example, --dry-run previews and tests the operation without requesting actual certificates.
DNS
Pigsty enables DNSMASQ on Infra nodes by default. It resolves auxiliary names such as i.pigsty, m.pigsty, and api.pigsty. The optional sss.pigsty name can provide the Silo endpoint.
Resolution records are stored in the /etc/dnsmasq.d/pigsty/default file on Infra nodes. To use this DNS server, you must add nameserver <ip> to /etc/resolv.conf. The node_dns_servers parameter handles this.
dns_enabled
name: dns_enabled, type: bool, level: G/I
Specifies whether to enable DNSMASQ on this Infra node. The default is true.
Set this value to false if you do not need the default DNS server. For example, you might have an external server or a provider that prohibits DNS servers. Use static records in node_default_etc_hosts and node_etc_hosts instead.
dns_port
name: dns_port, type: port, level: G
DNSMASQ default listening port, default is 53. It’s not recommended to modify the default DNS service port.
dns_records
name: dns_records, type: string[], level: G
Dynamic DNS records resolved by dnsmasq, generally used to resolve auxiliary domain names to the admin node. These records are written to the /etc/dnsmasq.d/pigsty/default file on infrastructure nodes.
v4.x default value:
The ${admin_ip} placeholder is used here and will be replaced with the actual admin_ip value during deployment.
Common domain name purposes:
i.pigsty: Pigsty home pagem.pigsty: Commonly used for the Silo console (optional)p.pigsty: Commonly used for the VictoriaMetrics Web UI when explicitly configured ininfra_portalapi.pigsty: API serviceadm.pigsty: Admin service- Others customized based on actual deployment needs
VICTORIA
Pigsty v4.x uses the VictoriaMetrics suite for observability in place of Prometheus and Loki:
- VictoriaMetrics: Replaces Prometheus as the time series database for storing monitoring metrics
- VictoriaLogs: Replaces Loki as the log aggregation storage
- VictoriaTraces: Distributed trace storage
- VMAlert: Replaces Prometheus Alerting for alert rule evaluation
vmetrics_enabled
name: vmetrics_enabled, type: bool, level: G/I
Specifies whether to enable VictoriaMetrics on this Infra node. The default is true.
VictoriaMetrics is the core monitoring component in Pigsty v4.x, replacing Prometheus as the time series database, responsible for:
- Scraping monitoring metrics from various exporters
- Storing time series data
- Providing PromQL-compatible query interface
- Supporting Grafana data sources
vmetrics_clean
name: vmetrics_clean, type: bool, level: G/A
Specifies whether to delete existing VictoriaMetrics data during initialization. The default is false.
When set to true, existing time series data will be deleted during initialization. Use this option carefully unless you’re sure you want to rebuild monitoring data.
vmetrics_port
name: vmetrics_port, type: port, level: G
VictoriaMetrics listen port, default value is 8428.
This port is used for:
- HTTP API access
- Web UI access
- Prometheus-compatible remote write/read
- Grafana data source connections
vmetrics_scrape_interval
name: vmetrics_scrape_interval, type: interval, level: G
VictoriaMetrics global metrics scrape interval, default value is 10s.
A 10-30 second scrape interval is suitable for production. A shorter interval gives more detailed monitoring data but increases storage and CPU overhead.
vmetrics_scrape_timeout
name: vmetrics_scrape_timeout, type: interval, level: G
VictoriaMetrics global scrape timeout, default is 8s.
A scrape timeout helps prevent monitoring queries from accumulating. Set it below and close to vmetrics_scrape_interval. This keeps each scrape shorter than the interval.
vmetrics_options
name: vmetrics_options, type: arg, level: G
VictoriaMetrics extra command line options, default value:
Common parameter descriptions:
-retentionPeriod=15d: Data retention period, default 15 days-promscrape.fileSDCheckInterval=5s: File service discovery refresh interval
You can add other VictoriaMetrics-supported parameters as needed.
vlogs_enabled
name: vlogs_enabled, type: bool, level: G/I
Specifies whether to enable VictoriaLogs on this Infra node. The default is true.
VictoriaLogs replaces Loki as the log aggregation storage, responsible for:
- Receiving log data from Vector
- Storing and indexing logs
- Providing log query interface
- Supporting Grafana VictoriaLogs data source
vlogs_clean
name: vlogs_clean, type: bool, level: G/A
Specifies whether to delete existing VictoriaLogs data during initialization. The default is false.
vlogs_port
name: vlogs_port, type: port, level: G
VictoriaLogs listen port, default value is 9428.
vlogs_options
name: vlogs_options, type: arg, level: G
VictoriaLogs extra command line options, default value:
Common parameter descriptions:
-retentionPeriod=15d: Log retention period, default 15 days-retention.maxDiskSpaceUsageBytes=50GiB: Maximum disk usage-insert.maxLineSizeBytes=1MB: Maximum single log line size-search.maxQueryDuration=120s: Maximum query execution time
vtraces_enabled
name: vtraces_enabled, type: bool, level: G/I
Specifies whether to enable VictoriaTraces on this Infra node. The default is true.
VictoriaTraces stores and queries distributed trace data. It supports Jaeger, Zipkin, and other trace protocols.
vtraces_clean
name: vtraces_clean, type: bool, level: G/A
Specifies whether to delete existing VictoriaTraces data during initialization. The default is false.
vtraces_port
name: vtraces_port, type: port, level: G
VictoriaTraces listen port, default value is 10428.
vtraces_options
name: vtraces_options, type: arg, level: G
VictoriaTraces extra command line options, default value:
vmalert_enabled
name: vmalert_enabled, type: bool, level: G/I
Specifies whether to enable VMAlert on this Infra node. The default is true.
VMAlert evaluates alert rules and works with Alertmanager. It replaces Prometheus Alerting.
vmalert_port
name: vmalert_port, type: port, level: G
VMAlert listen port, default value is 8880.
vmalert_options
name: vmalert_options, type: arg, level: G
VMAlert extra command line options, default value is an empty string.
PROMETHEUS
This section now primarily contains Blackbox Exporter and Alertmanager configuration.
Note: Pigsty v4.x uses VictoriaMetrics instead of Prometheus. The current interface no longer includes
prometheus_*andpushgateway_*. Usevmetrics_*andvmalert_*underVICTORIAfor metric storage and rule evaluation.
blackbox_enabled
name: blackbox_enabled, type: bool, level: G/I
Specifies whether to enable BlackboxExporter on this Infra node. The default is true.
BlackboxExporter sends ICMP packets to node IP addresses, VIP addresses, and PostgreSQL VIP addresses to test network connectivity. It can also perform HTTP, TCP, DNS, and other probes.
blackbox_port
name: blackbox_port, type: port, level: G
Blackbox Exporter listen port, default value is 9115.
blackbox_options
name: blackbox_options, type: arg, level: G
BlackboxExporter extra command line options, default value: empty string.
alertmanager_enabled
name: alertmanager_enabled, type: bool, level: G/I
Specifies whether to enable AlertManager on this Infra node. The default is true.
AlertManager receives alerts from VMAlert. It groups, inhibits, silences, routes, and otherwise processes these alerts.
alertmanager_port
name: alertmanager_port, type: port, level: G
AlertManager listen port, default value is 9059.
If you modify this port, ensure you update the alertmanager entry’s endpoint configuration in infra_portal accordingly (if defined).
alertmanager_options
name: alertmanager_options, type: arg, level: G
AlertManager extra command line options, default value: empty string.
exporter_metrics_path
name: exporter_metrics_path, type: path, level: G
HTTP endpoint path where monitoring exporters expose metrics, default: /metrics. Not recommended to modify this parameter.
This parameter defines the standard path for all exporters to expose monitoring metrics.
GRAFANA
Grafana provides the monitoring system frontend. It also supports data analysis, visualization, low-code data application development, and application prototyping.
grafana_enabled
name: grafana_enabled, type: bool, level: G/I
Specifies whether to enable Grafana on this Infra node. The default is true, which installs and enables Grafana on all infrastructure nodes.
grafana_port
name: grafana_port, type: port, level: G
Grafana listen port, default value is 3000.
If you need to access Grafana directly (not through Nginx reverse proxy), you can use this port.
grafana_clean
name: grafana_clean, type: bool, level: G/A
Specifies whether to delete Grafana data files during initialization. The default is false.
This operation removes /var/lib/grafana/grafana.db, ensuring a fresh Grafana installation.
If you want to preserve existing Grafana configuration (such as dashboards, users, data sources, etc.), set this parameter to false.
grafana_admin_username
name: grafana_admin_username, type: username, level: G
Grafana admin username, default is admin.
grafana_admin_password
name: grafana_admin_password, type: password, level: G
Grafana admin password, default is pigsty.
IMPORTANT: Change this password before production deployment.
grafana_auth_proxy
name: grafana_auth_proxy, type: bool, level: G
Specifies whether to enable the Grafana authentication proxy. The default is false.
If enabled, Grafana trusts user identity information from the Nginx reverse proxy. This supports single sign-on (SSO).
This is typically used for integration with external identity authentication systems.
grafana_pgurl
name: grafana_pgurl, type: url, level: G
External PostgreSQL database URL for Grafana persistence storage. Default is an empty string.
If specified, Grafana will use this PostgreSQL database instead of the default SQLite database to store its configuration data.
Format example: postgres://grafana:password@pg-meta:5432/grafana?sslmode=disable
This is useful for scenarios requiring Grafana high availability deployment or data persistence.
grafana_view_password
name: grafana_view_password, type: password, level: G
Read-only user password used by Grafana metadb PG data source, default is DBUser.Viewer.
This password is used for Grafana to connect to the PostgreSQL CMDB data source to query metadata in read-only mode.
3 - Playbook
Pigsty provides three playbooks related to the INFRA module:
deploy.yml: Deploy the NODE, INFRA, ETCD, MINIO, and PGSQL core modules on all nodes in one passinfra.yml: Initialize Pigsty infrastructure on infra nodesinfra-rm.yml: Remove infrastructure components from infra nodes
deploy.yml
Deploy NODE, INFRA, ETCD, MINIO, and PGSQL on all nodes in one pass. This resolves the circular dependency between INFRA and NODE.
The playbook interleaves subtasks from infra.yml and node.yml. It deploys core components in this order:
- id: Generate node and PostgreSQL identities
- ca: Create self-signed CA on localhost
- repo: Create local software repository on infra nodes
- node-init: Initialize nodes and HAProxy
- infra: Initialize Nginx, DNS, VictoriaMetrics, Grafana, etc.
- node-monitor: Initialize node-exporter, vector
- etcd: Initialize etcd (required for PostgreSQL HA)
- minio: Initialize Silo (optional)
- pgsql: Initialize PostgreSQL clusters and configure PostgreSQL monitoring
This playbook is equivalent to executing the following five playbooks sequentially:
deploy.yml does not currently deploy the Docker module. If Docker is required, set docker_enabled: true and run docker.yml separately.
infra.yml
Initialize the infrastructure module on Infra nodes defined in the infra group of your configuration file.
This playbook performs the following tasks:
- Configures directories and environment variables on Infra nodes
- Downloads and creates a local software repository to accelerate subsequent installations
- Incorporates the current Infra node as a common node managed by Pigsty
- Deploys infrastructure components (VictoriaMetrics/Logs/Traces, VMAlert, Grafana, Alertmanager, Blackbox Exporter, etc.)
Playbook notes:
- This is an idempotent playbook - repeated execution will overwrite infrastructure components on Infra nodes
- To preserve historical monitoring data, set
vmetrics_clean,vlogs_clean,vtraces_cleantofalsebeforehand - Unless
grafana_cleanis set tofalse, Grafana dashboards and configuration changes will be lost - If
/www/pigsty/repo_completeexists, the playbook skips internet downloads. SOW generates this SHA-256 manifest and completion marker. - Complete execution takes approximately 1-3 minutes, depending on machine configuration and network conditions
Available Tasks
infra-rm.yml
Remove Pigsty infrastructure from Infra nodes defined in the infra group of your configuration file.
Common subtasks include:
infra-rm.yml has no deletion safeguard. Without tags, it runs every phase above. The data phase recursively deletes infra_data (default: /data/infra), nginx_data (default: /data/nginx), nginx_home (default: /www), and /var/lib/grafana. This includes metrics, logs, traces, the software repository, and local Grafana data. Use the corresponding tag if you only want to stop services or deregister targets. Before a full run, back up everything that must survive and verify the exact infra target.
4 - Monitoring
This document describes monitoring dashboards and alert rules for the INFRA module in Pigsty.
Dashboards
The current files/grafana/infra directory contains 11 dashboards. The table also includes Pigsty Home from the root directory. See Monitoring System for overall dashboard and rule counts, and Metrics for endpoints and labels.
| Dashboard | Description |
|---|---|
| Pigsty Home | Pigsty monitoring system homepage |
| INFRA Overview | Pigsty infrastructure self-monitoring overview |
| Nginx Instance | Nginx metrics and logs |
| Grafana Instance | Grafana metrics and logs |
| VictoriaMetrics Instance | VictoriaMetrics scraping/query status |
| VMAlert Instance | Alert rule execution status |
| Alertmanager Instance | Alert aggregation and notifications |
| VictoriaLogs Instance | Log ingestion, querying, and indexing |
| Logs Instance | View log information on a single node |
| VictoriaTraces Instance | Trace storage and querying |
| Inventory CMDB | CMDB visualization |
| ETCD Overview | etcd cluster monitoring |
Alert Rules
Pigsty provides the following two alert rules for the INFRA module:
| Alert Rule | Description |
|---|---|
InfraDown | Infrastructure component is down |
AgentDown | Monitoring agent is down |
Both alerts fire when the corresponding recorded metric stays below 1 for one minute, with severity CRIT. AgentDown covers the actual exclusion list in agent_up, not every exporter; see Current Recording Rules. Source comments and alert summaries still contain older component names and the type label. Current registration uses cls / ins; troubleshoot using expressions and actual labels.
You can modify or add new infrastructure alert rules in files/victoria/rules/infra.yml.
Alert Rule Configuration
5 - Metrics
INFRA monitors VictoriaMetrics, VictoriaLogs, VictoriaTraces, VMAlert, Alertmanager, Grafana, Nginx Exporter, and Blackbox Exporter. Targets come from roles/infra/templates/prometheus/infra.yml.j2; scrape jobs are defined in roles/infra/templates/victoria/prometheus.yml.
Component versions and enabled services affect the raw metric set. This page lists scrape targets, rules, and common metrics for the Victoria stack. See Monitoring System for site-wide counts.
Metric Definitions and Counts
- Raw metrics: Produced by components or exporters. Read
TYPEandHELPat/metricsfor their types and meanings. - Recorded metrics: Computed from expressions by vmalert and queried in VictoriaMetrics. They have no independent
TYPEmetadata and cannot all be classified as Counter or Gauge. - Scrape status:
upandscrape_*are generated by the collection system.up=1indicates a successful scrape; database and application availability still require functional checks.
Histogram / Summary _bucket, _sum, and _count are different samples of the same metric family. Historical table rows, recording rules, and live time series count different objects and cannot be added together.
Scrape Endpoints and Labels
All targets below use job=infra and HTTP /metrics. The default target file is /infra/targets/infra/infra-<infra_seq>.yml.
| Component | Default Port | cls | Instance Label ins |
|---|---|---|---|
| Nginx Exporter | 9113 | nginx | nginx-<infra_seq> |
| VictoriaMetrics | 8428 | vmetrics | vmetrics-<infra_seq> |
| VictoriaLogs | 9428 | vlogs | vlogs-<infra_seq> |
| VictoriaTraces | 10428 | vtraces | vtraces-<infra_seq> |
| VMAlert | 8880 | vmalert | vmalert-<infra_seq> |
| Alertmanager | 9059 | alertmanager | alertmanager-<infra_seq> |
| Blackbox Exporter | 9115 | blackbox | blackbox-<infra_seq> |
| Grafana | 3000 | grafana | grafana-<infra_seq> |
Each target also carries ip and the scrape endpoint instance. The template does not inject the old type label; use cls to distinguish components. Targets are registered only for enabled components. VMAlert requires both vmalert_enabled and vmetrics_enabled; Nginx target registration depends on nginx_enabled.
Blackbox Exporter’s own metrics belong to job=infra. ICMP probe_* metrics produced through /probe belong to the separate job=ping. These are different target types.
Current Recording Rules
files/victoria/rules/infra.yml defines 2 recording rules, evaluated by vmalert and written back to VictoriaMetrics:
| Metric | Source Expression | Meaning |
|---|---|---|
infra_up | up{job="infra"} | Whether an infrastructure scrape endpoint is reachable |
agent_up | up{job!~"infra|node|etcd|minio|pgsql|redis|mysql"} | Reachability of targets outside the excluded jobs |
infra_up and agent_up are recording rules, absent from components’ raw /metrics output. The exclusion list above defines the scope of agent_up: it does not exclude jobs such as kafka, ping, or pgrds, and does not cover exporters already in node or pgsql. up=1 indicates only successful scraping. Assess functional service health with nginx_up, probe results, or component metrics.
The InfraDown and AgentDown alerts fire when their respective metrics stay below 1 for one minute. Both use severity CRIT. See Monitoring and Alerting for the rules.
Shared Liveness Recording Rules
In addition to module rules, roles/infra/templates/victoria/agent.yml generates 14 shared liveness rules, deployed to /infra/rules/agent.yml. The table retains template expressions; configuration variables render the ports. All derive from collector-generated up and indicate scrape success, not necessarily successful database queries, quorum, or application requests.
| Recorded Metric | Template Expression |
|---|---|
node_up | up{instance=~".*:{{ node_exporter_port|default('9100') }}"} |
haproxy_up | up{instance=~".*:{{ haproxy_exporter_port|default('9101') }}"} |
keepalived_exporter_up | up{instance=~".*:{{ vip_exporter_port|default('9650') }}"} |
docker_up | up{instance=~".*:{{ docker_exporter_port|default('9323') }}"} |
vector_up | up{instance=~".*:{{ vector_port|default('9598') }}"} |
etcd_up | up{job="etcd"} |
minio_up | up{job="minio"} |
pg_exporter_agent_up | up{instance=~".*:{{ pg_exporter_port|default('9630') }}"} |
pgbouncer_exporter_agent_up | up{instance=~".*:{{ pgbouncer_exporter_port|default('9631') }}"} |
pgbackrest_exporter_agent_up | up{instance=~".*:{{ pgbackrest_exporter_port|default('9854') }}"} |
patroni_up | up{instance=~".*:{{ patroni_port|default('8008') }}"} |
mysql_exporter_up | up{job="mysql"} |
kafka_up | up{job="kafka",role=~".+"} |
kafka_exporter_up | up{job="kafka",role=""} |
These recorded metrics are also absent from raw /metrics endpoints. Rules matching ports do not restrict job, so port overrides must remain consistent between the Infra rule template and service configuration.
Key Dashboard Metrics
The following names come from queries in the current files/grafana/infra dashboards and provide troubleshooting entry points. Availability depends on the installed version’s /metrics output.
| Component | Key Metrics | Purpose |
|---|---|---|
| Common process metrics | process_cpu_seconds_total, process_resident_memory_bytes, process_start_time_seconds | Process resources and start time |
| Victoria components | vm_app_version, vm_app_uptime_seconds | Version and uptime |
| VictoriaMetrics | vm_rows_inserted_total, vm_rows, vm_data_size_bytes, vm_new_timeseries_created_total | Ingestion, storage, and new series |
| VictoriaLogs | vl_rows_ingested_total, vl_bytes_ingested_total, vl_data_size_bytes, vl_http_requests_total | Log ingestion, capacity, and requests |
| VictoriaTraces | vt_rows_ingested_total, vt_bytes_ingested_total, vt_storage_rows, vt_data_size_bytes | Trace ingestion and storage |
| VMAlert | vmalert_alerts_firing, vmalert_alerts_pending, vmalert_recording_rules_last_evaluation_samples, vmalert_alerting_rules_errors_total | Alert state and rule evaluation |
| Alertmanager | alertmanager_alerts, alertmanager_silences, alertmanager_notifications_total, alertmanager_notifications_failed_total | Alert aggregation, silences, and notifications |
| Grafana | grafana_build_info, grafana_http_request_duration_seconds_count, grafana_stat_active_sessions | Version, HTTP requests, and sessions |
| Nginx | nginx_up, nginx_http_requests_total, nginx_connections_active, nginx_connections_waiting | Nginx status, traffic, and connections |
These are raw metric names. Counters usually require rate() / increase() before analysis. Histogram / Summary _bucket, _sum, and _count are samples of one metric family, not unrelated families counted by row.
Get the Actual Metric List
Run these queries in VictoriaMetrics VMUI (default http://<infra-ip>:8428/vmui) or Grafana Explore:
The first query checks each target’s scrape status, the second counts registered component endpoints, and the third lists visible series counts by metric name at the query time. To count distinct metric names, use count(count by (__name__) ({job="infra"})). This is still not an exporter metric-family count and cannot be added directly to other module counts.
Read raw types, HELP text, and labels from the target endpoint, for example:
6 - FAQ
What components are included in the INFRA module?
The current infra role directly manages these components:
- Nginx: Exposes Grafana, VictoriaMetrics (VMUI), Alertmanager, and other WebUIs, and hosts local YUM/APT repositories.
- DNSMasq: Provides DNS registration and resolution.
- VictoriaMetrics suite: VictoriaMetrics, VMAlert, VictoriaLogs, and VictoriaTraces.
- Alertmanager, Blackbox Exporter, and Grafana: Alert dispatch, blackbox probing, and visualization.
infra.yml also runs the CA, repository, NODE, HAProxy, and node-monitoring roles. These configure supporting services such as the self-signed CA, Chronyd, Node Exporter, and Vector on Infra nodes.
ETCD, PostgreSQL, and Docker are separate modules. The infra.yml playbook does not deploy them. Use etcd.yml, pgsql.yml, and docker.yml, respectively.
How to re-register monitoring targets to VictoriaMetrics?
VictoriaMetrics uses static service discovery through the /infra/targets/<job>/*.yml directory. If target files are accidentally deleted, use the following commands to re-register:
Other modules (such as pg_monitor.yml and mysql.yml) also provide corresponding *_register tags that can be executed as needed.
How to re-register PostgreSQL datasources to Grafana?
PGSQL databases defined in pg_databases are registered as Grafana datasources by default (for use by PGCAT applications).
If you accidentally delete postgres datasources registered in Grafana, you can register them again using the following command:
How to re-register node HAProxy admin pages to Nginx?
If you accidentally delete the registered haproxy proxy settings in /etc/nginx/conf.d/haproxy, you can restore them using the following command:
How to restore DNS registration records in DNSMASQ?
PGSQL cluster/instance domains are registered by default to /etc/dnsmasq.d/pigsty/<name> on infra nodes. You can restore them using the following command:
How to expose new upstream services via Nginx?
You can access services directly through IP:Port. However, we recommend domain names and the Nginx proxy for WebUI access. This centralizes access, reduces exposed ports, and simplifies access control and auditing.
If you want to expose new WebUI services through the Nginx portal, you can add service definitions to the infra_portal parameter.
For example, here’s the Infra portal configuration used by Pigsty’s official demo, exposing several additional services:
After completing the Nginx upstream service definition, use the following configuration and commands to register new services to Nginx.
For HTTPS, delete files/pki/csr/pigsty.csr and files/pki/nginx/pigsty.{key,crt} to force Nginx SSL/TLS certificate regeneration. The new certificates include the new upstream domains.
To use certificates from an authoritative CA instead of the Pigsty self-signed CA, put them in /etc/nginx/conf.d/cert/. Update the corresponding /etc/nginx/conf.d/<name>.conf configuration.
How to manually add upstream repo files to nodes?
Pigsty has a built-in wrapper script bin/repo-add that calls the ansible playbook node.yml to add repo files to corresponding nodes.
7 - Administration
This section covers daily administration and operations for Pigsty deployments.
7.1 - Nginx Management
Pigsty installs Nginx on INFRA nodes as the entry point for all web services. It listens on standard ports 80/443.
In Pigsty, you can configure Nginx to provide various services through inventory:
- Expose web interfaces for monitoring components like Grafana, VictoriaMetrics (VMUI), Alertmanager, and VictoriaLogs
- Serve static files (software repos, documentation sites, websites, etc.)
- Proxy custom application services (internal apps, database management UIs, Docker application interfaces, etc.)
- Automatically issue self-signed HTTPS certificates, or use Certbot to obtain free Let’s Encrypt certificates
- Expose services through a single port using different subdomains for unified access
Basic Configuration
Customize Nginx behavior via infra_portal parameter:
infra_portal is a dictionary where each key defines a service and the value is the service configuration.
Pigsty generates Nginx configuration files only for services with a defined domain.
home: Special default server for homepage and built-in monitoring component reverse proxies- Proxy services: Specify upstream service address via
endpointfor reverse proxy - Static services: Specify local directory via
pathfor static file serving
Server Parameters
Basic Parameters
| Parameter | Description |
|---|---|
domain | Optional proxy domain |
endpoint | Upstream service address (IP:PORT or socket) |
path | Local directory for static content |
scheme | Protocol type (http/https), default http |
domains | Additional domain list (aliases) |
SSL/TLS Options
| Parameter | Description |
|---|---|
certbot | Enable Let’s Encrypt cert management, value is cert name |
cert | Custom certificate file path |
key | Custom private key file path |
enforce_https | Force HTTPS redirect (301) |
Advanced Settings
| Parameter | Description |
|---|---|
conf | Select a template in roles/infra/templates/nginx |
cache_dir | Development sources can create the cache directory; other deployments must prepare it and its permissions manually |
config | Custom Nginx snippet in a generic template |
index | Enable directory listing (for static) |
log | Custom log file name |
websocket | Enable WebSocket support |
auth | Enable Basic Auth |
realm | Basic Auth prompt message |
When conf is set, that template takes precedence. Otherwise, the role selects a generic template based on home, path, and endpoint.
Configuration Examples
Reverse Proxy Services
Static Files and Directory Listing
Custom SSL Certificate
Using Let’s Encrypt Certificates
Force HTTPS Redirect
Custom Config Snippet
Management Commands
Domain Resolution
Three ways to resolve domains to Pigsty servers:
- Public domains: Configure via DNS provider
- Internal DNS server: Configure internal DNS resolution
- Local hosts file: Modify
/etc/hosts
For local development, add to /etc/hosts:
Pigsty includes dnsmasq service, configurable via dns_records parameter for internal DNS resolution.
HTTPS Configuration
Configure HTTPS via nginx_sslmode parameter:
| Mode | Description |
|---|---|
disable | Listen HTTP only (nginx_port) |
enable | Also listen HTTPS (nginx_ssl_port), default self-signed cert |
enforce | Force redirect to HTTPS, all port 80 requests get 301 redirect |
For self-signed certificates, several access options:
- Trust the self-signed CA in browser (download at
http://<ip>/ca.crt) - Use browser security bypass (type “thisisunsafe” in Chrome)
- Configure proper CA-signed certs or Let’s Encrypt for production
Certbot Certificates
Pigsty supports using Certbot to request free Let’s Encrypt certificates.
Enable Certbot
- Add
certbotparameter to services ininfra_portal, specifying cert name - Configure
certbot_emailwith a valid email - Set
certbot_signtotruefor auto-signing during deployment
Manual Certificate Signing
Or run the scripts directly on the server:
For more info, see Certbot: Request and Renew HTTPS Certificates
Default Homepage
Pigsty’s default home server provides these built-in routes:
| Path | Description |
|---|---|
/ | Homepage navigation |
/ui/ | Grafana monitoring dashboards |
/vmetrics/ | VictoriaMetrics VMUI |
/vlogs/ | VictoriaLogs log query |
/vtraces/ | VictoriaTraces tracing |
/vmalert/ | VMAlert alerting rules |
/alertmgr/ | AlertManager alert management |
/blackbox/ | Blackbox Exporter |
/pev | PostgreSQL Explain visualization |
/haproxy/<cluster>/ | HAProxy admin interface (if any) |
These routes provide one entry point for all monitoring components. You do not need to configure multiple domains.
Best Practices
- Use domain names instead of IP:PORT for service access
- Properly configure DNS resolution or hosts file
- Enable WebSocket for real-time apps (e.g., Grafana, Jupyter)
- Enable HTTPS for production
- Use meaningful subdomains to organize services
- Monitor Let’s Encrypt certificate expiration
- Use
configparameter for custom Nginx configurations
Full Example
Here’s the Nginx configuration used by Pigsty’s public demo site demo.pigsty.io:
Development Maintenance Reference
The specialized development templates below maintain Pigsty’s public sites and are not yet included in public sources. Ordinary portals can use the generic configuration above.
Specialized site templates and migration notes
conf | Purpose and Configuration |
|---|---|
repo.conf | Public package repository; path selects the publication directory. Exposes only listed directories/files, disables directory listings, and rejects unknown Host / SNI |
beta.conf | Proxy cache for Pigsty, PGDG, distribution, and Docker repositories; cache_dir selects the cache directory, with an 80 GiB cache limit and at least 100 GiB free space |
demo.conf | Demo reverse proxy using endpoint, WebSocket support, one-hour read/write timeouts, and disabled response buffering |
pgext.conf | Extension catalog reverse proxy using endpoint, connection reuse, and response buffering |
pgweb.conf | Chinese PostgreSQL community website using endpoint; optional static directories admin_static, media_root, and files_root |
Development files reside in roles/infra/templates/nginx/. All redirect HTTP to HTTPS while retaining the ACME challenge path. Upstream domains, cache limits, and the CA path in beta.conf are template settings. Its default CA path is EL’s /etc/pki/tls/certs/ca-bundle.crt; adapt the template before moving to Debian / Ubuntu. pgweb.conf serves the community website, not the PostgreSQL browser application of the same name.
repo.conf includes a default server and the 127.0.0.1:9180/nginx status endpoint. Do not also generate a home.conf default server on the same listening address. Set nginx_exporter_scrape_uri: http://127.0.0.1:9180/nginx for this template. If overriding nginx_status_port, update the scrape URL too.
The role creates the cache directory only when configuration explicitly provides a nonempty cache_dir. Set it explicitly for beta.conf, for example /data/beta, and verify sufficient data-disk space first.
7.2 - Software Repository
Pigsty’s REPO role downloads required packages and creates a local YUM/APT repository under /www/pigsty. Nginx can serve this repository.
The current package candidate is SOW 0.3.0. SOW generates metadata for both repository types. The source no longer calls createrepo_c, modifyrepo_c, or dpkg-scanpackages separately.
Quick Start
Add packages to repo_packages or repo_extra_packages, then run:
If /www/pigsty/repo_complete already exists, the default repo_build skips the build. To force a rebuild, override it explicitly:
To rebuild metadata for packages already present without downloading new ones:
SOW Prerequisites
Both repo_create and cache_create require sow on the target node. A fresh online build automatically adds infra to the effective repo_modules list. It installs SOW from the Pigsty INFRA upstream repository.
Offline bundles and local repositories created before this change may not contain SOW. Before you rebuild from old media, refresh the bundle or local repository. Alternatively, install the current SOW 0.3.0 candidate from Pigsty INFRA. Do not assume that older environments can still fall back to createrepo_c.
On a fresh installation, the role checks whether /www exists. If absent, it creates /data/nginx and points /www to it. It preserves existing directories and symlinks.
Build Flow
| Task | Purpose |
|---|---|
repo_check | Check repo_complete to determine whether the local repository is complete |
repo_prepare | Configure and use an existing repository |
repo_dir | Create /www/pigsty and ACME directories |
repo_upstream | Back up and add upstream YUM or APT definitions |
repo_url_pkg | Download packages from direct URLs |
repo_cache | Run yum makecache or apt update |
repo_boot_pkg | Install sow and the RPM platform’s dnf-utils / yum-utils |
repo_pkg | Download packages and dependencies |
repo_create | Run SOW to clean and atomically publish repository metadata |
repo_use | Write the local Pigsty repository definition on the current host |
repo_nginx | Start a temporary Nginx when no service is already running |
The command executed by repo_create is:
--pigsty removes unneeded packages and packages likely to cause conflicts. It atomically publishes the result only after all metadata is complete. A typical layout is:
repo_complete contains SHA-256 checksums. Do not treat it as an empty marker. Its presence means SOW completed publication of local repository metadata. It does not prove that remote mirrors, signed repositories, or offline bundles have been synchronized.
DNF Module Streams
Pigsty no longer fabricates modules.yaml / ModuleMD metadata for the aggregated local repository. System upstream repositories retain native DNF module filtering. Only an upstream repository that truly needs to replace an EL module stream should set meta explicitly:
The aggregated local repository uses module_hotfixes=1. This prevents system module streams from hiding local PostgreSQL packages. It does not generate artificial ModuleMD metadata.
Package Aliases
The default repo_packages uses these alias groups:
node-bootstrap includes Ansible, Python dependencies, SOW, and SSH tools. infra-package includes Nginx, etcd, HAProxy, Victoria exporters, Redis/Valkey, Silo, mcli, SOW, and Pig. Exact names vary by operating-system mapping. Use roles/node_id/vars/<os>.<arch>.yml as the authoritative source.
Common Commands
7.3 - Domain Management
Use domain names instead of IP addresses to access Pigsty’s various web services.
Quick Start
Add the following static resolution records to /etc/hosts:
Replace IP address with your actual Pigsty node’s IP.
Why Use Domain Names
- Easier to remember than IP addresses
- Flexible pointing to different IPs
- Unified service management through Nginx
- Support for HTTPS encryption
- Prevent ISP hijacking in some regions
- Allow access to internally bound services via proxy
DNS Mechanism
DNS Protocol: Resolves domain names to IP addresses. Multiple domains can point to same IP.
HTTP Protocol: The Host header routes requests to different sites on the same port (80/443).
Default Domains
Pigsty predefines the following default domains:
| Domain | Service | Port | Purpose |
|---|---|---|---|
i.pigsty | Nginx | 80/443 | Default homepage, local repo, unified entry |
m.pigsty | Silo | 9001 | Object storage console |
By default, access Grafana, VictoriaMetrics, and Alertmanager under i.pigsty. Their paths are /ui/, /vmetrics/, and /alertmgr/, respectively. To use dedicated domains such as g.pigsty, p.pigsty, and a.pigsty, configure them explicitly in infra_portal and dns_records.
Resolution Methods
Local Static Resolution
Add entries to /etc/hosts on the client machine:
Add content:
Internal Dynamic Resolution
Pigsty includes dnsmasq as an internal DNS server. Configure managed nodes to use INFRA node as DNS server:
Configure domain records resolved by dnsmasq via dns_records:
Public Domain Names
Purchase a domain and add DNS A record pointing to public IP:
- Purchase domain from registrar (e.g.,
example.com) - Configure A record pointing to server public IP
- Use real domain in
infra_portal
Built-in DNS Service
Pigsty runs dnsmasq on INFRA nodes as a DNS server.
Related Parameters
| Parameter | Default | Description |
|---|---|---|
dns_enabled | true | Enable DNS service |
dns_port | 53 | DNS listen port |
dns_records | See below | Default DNS records |
Default DNS records:
Dynamic DNS Registration
Pigsty automatically registers DNS records for PostgreSQL clusters and instances:
- Instance-level DNS:
<pg_instance>points to instance IP (e.g.,pg-meta-1) - Cluster-level DNS:
<pg_cluster>points to primary IP or VIP (e.g.,pg-meta)
Cluster-level DNS target controlled by pg_dns_target:
| Value | Description |
|---|---|
auto | Auto-select: use VIP if available, else primary IP |
primary | Always point to primary IP |
vip | Always point to VIP (requires VIP enabled) |
none | Don’t register cluster DNS |
<ip> | Specify fixed IP address |
Add suffix to cluster DNS via pg_dns_suffix.
Node DNS Configuration
Pigsty manages DNS configuration on managed nodes.
Static hosts Records
Configure static /etc/hosts records via node_etc_hosts:
DNS Server Configuration
| Parameter | Default | Description |
|---|---|---|
node_dns_method | add | DNS config method |
node_dns_servers | ['${admin_ip}'] | DNS server list |
node_dns_options | See below | resolv.conf options |
node_dns_method options:
| Value | Description |
|---|---|
add | Prepend to existing DNS server list |
overwrite | Completely overwrite DNS config |
none | Don’t modify DNS config |
Default DNS options:
HTTPS Certificates
Pigsty uses self-signed certificates by default. Options include:
- Ignore warnings, use HTTP
- Trust self-signed CA certificate (download at
http://<ip>/ca.crt) - Use real CA or get free public domain certs via Certbot
See CA and Certificates documentation for details.
Extended Domains
Pigsty reserves the following domains for various application services:
| Domain | Purpose |
|---|---|
adm.pigsty | PgAdmin interface |
ddl.pigsty | Bytebase DDL management |
cli.pigsty | PgWeb CLI interface |
api.pigsty | PostgREST API service |
lab.pigsty | Jupyter environment |
git.pigsty | Gitea Git service |
wiki.pigsty | Wiki.js docs |
noco.pigsty | NocoDB |
supa.pigsty | Supabase |
dify.pigsty | Dify AI |
odoo.pigsty | Odoo ERP |
mm.pigsty | Mattermost |
Using these domains requires configuring corresponding services in infra_portal.
Management Commands
7.4 - Module Management
Use this guide for daily INFRA administration. It covers installation, removal, scaling, and component maintenance.
Install INFRA Module
Use the infra.yml playbook to install the INFRA module on the infra group:
Uninstall INFRA Module
Use the infra-rm.yml playbook to uninstall the INFRA module from the infra group:
This playbook has no deletion safeguard. Full execution removes infra_data, nginx_data, nginx_home (default: /www), and /var/lib/grafana.
If you only need to stop services or deregister targets, use -t service or -t deregister. Read the complete removal scope and back up required data before running it.
Scale Out INFRA Module
Assign infra_seq to new nodes and add them to the infra group in the inventory:
Use the -l limit option to execute the playbook on the new node only:
Manage Local Repository
Local repository management tasks:
Complete subtask list:
Manage Nginx
Nginx management tasks:
Request HTTPS certificate:
Manage Infrastructure Components
Management commands for various infrastructure components:
Common maintenance commands:
Manage Grafana Passwords
Grafana uses two password parameters. grafana_admin_password defaults to the public value pigsty. grafana_view_password defaults to DBUser.Viewer.
| Parameter | Rendered configuration |
|---|---|
grafana_admin_password | /etc/grafana/grafana.ini and /infra/env/pigsty |
grafana_view_password | /etc/grafana/provisioning/datasources/pigsty.yml |
Change the public defaults before production. After initialization, a change to grafana_admin_password in the inventory does not reset the live Grafana account password. Change it through Grafana or a supported administration interface. Keep the inventory consistent and regenerate the environment when needed:
grafana_view_password is the password used by the default PostgreSQL metadb data source as dbuser_view. If the database role password changes, update both the declared value and the Grafana data source. A change on only one side breaks the dashboard connection.
7.5 - CA and Certificates
Pigsty maintains a self-signed Certificate Authority (CA) on the admin node by default. It signs certificates for PostgreSQL, Patroni, etcd, Silo, Nginx, and other internal services. Public Nginx entries can use Certbot/Let’s Encrypt certificates configured through infra_portal.
files/pki/ca/ca.key is the trust-root private key for the entire deployment. Never print, commit, upload, or transmit it over an unprotected channel. Back it up with ca.crt. Encrypt the backup and tightly restrict read access.
Self-Signed CA
The ca stage of infra.yml creates or reuses the CA locally on the admin node running Ansible. It does not create the CA on a remote Infra node. The default layout is:
The core defaults match the v4.5.0 roles:
| Parameter | Default | Meaning |
|---|---|---|
ca_create | true | Allow creation when ca.key is missing |
ca_cn | pigsty-ca | Common Name of the CA certificate |
cert_validity | 7300d | Default internal service/client validity (20 years) |
nginx_cert_validity | 397d | Nginx self-signed HTTPS certificate validity |
The role hard-codes the CA certificate lifetime to 36500d (about 100 years). These long-lived certificates serve a controlled internal trust domain. Public browsers do not trust them by default. Clients must explicitly trust ca.crt. Public endpoints should use a publicly trusted CA.
Initialize the local CA stage:
Running ./infra.yml -t ca may create a missing key or certificate and therefore changes PKI state. Confirm the admin node, configuration, and existing CA backup first.
Use an External CA
To reuse an enterprise CA:
- Set
ca_create: falseinpigsty.yml. - Place a matching
files/pki/ca/ca.keyandfiles/pki/ca/ca.crtpair on the admin node. - Set permissions and verify that the public-key digests match.
ca_create: false prevents generation of a new private key only when ca.key is missing. If the key exists and ca.crt is missing, the role still creates a new self-signed CA certificate from the key. Always restore the pair together instead of relying on certificate regeneration.
Before running the CA stage, verify the files that will be used, the existing CA backup, and the admin node.
Back Up and Restore the CA
Retain at least:
files/pki/ca/ca.keyandca.crt- CA state such as
ca.srl,index.txt, and CRL files if issuance/revocation management uses them - backup time, the CA certificate SHA-256 fingerprint, and restoration instructions
Encrypt the backup and store it on controlled offline media or in a secrets-management system. Do not keep an unencrypted tar archive.
First, restore it to an isolated temporary directory. Before replacement, verify the file count, types, permissions, public-key match, and certificate fingerprint.
Loss of ca.key does not immediately prevent verification of existing certificates. Verification still works if clients trust ca.crt and the certificates remain valid and unrevoked.
You can no longer issue, renew, or revoke certificates with the original CA. Recovery usually requires a new CA, reissuance of every certificate, and deployment of a new trust chain.
Issue Certificates with cert.yml
cert.yml runs locally on the admin node and issues generic certificates with the Pigsty CA. Pass cn explicitly instead of relying on the generic script default:
Default outputs:
| Parameter | Default | Meaning |
|---|---|---|
cn | pigsty | Common Name; set explicitly in real use |
san | [DNS:localhost, IP:127.0.0.1] | Subject Alternative Names |
org | pigsty | Organization |
unit | pigsty | Organizational Unit |
expire | 7300d | Validity |
key | files/pki/misc/<cn>.key | Private-key output path |
crt | files/pki/misc/<cn>.crt | Certificate output path |
Advanced examples:
Verify the certificate without displaying or copying private-key content:
For PostgreSQL client certificates, cn must match the database role expected by HBA/cert authentication. Install the certificate, key, and root certificate on the client. Set the private key permissions to 0600. With sslmode=verify-full, the connection hostname must appear in the server certificate SAN.
Trust the CA Certificate
Distribute only the public ca.crt. Never distribute ca.key. Verify its SHA-256 fingerprint through a separate trusted channel before installation.
Debian / Ubuntu
RHEL / Rocky / AlmaLinux
macOS
Windows (Administrator PowerShell)
Infra Nginx normally exposes the public CA certificate at http://<infra_ip>/ca.crt. Verify the fingerprint after download. HTTP transport alone does not prove certificate authenticity.
Nginx and Let’s Encrypt
Each infra_portal entry can name a certbot certificate. Pigsty’s /etc/nginx/sign-cert uses Certbot webroot mode. It groups domain and domains entries that share a certificate name. Then /etc/nginx/link-cert links the resulting certificate into Nginx.
sign-cert uses --expand for existing certificates. Check the certificate domain set separately when removing aliases. link-cert selects a Certbot certificate based only on whether its private-key file exists; it does not validate expiration or hostnames. Check the actual certificate SANs and validity after deployment.
Prerequisites:
- Public DNS A/AAAA records resolve to the intended Infra node.
- Port 80 is publicly reachable for HTTP-01, and Nginx serves the ACME webroot.
certbot_emailis valid and the Certbot package is installed.- Portal domains, additional domains, and certificate names are exact.
Update the Nginx configuration and issue certificates:
In v4.5.0, the nginx_certbot task has ignore_errors: true. A playbook that continues or reports overall success does not prove certificate issuance. Inspect Certbot state, certificate files, Nginx configuration, and a real TLS handshake.
Renewal scheduling depends on the Certbot package for the operating system. Do not add a duplicate cron job before checking existing timers and cron configuration:
Replacing certificate files does not make Nginx load them automatically. Check that the renewal hook runs nginx -t && systemctl reload nginx.service after successful issuance. If missing, add this step to the existing Certbot renewal task.
Troubleshooting and Acceptance
| Symptom | Check |
|---|---|
| Browser rejects an internal cert | Correct ca.crt, SAN hostname, and system time |
verify-full fails | Connection hostname, SAN, chain, and root certificate |
| Certbot HTTP-01 fails | DNS, port 80, ACME webroot, proxy/CDN, and rate limits |
| Playbook succeeds but old cert remains | Ignored nginx_certbot errors, link-cert, and Nginx reload |
| Permission denied | Private key 0600 (deployed Nginx key is 0640 root:nginx) |
| Trust breaks after CA rotation | Roll out client trust, then service certs, then reload services |
For final acceptance, verify each result separately:
- The certificate content and SANs are correct.
- Chain validation succeeds.
- The service has loaded the new certificate.
- Target clients trust the certificate.
- Renewal is configured and passes a dry run.
A generated file or successful playbook alone does not prove these results.
7.6 - Grafana High Availability: Using PostgreSQL Backend
You can use PostgreSQL as Grafana’s backend database.
This tutorial explains the Pigsty deployment system through these tasks:
- How to create a new database cluster
- How to create new business users in an existing cluster
- How to create new business databases in an existing cluster
- How to access databases created by Pigsty
- How to manage Grafana dashboards
- How to manage PostgreSQL datasources in Grafana
- How to upgrade Grafana database in one step
TL;DR
Create Database Cluster
You can define a grafana database on pg-meta. You can also create a dedicated pg-grafana cluster on new nodes.
Define Cluster
To create a new dedicated cluster pg-grafana on machines 10.10.10.11 and 10.10.10.12, use this config:
Create Cluster
Use this command to create the pg-grafana cluster: pgsql.yml.
This command is the Ansible Playbook pgsql.yml for creating database clusters.
Cluster initialization automatically creates the users and databases in pg_users and pg_databases. After cluster creation, any of these connection strings provides database access without DNS:
Pigsty defaults to a single meta node. The following steps use its existing pg-meta cluster for the Grafana user and database. They do not use the pg-grafana cluster created above.
Create Grafana Business User
Create the user before the database. A database with an owner depends on that user.
Define User
To create user dbuser_grafana on the pg-meta cluster, first add this user definition to pg-meta’s cluster definition:
Location: all.children.pg-meta.vars.pg_users
If you define a different password here, replace the corresponding parameter in subsequent steps
Create User
Use this command to create the dbuser_grafana user (either works):
This actually calls the Ansible Playbook pgsql-user.yml to create the user:
The dbrole_admin role has permission to execute DDL changes in the database, which is exactly what Grafana needs.
Create Grafana Business Database
Define Database
Creating a business database follows the same pattern as users. First add the new database grafana definition to pg-meta’s cluster definition.
Location: all.children.pg-meta.vars.pg_databases
Create Database
Use this command to create the grafana database (either works):
This actually calls the Ansible Playbook pgsql-db.yml to create the database:
Use Grafana Business Database
Verify Connection String Reachability
You can access the database using different services or access methods, for example:
Here, we’ll use the Default service that directly accesses the primary through load balancer.
First verify the connection string is reachable and has DDL execution permissions:
Directly Modify Grafana Config
To make Grafana use a Postgres datasource, edit /etc/grafana/grafana.ini and modify the config:
Change the default config to:
Then restart Grafana:
Activity in the new grafana database indicates that Grafana now uses PostgreSQL as its main backend.
The original Grafana dashboards and datasources are absent from this new backend. Import the dashboards and Postgres datasources again.
Manage Grafana Dashboards
As admin user, navigate to the files/grafana directory under the Pigsty directory and run grafana.py init to reload Pigsty dashboards.
Execution result:
The script detects the environment defined in ~/pigsty during installation. It gets Grafana access information and replaces dashboard URL placeholders (*.pigsty) with actual domains.
Use grafana.py clean to delete target dashboards. Use grafana.py load to load all dashboards from the current directory. When Pigsty dashboards change, use these two commands to upgrade all dashboards.
Manage Postgres Datasources
Pigsty registers PostgreSQL datasources in Grafana when pgsql.yml creates a cluster or pgsql-db.yml creates a business database. You can directly access target database instances through Grafana using the default monitoring user. Most pgcat application features depend on this.
To register Postgres databases, use the register_grafana task in pgsql.yml:
One-Step Grafana Upgrade
Change the Pigsty configuration to switch the Grafana backend database in one step. Edit the grafana_pgurl parameter in pigsty.yml:
Then re-run the grafana task from infra.yml to complete the Grafana upgrade:






