#!/usr/bin/env ansible-playbook --- #==============================================================# # File : deploy # Desc : deploy everything on all nodes # Ctime : 2021-01-19 # Mtime : 2026-08-06 # Path : deploy.yml # Docs : https://pigsty.io/docs/infra/playbook # License : Apache-2.0 @ https://pigsty.io/docs/about/license/ # Copyright : 2018-2026 Ruohang Feng / Vonng (rh@vonng.com) #==============================================================# #==============================================================# # deploy will interleave infra.yml & node.yml in following # orders to set up everything in one pass # - id : generate node & pgsql identity # - ca : create self-signed CA on localhost # - repo : create local yum repo on infra nodes # - node-init : init node, haproxy & docker # - infra : init nginx, dns, victoria, grafana # - node-monitor : init node-exporter vector # - etcd : init etcd (required for pgsql HA) # - vault : init vault (optional, kms for pg_tde & kes) # - minio : init minio (optional) # - pgsql : init pgsql # - pgsql-monitor : init pgsql # # Which is equivalent to the following 4 playbooks altogether: # - infra.yml -l infra deploy infrastructure on group 'infra' # - node.yml -l all init all nodes # - etcd.yml -l etcd init etcd on group 'etcd' for pg ha # - vault.yml -l vault init vault on group 'vault' for pg_tde & kes # - minio.yml -l init minio hosts marked with minio_cluster # - pgsql.yml -l all init pgsql database clusters on all nodes #==============================================================# #--------------------------------------------------------------- # 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 } ] #--------------------------------------------------------------- # bootstrap a local yum repo #--------------------------------------------------------------- - name: REPO become: true hosts: infra gather_facts: no tags: repo roles: [ { role: repo } ] #--------------------------------------------------------------- # init node , ca, docker #--------------------------------------------------------------- - name: NODE INIT become: true hosts: all gather_facts: no tags: node-init roles: - { role: node ,tags: node } # prepare node for pigsty - { role: haproxy ,tags: haproxy } # init haproxy if enabled #--------------------------------------------------------------- # init dns, nginx, victoria, grafana #--------------------------------------------------------------- - name: INFRA INIT become: true hosts: infra gather_facts: no tags: infra roles: [ { role: infra } ] #--------------------------------------------------------------- # Node Monitor #--------------------------------------------------------------- - name: NODE MONITOR become: true hosts: all gather_facts: no tags: [ monitor, node-monitor ] roles: [ { role: node_monitor } ] #--------------------------------------------------------------- # ETCD INIT #--------------------------------------------------------------- - name: ETCD INIT become: true hosts: etcd gather_facts: no tags: etcd roles: [ { role: etcd } ] # init etcd on fixed group 'etcd' #--------------------------------------------------------------- # VAULT INIT #--------------------------------------------------------------- - name: VAULT INIT become: true hosts: vault gather_facts: no tags: vault roles: [ { role: vault } ] # init vault on fixed group 'vault' #--------------------------------------------------------------- # MINIO INIT #--------------------------------------------------------------- - name: MINIO INIT become: true hosts: all gather_facts: no tags: minio pre_tasks: [ { name: skip non-minio hosts ,meta: end_host ,when: minio_cluster is not defined ,tags: always } ] roles: [ { role: minio ,when: minio_cluster is defined } ] #--------------------------------------------------------------- # PGSQL INIT #--------------------------------------------------------------- - name: PGSQL INIT # init pgsql on all nodes become: true # with pg_cluster defined hosts: all gather_facts: no tags: pgsql pre_tasks: [ { name: skip non-pgsql hosts ,meta: end_host ,when: pg_cluster is not defined ,tags: always } ] roles: - { role: pgsql ,when: pg_cluster is defined } - { role: pg_monitor ,when: pg_cluster is defined } ...