-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.ini.ts
52 lines (45 loc) · 1.95 KB
/
inventory.ini.ts
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
import { controlPlanes, etcds, Node, workers } from "./helpers.ts";
const ini = String.raw;
/**
* Transform a Node object to a string representation for the inventory.ini file.
* Includes the node index in the comment if available.
*
* @param node The Node object
* @returns String representation for inventory.ini
*/
const transformNodeToString = (node: Node): string => {
return [
node.name,
`ansible_host=${node.publicIp}`,
`ip=${node.privateIp}`,
node.roles.includes("etcd") ? `etcd_member_name=${node.name}` : '',
[
'#',
`roles=${node.roles.join(",")}`,
node.index !== undefined ? `# index=${node.index}` : '',
].filter(Boolean).join(' '),
].filter(Boolean).join('\t')
};
export default ini`
# This inventory is auto-generated by 'make generate'
# See https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html
# for tips on building your inventory
# ⚠️ IMPORTANT: Node naming convention
# Each node name must start with the domain name prefix (<domain-name>-) followed by the role:
# - Control Plane Nodes: <domain-name>-control-plane-X[-etcd][-worker] (where X is the index: 0, 1, 2, etc.)
# - ETCD Nodes: <domain-name>-etcd-X (where X is the index: 0, 1, 2, etc.)
# - Worker Nodes: <domain-name>-worker-X[-etcd] (where X is the index: 0, 1, 2, etc.)
#
# ⚠️ WARNING: DO NOT change the first control plane node (<domain-name>-control-plane-0) without understanding
# the implications! See README.md for more details on the proper procedure for replacing
# the first control plane node.
# Configure 'ip' variable to bind kubernetes services on a different ip than the default iface
# We should set etcd_member_name for etcd cluster. The node that are not etcd members do not need to set the value,
# or can set the empty string value.
[kube_control_plane]
${controlPlanes.map(transformNodeToString).join("\n")}
[etcd]
${etcds.map(transformNodeToString).join("\n")}
[kube_node]
${workers.map(transformNodeToString).join("\n")}
`;