pmcf 1.59.12 → 1.59.13

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cluster.mjs +30 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.59.12",
3
+ "version": "1.59.13",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -50,6 +50,7 @@ export class Cluster extends Host {
50
50
  }
51
51
 
52
52
  async *preparePackages(stagingDir) {
53
+
53
54
  const result = {
54
55
  sources: [],
55
56
  outputs: this.outputs,
@@ -58,26 +59,36 @@ export class Cluster extends Host {
58
59
  access: "private"
59
60
  }
60
61
  };
62
+
63
+ let interfaces = new Set();
61
64
 
62
- for (const ni of this.masters.union(this.backups)) {
63
- const name = `${this.typeName}-${this.owner.name}-${this.name}-${ni.host.name}`;
65
+ for(const cluster of this.owner.clusters()) {
66
+ interfaces = interfaces.union(cluster.masters.union(cluster.backups));
67
+ }
68
+
69
+ for (const ni of interfaces) {
70
+ const name = `keepalived-${ni.host.name}`;
64
71
  const packageStagingDir = join(stagingDir, name);
65
- const cfg = [
66
- `vrrp_instance ${this.name} {`,
67
- ` state ${this.masters.has(ni) ? "MASTER" : "BACKUP"}`,
68
- ` interface ${ni.name}`,
69
- " virtual_router_id 101",
70
- " priority 255",
71
- " advert_int 1",
72
- " authentication {",
73
- " auth_type PASS",
74
- " auth_pass pass1234",
75
- " }",
76
- " virtual_ipaddress {",
77
- ` ${this.rawAddress}`,
78
- " }",
79
- "}"
80
- ];
72
+
73
+ const cfg = [];
74
+
75
+ for(const cluster of this.owner.clusters()) {
76
+ cfg.push(`vrrp_instance ${cluster.name} {`);
77
+ cfg.push(` state ${cluster.masters.has(ni) ? "MASTER" : "BACKUP"}`);
78
+ cfg.push(` interface ${ni.name}`,);
79
+ cfg.push(" virtual_ipaddress {");
80
+ cfg.push(` ${cluster.rawAddress}`);
81
+ cfg.push(" }");
82
+ cfg.push(" virtual_router_id 101");
83
+ cfg.push(" priority 255");
84
+ cfg.push(" advert_int 1");
85
+ cfg.push(" authentication {");
86
+ cfg.push(" auth_type PASS");
87
+ cfg.push(" auth_pass pass1234");
88
+ cfg.push(" }");
89
+ cfg.push("}");
90
+ cfg.push("");
91
+ }
81
92
 
82
93
  await writeLines(
83
94
  join(packageStagingDir, "etc/keepalived"),
@@ -87,6 +98,7 @@ export class Cluster extends Host {
87
98
 
88
99
  result.properties.name = name;
89
100
  result.properties.dependencies = ["keepalived"];
101
+ result.properties.replaces = [`${this.typeName}-${this.owner.name}-${this.name}-${ni.host.name}`];
90
102
 
91
103
  result.sources.push(
92
104
  new FileContentProvider(packageStagingDir + "/")[Symbol.asyncIterator]()