#!/usr/bin/env ansible-playbook
---
#==============================================================#
# File      :   slim.yml
# Desc      :   pure postgres installation with out infra
# Ctime     :   2024-09-02
# Mtime     :   2025-12-15
# Path      :   slim.yml
# Docs      :   https://pigsty.io/docs/setup/slim
# License   :   Apache-2.0 @ https://pigsty.io/docs/about/license/
# Copyright :   2018-2026  Ruohang Feng / Vonng (rh@vonng.com)
#==============================================================#


# The minimal installation focus on Pure HA-PostgreSQL Cluster
# It only install essential components for this purpose
#
# There's NO Infra modules, No monitoring, No software repo
# Just partial of NODE module, along with ETCD & PGSQL modules
#
# Systemd Service Installed in this mode:
#
# patroni, pgbouncer, vip-manager, haproxy, etcd, chronyd, tuned


#---------------------------------------------------------------
# setup node & pgsql identity
#---------------------------------------------------------------
- name: IDENTITY
  hosts: all
  gather_facts: no
  tags: id
  roles:
    - { role: node_id ,tags: node-id }
    - { role: pg_id   ,tags: pg-id ,when: pg_cluster is defined }

#---------------------------------------------------------------
# Setup local CA
#---------------------------------------------------------------
- name: CA
  become: true
  hosts: localhost
  gather_facts: no
  tags: ca
  roles: [ { role: ca } ]

#---------------------------------------------------------------
# init node and haproxy
#---------------------------------------------------------------
- name: NODE INIT
  become: true
  hosts: all
  gather_facts: no
  tags: node
  roles:
    - { role: node    , tags: node     }  # prepare node for pigsty
    - { role: haproxy , tags: haproxy  }  # init haproxy optional

#---------------------------------------------------------------
# ETCD INIT
#---------------------------------------------------------------
- name: ETCD INIT
  become: true
  hosts: etcd
  gather_facts: no
  tags: etcd
  roles: [ { role: etcd } ]   # init etcd on fixed group 'etcd'

#---------------------------------------------------------------
# INIT PGSQL
#---------------------------------------------------------------
- name: PGSQL INIT            # init pgsql on all nodes
  become: true                 # with pg_cluster defined
  hosts: all
  gather_facts: no
  tags: pgsql
  roles: [ { role: pgsql ,when: pg_cluster is defined } ]

...