@@ -1658,3 +1658,189 @@ __NODE_EXPORTER_:
16581658
16591659install_node_exporter :
16601660 @./scripts/install_node_exporter.sh
1661+
1662+ # ==============================================================================
1663+ # Aggregation Mode Ansible Deployment
1664+ # ==============================================================================
1665+
1666+ AGG_MODE_ANSIBLE_DIR = infra/aggregation_mode/ansible
1667+ AGG_MODE_PLAYBOOKS_DIR = $(AGG_MODE_ANSIBLE_DIR ) /playbooks
1668+ AGG_MODE_INI_DIR = $(AGG_MODE_PLAYBOOKS_DIR ) /ini
1669+
1670+ # ------------------------------------------------------------------------------
1671+ # Setup: Create INI configuration files
1672+ # ------------------------------------------------------------------------------
1673+
1674+ # ------------------------------------------------------------------------------
1675+ # PostgreSQL Cluster Deployment
1676+ # ------------------------------------------------------------------------------
1677+
1678+ .PHONY : postgres_deploy
1679+ postgres_deploy : # # Deploy PostgreSQL Auto-Failover Cluster. Usage: make postgres_deploy ENV=hoodi
1680+ @if [ -z " $( ENV) " ]; then \
1681+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1682+ exit 1; \
1683+ fi
1684+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /postgres_cluster.yaml \
1685+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1686+ -e " env=$( ENV) "
1687+
1688+ .PHONY : postgres_monitor_deploy
1689+ postgres_monitor_deploy : # # Deploy PostgreSQL Monitor only. Usage: make postgres_monitor_deploy ENV=hoodi
1690+ @if [ -z " $( ENV) " ]; then \
1691+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1692+ exit 1; \
1693+ fi
1694+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /pg_monitor.yaml \
1695+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1696+ -e " host=postgres_monitor" \
1697+ -e " env=$( ENV) "
1698+
1699+ .PHONY : postgres_nodes_deploy
1700+ postgres_nodes_deploy : # # Deploy PostgreSQL Primary & Secondary. Usage: make postgres_nodes_deploy ENV=hoodi
1701+ @if [ -z " $( ENV) " ]; then \
1702+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1703+ exit 1; \
1704+ fi
1705+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /pg_node.yaml \
1706+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1707+ -e " host=postgres_primary" \
1708+ -e " env=$( ENV) "
1709+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /pg_node.yaml \
1710+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1711+ -e " host=postgres_secondary" \
1712+ -e " env=$( ENV) "
1713+
1714+ .PHONY : postgres_migrations
1715+ postgres_migrations : # # Run database migrations. Usage: make postgres_migrations ENV=hoodi
1716+ @if [ -z " $( ENV) " ]; then \
1717+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1718+ exit 1; \
1719+ fi
1720+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /postgres_migrations.yaml \
1721+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1722+ -e " host=postgres_primary" \
1723+ -e " env=$( ENV) "
1724+
1725+ .PHONY : postgres_status
1726+ postgres_status : # # Check PostgreSQL cluster status. Usage: make postgres_status ENV=hoodi
1727+ @if [ -z " $( ENV) " ]; then \
1728+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1729+ exit 1; \
1730+ fi
1731+ @ansible postgres_monitor -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1732+ -m shell -a " sudo -u postgres pg_autoctl show state --monitor postgres://autoctl_node@localhost:5432/pg_auto_failover" --become
1733+
1734+ # ------------------------------------------------------------------------------
1735+ # Gateway & Poller Deployment
1736+ # ------------------------------------------------------------------------------
1737+
1738+ .PHONY : gateway_deploy
1739+ gateway_deploy : # # Deploy Gateway & Poller on both servers. Usage: make gateway_deploy ENV=hoodi
1740+ @if [ -z " $( ENV) " ]; then \
1741+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1742+ exit 1; \
1743+ fi
1744+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /gateway_stack.yaml \
1745+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1746+ -e " host=gateway_primary" \
1747+ -e " env=$( ENV) "
1748+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /gateway_stack.yaml \
1749+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1750+ -e " host=gateway_secondary" \
1751+ -e " env=$( ENV) "
1752+
1753+ .PHONY : gateway_primary_deploy
1754+ gateway_primary_deploy : # # Deploy Gateway & Poller on primary only. Usage: make gateway_primary_deploy ENV=hoodi
1755+ @if [ -z " $( ENV) " ]; then \
1756+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1757+ exit 1; \
1758+ fi
1759+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /gateway_stack.yaml \
1760+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1761+ -e " host=gateway_primary" \
1762+ -e " env=$( ENV) "
1763+
1764+ .PHONY : gateway_secondary_deploy
1765+ gateway_secondary_deploy : # # Deploy Gateway & Poller on secondary only. Usage: make gateway_secondary_deploy ENV=hoodi
1766+ @if [ -z " $( ENV) " ]; then \
1767+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1768+ exit 1; \
1769+ fi
1770+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /gateway_stack.yaml \
1771+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1772+ -e " host=gateway_secondary" \
1773+ -e " env=$( ENV) "
1774+
1775+ # ------------------------------------------------------------------------------
1776+ # Metrics Deployment
1777+ # ------------------------------------------------------------------------------
1778+
1779+ .PHONY : metrics_deploy
1780+ metrics_deploy : # # Deploy Prometheus & Grafana. Usage: make metrics_deploy ENV=hoodi
1781+ @if [ -z " $( ENV) " ]; then \
1782+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1783+ exit 1; \
1784+ fi
1785+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /metrics_stack.yaml \
1786+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1787+ -e " host=metrics" \
1788+ -e " env=$( ENV) "
1789+
1790+ .PHONY : prometheus_deploy
1791+ prometheus_deploy : # # Deploy Prometheus only. Usage: make prometheus_deploy ENV=hoodi
1792+ @if [ -z " $( ENV) " ]; then \
1793+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1794+ exit 1; \
1795+ fi
1796+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /prometheus_agg_mode.yaml \
1797+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1798+ -e " host=metrics" \
1799+ -e " env=$( ENV) "
1800+
1801+ .PHONY : grafana_deploy
1802+ grafana_deploy : # # Deploy Grafana only. Usage: make grafana_deploy ENV=hoodi
1803+ @if [ -z " $( ENV) " ]; then \
1804+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1805+ exit 1; \
1806+ fi
1807+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /grafana_agg_mode.yaml \
1808+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1809+ -e " host=metrics" \
1810+ -e " env=$( ENV) "
1811+
1812+ # ------------------------------------------------------------------------------
1813+ # Full Deployment
1814+ # ------------------------------------------------------------------------------
1815+
1816+ .PHONY : agg_mode_deploy_all
1817+ agg_mode_deploy_all : # # Deploy entire aggregation mode stack. Usage: make agg_mode_deploy_all ENV=hoodi
1818+ @if [ -z " $( ENV) " ]; then \
1819+ echo " Error: ENV must be set (hoodi or mainnet)" ; \
1820+ exit 1; \
1821+ fi
1822+ @ansible-playbook $(AGG_MODE_PLAYBOOKS_DIR ) /deploy_all.yaml \
1823+ -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1824+ -e " env=$( ENV) "
1825+
1826+ # ------------------------------------------------------------------------------
1827+ # Service Management
1828+ # ------------------------------------------------------------------------------
1829+
1830+ .PHONY : gateway_restart
1831+ gateway_restart : # # Restart gateway service. Usage: make gateway_restart ENV=hoodi HOST=gateway_primary
1832+ @if [ -z " $( ENV) " ] || [ -z " $( HOST) " ]; then \
1833+ echo " Error: ENV and HOST must be set" ; \
1834+ exit 1; \
1835+ fi
1836+ @ansible $(HOST ) -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1837+ -m shell -a " sudo systemctl restart gateway" --become
1838+
1839+ .PHONY : poller_restart
1840+ poller_restart : # # Restart poller service. Usage: make poller_restart ENV=hoodi HOST=gateway_primary
1841+ @if [ -z " $( ENV) " ] || [ -z " $( HOST) " ]; then \
1842+ echo " Error: ENV and HOST must be set" ; \
1843+ exit 1; \
1844+ fi
1845+ @ansible $(HOST ) -i $(AGG_MODE_ANSIBLE_DIR ) /$(ENV ) -inventory.yaml \
1846+ -m shell -a " systemctl --user restart poller"
0 commit comments