forked from Vonng/pigsty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.yml
executable file
·111 lines (109 loc) · 4.3 KB
/
node.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env ansible-playbook
---
#==============================================================#
# File : node.yml
# Desc : init node for pigsty
# Ctime : 2020-05-12
# Mtime : 2023-02-20
# Path : node.yml
# Author : Ruohang Feng ([email protected])
# License : AGPLv3
#==============================================================#
- name: NODE
hosts: all
become: yes
gather_facts: no
roles:
- { role: node_id , tags: id } # get node identity (always)
- { role: node , tags: node } # prepare node for pigsty
- { role: haproxy , tags: haproxy } # init haproxy optional
- { role: node_monitor , tags: monitor } # init node monitor
#---------------------------------------------------------------
# Usage
#---------------------------------------------------------------
# 1. make sure you have nopass ssh & sudo access to target node
# 2. make sure you have defined these nodes in your inventory
# 3. run ./node.yml -l <selector> to finish node provisioning
#
# Add node to pigsty:
# node.yml -l <cls> # add groups
# node.yml -l <ip> # add single node
#
# Bootstrap with another admin user: (Create admin with another admin)
# node.yml -t node_admin # create admin user for nodes
# node.yml -t node_admin -k -K -e ansible_user=<another admin>
#
#--------------------------------------------------------------#
# Utils
#--------------------------------------------------------------#
#
# bin/node-add pg-meta # init nodes of group `pg-meta`
# bin/node-add pg-meta pg-test # init multiple node groups
# bin/node-add 10.10.10.10 # init node with ip `10.10.10.10`
# bin/node-add 10.10.10.1* # init node with pattern `10.10.10.1*`
# bin/node-add 1.2.3.4 5.6.7.8 # init multiple nodes
#
#---------------------------------------------------------------
# Identity
#---------------------------------------------------------------
# nodename : optional, used as node identity, default to existing name
# node_cluster : optional, used as node identity, default to `nodes`
#
# cls: node_cluster (explicit) > pg_cluster (when node_id_from_pg) > 'nodes'
# ins: nodename (explicit) > pg_instance (when node_id_from_pg) > node.hostname
#
# you can overwrite node identity with pgsql identity on 1:1 deployment
# with option `node_id_from_pg: true`
#
# 1. node identity can be specified by nodename or node_cluster explicitly (override all)
# 2. if node identity is not specified and node_id_from_pg is set, it will use pg's instance identity if applicable
# 3. otherwise, node_cluster will fall back to `nodes` and nodename will fall back to node's current hostname
#---------------------------------------------------------------
# Tasks
#---------------------------------------------------------------
# node-id : generate node identity
# node_name : setup hostname
# node_hosts : setup /etc/hosts records
# node_resolv : setup dns resolver
# node_firewall : setup firewall & selinux
# node_ca : add & trust ca certificate
# node_repo : add upstream repo
# node_pkg : install yum packages
# node_feature : setup numa, grub, static network
# node_kernel : enable kernel modules
# node_tune : setup tuned profile
# node_sysctl : setup additional sysctl parameters
# node_profile : write /etc/profile.d/node.sh
# node_ulimit : setup resource limits
# node_data : setup main data dir
# node_admin : setup admin user and ssh key
# node_timezone : setup timezone
# node_ntp : setup ntp server/clients
# node_crontab : add/overwrite crontab tasks
# node_vip : setup optional l2 vrrp vip for node cluster
# - vip_install
# - vip_config
# - vip_launch
# - vip_reload
# haproxy : setup haproxy on node to expose services
# - haproxy_install
# - haproxy_config
# - haproxy_launch
# - haproxy_reload
# monitor : setup node_exporter & promtail for metrics & logs
# - haproxy_register
# - vip_dns
# - node_exporter
# - node_exporter_config
# - node_exporter_launch
# - vip_exporter
# - vip_exporter_config
# - vip_exporter_launch
# - node_register
# - promtail
# - promtail_install
# - promtail_clean
# - promtail_config
# - promtail_launch
#---------------------------------------------------------------
...