pmcf 6.65.2 → 6.65.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/services/keepalived.mjs +24 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmcf",
|
|
3
|
-
"version": "6.65.
|
|
3
|
+
"version": "6.65.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"yaml": "^2.9.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@types/node": "^26.6.
|
|
63
|
+
"@types/node": "^26.6.3",
|
|
64
64
|
"ava": "^8.0.1",
|
|
65
65
|
"c8": "^12.0.0",
|
|
66
66
|
"documentation": "^14.0.3",
|
|
@@ -71,6 +71,8 @@ export class keepalive_cluster_member extends core {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
const states = ["master", "backup", "fault"];
|
|
75
|
+
|
|
74
76
|
export class keepalived extends CoreService {
|
|
75
77
|
static priority = 1.5;
|
|
76
78
|
static attributes = {
|
|
@@ -123,19 +125,14 @@ export class keepalived extends CoreService {
|
|
|
123
125
|
|
|
124
126
|
cfg.push(` interface ${ni.name}`);
|
|
125
127
|
|
|
128
|
+
cfg.push(" virtual_ipaddress {");
|
|
129
|
+
|
|
126
130
|
for (const na of cluster.networkAddresses(
|
|
127
131
|
na => na.networkInterface.kind !== "loopback"
|
|
128
132
|
)) {
|
|
129
|
-
cfg.push(
|
|
130
|
-
` ${
|
|
131
|
-
na.family === FAMILY_IPV4
|
|
132
|
-
? "virtual_ipaddress"
|
|
133
|
-
: "virtual_ipaddress_excluded"
|
|
134
|
-
} {`
|
|
135
|
-
);
|
|
136
133
|
cfg.push(` ${na.cidrAddress} dev ${ni.name} label ${clusterName}`);
|
|
137
|
-
cfg.push(" }");
|
|
138
134
|
}
|
|
135
|
+
cfg.push(" }");
|
|
139
136
|
|
|
140
137
|
cfg.push(` virtual_router_id ${cluster.id}`);
|
|
141
138
|
|
|
@@ -150,19 +147,19 @@ export class keepalived extends CoreService {
|
|
|
150
147
|
cfg.push(" advert_int 5");
|
|
151
148
|
cfg.push(" authentication {");
|
|
152
149
|
cfg.push(" auth_type PASS");
|
|
153
|
-
cfg.push(" auth_pass pass1234");
|
|
154
150
|
cfg.push(
|
|
155
|
-
`
|
|
151
|
+
` auth_pass file:\${_ENV CREDENTIALS_DIRECTORY}/keepalived.${cluster.name}.password`
|
|
156
152
|
);
|
|
153
|
+
cfg.push(" # auth_pass pass1234");
|
|
157
154
|
cfg.push(" # auth_pass ${_ENV " + cred.localName + "}");
|
|
158
155
|
cfg.push(" # auth_pass ${" + cred.localName + "}");
|
|
159
156
|
cfg.push(" }");
|
|
160
157
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
for (const state of states) {
|
|
159
|
+
cfg.push(
|
|
160
|
+
` notify_${state} "/usr/bin/systemctl start ${clusterName}-${state}.target"`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
166
163
|
|
|
167
164
|
cfg.push("}", "");
|
|
168
165
|
|
|
@@ -214,37 +211,19 @@ export class keepalived extends CoreService {
|
|
|
214
211
|
cfg.push("}", "");
|
|
215
212
|
break; // only one for now
|
|
216
213
|
}
|
|
217
|
-
await writeLines(
|
|
218
|
-
join(dir, "/usr/lib/systemd/system"),
|
|
219
|
-
`${clusterName}-master.target`,
|
|
220
|
-
[
|
|
221
|
-
"[Unit]",
|
|
222
|
-
`Description=master state of cluster ${clusterName}`,
|
|
223
|
-
"PartOf=keepalived.service",
|
|
224
|
-
`Conflicts=${clusterName}-backup.target ${clusterName}-fault.target`
|
|
225
|
-
]
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
await writeLines(
|
|
229
|
-
join(dir, "/usr/lib/systemd/system"),
|
|
230
|
-
`${clusterName}-backup.target`,
|
|
231
|
-
[
|
|
232
|
-
"[Unit]",
|
|
233
|
-
`Description=backup state of cluster ${clusterName}`,
|
|
234
|
-
"PartOf=keepalived.service",
|
|
235
|
-
`Conflicts=${clusterName}-master.target ${clusterName}-fault.target`
|
|
236
|
-
]
|
|
237
|
-
);
|
|
238
214
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
215
|
+
for (const state of states) {
|
|
216
|
+
await writeLines(
|
|
217
|
+
join(dir, "/usr/lib/systemd/system"),
|
|
218
|
+
`${clusterName}-${state}.target`,
|
|
219
|
+
[
|
|
220
|
+
"[Unit]",
|
|
221
|
+
`Description=${state} state of cluster ${clusterName}`,
|
|
222
|
+
"PartOf=keepalived.service",
|
|
223
|
+
`Conflicts=${states.filter(s=>s!==state).map(other=>`${clusterName}-${other}.target`).join(' ')}`
|
|
224
|
+
]
|
|
225
|
+
);
|
|
226
|
+
}
|
|
248
227
|
|
|
249
228
|
await this.writeSystemdCredentialConfig(dir, "keepalived.service");
|
|
250
229
|
|