pmcf 5.0.3 → 6.0.1

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/README.md CHANGED
@@ -42,61 +42,63 @@ generates config packages for:
42
42
  ### Table of Contents
43
43
 
44
44
  * [Base](#base)
45
- * [Parameters](#parameters)
46
45
  * [mapFromDirections](#mapfromdirections)
47
- * [Parameters](#parameters-1)
46
+ * [Parameters](#parameters)
48
47
  * [unionFromDirections](#unionfromdirections)
49
- * [Parameters](#parameters-2)
48
+ * [Parameters](#parameters-1)
50
49
  * [walkDirections](#walkdirections)
51
- * [Parameters](#parameters-3)
50
+ * [Parameters](#parameters-2)
52
51
  * [attribute](#attribute)
53
- * [Parameters](#parameters-4)
52
+ * [Parameters](#parameters-3)
54
53
  * [attributeIterator](#attributeiterator)
55
- * [Parameters](#parameters-5)
54
+ * [Parameters](#parameters-4)
56
55
  * [getAttributes](#getattributes)
57
- * [Parameters](#parameters-6)
56
+ * [Parameters](#parameters-5)
58
57
  * [property](#property)
59
- * [Parameters](#parameters-7)
58
+ * [Parameters](#parameters-6)
60
59
  * [priority](#priority)
61
60
  * [expression](#expression)
62
- * [Parameters](#parameters-8)
61
+ * [Parameters](#parameters-7)
63
62
  * [templateContent](#templatecontent)
64
- * [Parameters](#parameters-9)
63
+ * [Parameters](#parameters-8)
65
64
  * [isTemplate](#istemplate)
66
65
  * [expand](#expand)
67
- * [Parameters](#parameters-10)
66
+ * [Parameters](#parameters-9)
68
67
  * [PortEndpoint](#portendpoint)
69
- * [Parameters](#parameters-11)
68
+ * [Parameters](#parameters-10)
70
69
  * [port](#port)
71
70
  * [socketAddress](#socketaddress)
72
71
  * [HTTPEndpoint](#httpendpoint)
73
- * [Parameters](#parameters-12)
72
+ * [Parameters](#parameters-11)
74
73
  * [port](#port-1)
75
74
  * [id](#id)
75
+ * [domainNames](#domainnames)
76
76
  * [InitializationContext](#initializationcontext)
77
- * [Parameters](#parameters-13)
78
- * [SkeletonNetworkInterface](#skeletonnetworkinterface)
79
- * [networkAddresses](#networkaddresses)
80
- * [Parameters](#parameters-14)
77
+ * [Parameters](#parameters-12)
81
78
  * [SystemdJournalRemoteService](#systemdjournalremoteservice)
82
79
  * [Properties](#properties)
83
80
  * [systemdConfigs](#systemdconfigs)
84
- * [Parameters](#parameters-15)
81
+ * [Parameters](#parameters-13)
85
82
  * [SystemdJournalUploadService](#systemdjournaluploadservice)
86
83
  * [Properties](#properties-1)
87
84
  * [systemdConfigs](#systemdconfigs-1)
88
- * [Parameters](#parameters-16)
85
+ * [Parameters](#parameters-14)
89
86
  * [NetworkAddress](#networkaddress)
90
- * [Parameters](#parameters-17)
87
+ * [Parameters](#parameters-15)
91
88
  * [subnet](#subnet)
92
89
  * [networkInterface](#networkinterface)
93
90
  * [address](#address)
94
91
  * [addresses](#addresses)
95
- * [Parameters](#parameters-18)
92
+ * [Parameters](#parameters-16)
96
93
  * [cidrAddresses](#cidraddresses)
97
- * [Parameters](#parameters-19)
94
+ * [Parameters](#parameters-17)
95
+ * [SkeletonNetworkInterface](#skeletonnetworkinterface)
96
+ * [networkAddresses](#networkaddresses)
97
+ * [Parameters](#parameters-18)
98
98
  * [secretName](#secretname)
99
- * [isTemplate](#istemplate-1)
99
+ * [directHosts](#directhosts)
100
+ * [subnetForAddress](#subnetforaddress)
101
+ * [Parameters](#parameters-19)
100
102
  * [serviceEndpoints](#serviceendpoints)
101
103
  * [Parameters](#parameters-20)
102
104
  * [domainName](#domainname)
@@ -115,11 +117,6 @@ generates config packages for:
115
117
  attributes: as declared in the types
116
118
  properties: use defined values to support attribute value definitions
117
119
 
118
- ### Parameters
119
-
120
- * `owner` **[Base](#base)** 
121
- * `data` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** 
122
-
123
120
  ### mapFromDirections
124
121
 
125
122
  Deliver AggregatedMap of all property Maps.
@@ -261,6 +258,10 @@ Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
261
258
 
262
259
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
263
260
 
261
+ ## domainNames
262
+
263
+ Returns **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
264
+
264
265
  ## InitializationContext
265
266
 
266
267
  Keeps track of all in flight object creations and loose ends during config initialization.
@@ -269,18 +270,6 @@ Keeps track of all in flight object creations and loose ends during config initi
269
270
 
270
271
  * `directory` (optional, default `"/"`)
271
272
 
272
- ## SkeletonNetworkInterface
273
-
274
- **Extends ServiceOwner**
275
-
276
- ### networkAddresses
277
-
278
- #### Parameters
279
-
280
- * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
281
-
282
- Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
283
-
284
273
  ## SystemdJournalRemoteService
285
274
 
286
275
  **Extends Service**
@@ -356,13 +345,33 @@ Returns **Iterable<[string](https://developer.mozilla.org/docs/Web/JavaScript/Re
356
345
 
357
346
  Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**&#x20;
358
347
 
348
+ ## SkeletonNetworkInterface
349
+
350
+ **Extends ServiceOwner**
351
+
352
+ ### networkAddresses
353
+
354
+ #### Parameters
355
+
356
+ * `filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `n=>true`)
357
+
358
+ Returns **Iterable<[NetworkAddress](#networkaddress)>**&#x20;
359
+
359
360
  ## secretName
360
361
 
361
362
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
362
363
 
363
- ## isTemplate
364
+ ## directHosts
364
365
 
365
- Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**&#x20;
366
+ hosts we own direcly.
367
+
368
+ ## subnetForAddress
369
+
370
+ ### Parameters
371
+
372
+ * `address` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
373
+
374
+ Returns **Subnet?**&#x20;
366
375
 
367
376
  ## serviceEndpoints
368
377
 
@@ -388,7 +397,7 @@ Appends default domain if name does not already have a domain.
388
397
  * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
389
398
  * `defaultDomain` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**&#x20;
390
399
 
391
- Returns **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**&#x20;
400
+ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
392
401
 
393
402
  ## domainFromDominName
394
403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "5.0.3",
3
+ "version": "6.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "aggregated-map": "^1.0.7",
54
54
  "content-entry-transform": "^1.6.9",
55
- "ip-utilties": "^3.1.3",
55
+ "ip-utilties": "^3.2.0",
56
56
  "npm-pkgbuild": "^20.7.12",
57
57
  "pacc": "^10.4.0",
58
58
  "package-directory": "^8.2.0"
package/src/cluster.mjs CHANGED
@@ -56,19 +56,15 @@ export class Cluster extends Host {
56
56
  )) {
57
57
  const host = ni.host;
58
58
  const packageStagingDir = join(stagingDir, host.name);
59
- const location = `${this.owner.name}-${host.name}`;
59
+ const name = `${this.owner.name}-${host.name}`;
60
60
 
61
61
  const packageData = host.packageData;
62
62
  packageData.sources.push(
63
63
  new FileContentProvider(packageStagingDir + "/")
64
64
  );
65
- packageData.properties.name = `keepalived-${location}`;
65
+ packageData.properties.name = `keepalived-${name}`;
66
66
  packageData.properties.description = `${this.typeName} definitions for ${this.fullName}`;
67
- packageData.properties.groups.push(
68
- "service-config",
69
- location,
70
- "keepalived"
71
- );
67
+ packageData.properties.groups.push("service-config", name, "keepalived");
72
68
 
73
69
  const extra = [];
74
70
 
@@ -91,6 +87,7 @@ export class Cluster extends Host {
91
87
  ""
92
88
  ];
93
89
 
90
+ const credentials = [];
94
91
  for (const cluster of [...this.owner.clusters].sort((a, b) =>
95
92
  a.name.localeCompare(b.name)
96
93
  )) {
@@ -123,12 +120,14 @@ export class Cluster extends Host {
123
120
  reducedPrio = cluster.backups.indexOf(ni) + 5;
124
121
  }
125
122
 
123
+ const credential = cluster.name.toUpperCase() + "_PASSWORD";
124
+ credentials.push(credential);
126
125
  cfg.push(` priority ${host.priority - reducedPrio}`);
127
126
  cfg.push(" smtp_alert");
128
127
  cfg.push(" advert_int 5");
129
128
  cfg.push(" authentication {");
130
129
  cfg.push(" auth_type PASS");
131
- cfg.push(" auth_pass pass1234");
130
+ cfg.push(" auth_pass ${" + credential + "}");
132
131
  cfg.push(" }");
133
132
 
134
133
  cfg.push(
@@ -218,6 +217,18 @@ export class Cluster extends Host {
218
217
  `Conflicts=${cluster.name}-master.target ${cluster.name}-backup.target`
219
218
  ]
220
219
  );
220
+
221
+ await writeLines(
222
+ join(packageStagingDir, "/usr/lib/systemd/system/keepalived.d"),
223
+ `use-credentials.conf`,
224
+ [
225
+ "[Service]",
226
+ ...credentials.map(
227
+ c =>
228
+ `LoadCredentialEncrypted=${c}:/etc/credstore.encrypted/keepalived.password`
229
+ )
230
+ ]
231
+ );
221
232
  }
222
233
 
223
234
  await writeLines(
@@ -64,7 +64,7 @@ export class wlan extends ethernet {
64
64
 
65
65
  await writeLines(
66
66
  join(dir, "usr/lib/systemd/system/iwd.service.d/"),
67
- "pmcf.conf",
67
+ "credentials.conf",
68
68
  [
69
69
  sectionLines("Service", {
70
70
  LoadCredentialEncrypted: `${secretName}:/etc/credstore.encrypted/${secretName}`
@@ -0,0 +1,62 @@
1
+ import {
2
+ default_attribute_writable,
3
+ string_collection_attribute_writable,
4
+ string_attribute_writable,
5
+ integer_attribute_writable,
6
+ hostname_attribute as hostname_attribute_base,
7
+ boolean_attribute_writable
8
+ } from "pacc";
9
+
10
+ export const networkAddressType = "network|host|network_interface";
11
+
12
+ export const networks_attribute = {
13
+ ...default_attribute_writable,
14
+ name: "networks",
15
+ type: "network",
16
+ collection: true
17
+ };
18
+
19
+ export const psk_attribute = { ...string_attribute_writable, name: "psk" };
20
+ export const ssid_attribute = { ...string_attribute_writable, name: "ssid" };
21
+ export const hostname_attribute = {
22
+ ...hostname_attribute_base,
23
+ name: "hostName",
24
+ writable: true
25
+ };
26
+
27
+ export const networkAttributes = {
28
+ scope: {
29
+ ...string_attribute_writable,
30
+ name: "scope",
31
+ values: ["global", "site", "link", "host"]
32
+ // default: "global"
33
+ },
34
+ class: {
35
+ ...string_attribute_writable,
36
+ name: "class",
37
+ values: ["10GBASE-T", "1000BASE-T", "100BASE-T", "10BASE-T"]
38
+ },
39
+ kind: {
40
+ ...string_attribute_writable,
41
+ name: "kind",
42
+ values: ["loopback", "ethernet", "wlan", "wireguard", "fiber", "dsl"]
43
+ },
44
+ ssid: ssid_attribute,
45
+ psk: psk_attribute,
46
+ secretName: { ...string_attribute_writable, name: "secretName" },
47
+ metric: { ...integer_attribute_writable, name: "metric" /*default: 1004*/ },
48
+ mtu: { ...integer_attribute_writable, name: "mtu", default: 1500 },
49
+ gateway: { ...default_attribute_writable, name: "gateway", type: "host" },
50
+ multicastDNS: { ...boolean_attribute_writable, name: "multicastDNS" }
51
+ };
52
+
53
+ export const networkAddressAttributes = {
54
+ hostName: hostname_attribute,
55
+ cidrAddresses: {
56
+ ...string_collection_attribute_writable,
57
+ name: "cidrAddresses"
58
+ },
59
+ cidrAddress: { ...string_attribute_writable, name: "cidrAddress" },
60
+ addresses: { ...string_collection_attribute_writable, name: "addresses" },
61
+ address: { ...string_attribute_writable, name: "address" }
62
+ };