underpost 3.2.22 → 3.2.28
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/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/gitlab.ci.yml +1 -1
- package/.github/workflows/npmpkg.ci.yml +1 -1
- package/.github/workflows/publish.ci.yml +2 -2
- package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -1
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/CHANGELOG.md +141 -1
- package/CLI-HELP.md +56 -2
- package/README.md +3 -2
- package/baremetal/commission-workflows.json +1 -0
- package/bin/build.js +1 -0
- package/docker-compose.yml +224 -0
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/package.json +27 -15
- package/scripts/kubeadm-node-setup.sh +317 -0
- package/scripts/rocky-kickstart.sh +877 -185
- package/scripts/rpmfusion-ffmpeg-setup.sh +26 -50
- package/src/cli/baremetal.js +717 -16
- package/src/cli/cluster.js +3 -1
- package/src/cli/deploy.js +6 -2
- package/src/cli/docker-compose.js +591 -0
- package/src/cli/fs.js +35 -11
- package/src/cli/index.js +75 -0
- package/src/cli/kickstart.js +142 -20
- package/src/cli/repository.js +72 -11
- package/src/cli/run.js +253 -2
- package/src/cli/ssh.js +190 -0
- package/src/cli/static.js +2 -2
- package/src/{server → client-builder}/client-build-docs.js +15 -5
- package/src/{server → client-builder}/client-build-live.js +3 -3
- package/src/{server → client-builder}/client-build.js +25 -22
- package/src/{server → client-builder}/client-dev-server.js +3 -3
- package/src/{server → client-builder}/client-icons.js +2 -2
- package/src/{server → client-builder}/ssr.js +5 -5
- package/src/client.build.js +1 -1
- package/src/client.dev.js +1 -1
- package/src/index.js +12 -1
- package/src/mailer/EmailRender.js +1 -1
- package/src/{server → projects/underpost}/catalog-underpost.js +1 -2
- package/src/runtime/express/Express.js +2 -2
- package/src/runtime/nginx/Nginx.js +250 -0
- package/src/server/catalog.js +7 -14
- package/src/server/conf.js +3 -3
- package/src/server.js +1 -1
- package/typedoc.json +3 -1
- package/src/server/ipfs-client.js +0 -599
- /package/src/client/ssr/{Render.js → RootDocument.js} +0 -0
- /package/src/{server → client-builder}/client-formatted.js +0 -0
package/src/cli/fs.js
CHANGED
|
@@ -95,6 +95,17 @@ class UnderpostFileStorage {
|
|
|
95
95
|
) {
|
|
96
96
|
const { storage, storageConf } = Underpost.fs.getStorageConf(options);
|
|
97
97
|
|
|
98
|
+
// ── Single-file handling: when path is a file (not a directory), use parent dir
|
|
99
|
+
// as the git working directory and process just that one file. ──────────────
|
|
100
|
+
let isSingleFile = false;
|
|
101
|
+
let parentDir = path;
|
|
102
|
+
let singleFileName = '';
|
|
103
|
+
if (fs.existsSync(path) && !fs.statSync(path).isDirectory()) {
|
|
104
|
+
isSingleFile = true;
|
|
105
|
+
parentDir = dir.dirname(path);
|
|
106
|
+
singleFileName = path.split('/').pop();
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
// In recursive remove mode, delete every tracked storage key under the requested path,
|
|
99
110
|
// even when local files/directories are already missing.
|
|
100
111
|
if (options.rm === true) {
|
|
@@ -137,10 +148,15 @@ class UnderpostFileStorage {
|
|
|
137
148
|
return;
|
|
138
149
|
}
|
|
139
150
|
|
|
140
|
-
|
|
151
|
+
// For single files, run getDeleteFiles against the parent directory to avoid
|
|
152
|
+
// trying to `cd` into a file.
|
|
153
|
+
const gitContextPath = isSingleFile ? parentDir : path;
|
|
154
|
+
const deleteFiles = options.pull === true ? [] : Underpost.repo.getDeleteFiles(gitContextPath);
|
|
155
|
+
|
|
156
|
+
// When processing a single file, only consider it for deletion
|
|
141
157
|
for (const relativePath of deleteFiles) {
|
|
142
|
-
const _path = path + '/' + relativePath;
|
|
143
|
-
if (_path in storage) {
|
|
158
|
+
const _path = isSingleFile ? (relativePath === singleFileName ? path : null) : path + '/' + relativePath;
|
|
159
|
+
if (_path && _path in storage) {
|
|
144
160
|
await Underpost.fs.delete(_path);
|
|
145
161
|
delete storage[_path];
|
|
146
162
|
}
|
|
@@ -157,17 +173,25 @@ class UnderpostFileStorage {
|
|
|
157
173
|
// Only run git init/commit when the caller explicitly requests git tracking (--git flag).
|
|
158
174
|
// For bundle pulls into ./build the git step is unwanted and would error on a non-repo path.
|
|
159
175
|
if (options.git === true) {
|
|
160
|
-
Underpost.repo.initLocalRepo({ path });
|
|
161
|
-
shellExec(`cd ${
|
|
176
|
+
Underpost.repo.initLocalRepo({ path: gitContextPath });
|
|
177
|
+
shellExec(`cd ${gitContextPath} && git add . && git commit -m "Base pull state"`, {
|
|
162
178
|
silentOnError: true,
|
|
163
179
|
});
|
|
164
180
|
}
|
|
165
181
|
} else {
|
|
166
|
-
|
|
167
|
-
|
|
182
|
+
let files;
|
|
183
|
+
if (isSingleFile) {
|
|
184
|
+
// Single file: treat the file itself as the sole item to process
|
|
185
|
+
files = [singleFileName];
|
|
186
|
+
} else {
|
|
187
|
+
files =
|
|
188
|
+
options.git === true
|
|
189
|
+
? Underpost.repo.getChangedFiles(gitContextPath)
|
|
190
|
+
: await fs.readdir(path, { recursive: true });
|
|
191
|
+
}
|
|
168
192
|
for (const relativePath of files) {
|
|
169
|
-
const _path = path + '/' + relativePath;
|
|
170
|
-
if (fs.statSync(_path).isDirectory()) {
|
|
193
|
+
const _path = isSingleFile ? path : path + '/' + relativePath;
|
|
194
|
+
if (fs.existsSync(_path) && fs.statSync(_path).isDirectory()) {
|
|
171
195
|
if (options.pull === true && !fs.existsSync(_path)) fs.mkdirSync(_path, { recursive: true });
|
|
172
196
|
continue;
|
|
173
197
|
} else if (!(_path in storage) || options.force === true) {
|
|
@@ -178,8 +202,8 @@ class UnderpostFileStorage {
|
|
|
178
202
|
}
|
|
179
203
|
Underpost.fs.writeStorageConf(storage, storageConf);
|
|
180
204
|
if (options.git === true) {
|
|
181
|
-
shellExec(`cd ${
|
|
182
|
-
shellExec(`underpost cmt ${
|
|
205
|
+
shellExec(`cd ${gitContextPath} && git add .`);
|
|
206
|
+
shellExec(`underpost cmt ${gitContextPath} feat`, {
|
|
183
207
|
silentOnError: true,
|
|
184
208
|
silent: true,
|
|
185
209
|
disableLog: true,
|
package/src/cli/index.js
CHANGED
|
@@ -738,6 +738,37 @@ program
|
|
|
738
738
|
.description('Runs specified scripts using various runners.')
|
|
739
739
|
.action(Underpost.run.callback);
|
|
740
740
|
|
|
741
|
+
program
|
|
742
|
+
.command('docker-compose')
|
|
743
|
+
.argument('[target]', 'Optional service name for --logs, --shell, --restart, or --build.')
|
|
744
|
+
.option('--install', 'Install Docker Engine and the Compose v2 plugin on RHEL/Rocky hosts.')
|
|
745
|
+
.option(
|
|
746
|
+
'--reset',
|
|
747
|
+
'Comprehensive teardown (equivalent to cluster --reset): removes all stack containers, the network, named volumes (destroys data), orphans, and generated artifacts.',
|
|
748
|
+
)
|
|
749
|
+
.option('--force', 'Force reinstall (--install), remove volumes (--down), or also drop the env-file (--reset).')
|
|
750
|
+
.option(
|
|
751
|
+
'--deploy-id <deploy-id>',
|
|
752
|
+
"Deployment to run as the app container (default: dd-default). 'dd-default' self-bootstraps a fresh engine; any other id runs the standard 'underpost start' command (mirrors src/cli/deploy.js).",
|
|
753
|
+
)
|
|
754
|
+
.option('--env <env>', 'Deployment environment for non-default deploy ids (default: development).')
|
|
755
|
+
.option('--generate', 'Render dynamic supporting files (nginx router config, env-file, app-command override).')
|
|
756
|
+
.option('--up', 'Start the full stack detached (regenerates config first).')
|
|
757
|
+
.option('--down', 'Stop and remove containers (and orphans).')
|
|
758
|
+
.option('--volumes', 'With --down, also remove named volumes (destroys persisted data).')
|
|
759
|
+
.option('--restart', 'Restart services (optionally a single [target]).')
|
|
760
|
+
.option('--build', 'With --up rebuild images; alone, rebuilds images with --no-cache.')
|
|
761
|
+
.option('--pull', 'Pull upstream images for all services.')
|
|
762
|
+
.option('--logs', 'Follow logs for all services (optionally a single [target]).')
|
|
763
|
+
.option('--status', 'Show a formatted status table of services.')
|
|
764
|
+
.option('--shell', 'Open an interactive shell in [target] (default: app).')
|
|
765
|
+
.option('--exec <subcommand>', 'General-purpose passthrough docker compose subcommand.')
|
|
766
|
+
.option('--compose-file <path>', 'Path to the compose file (default: docker-compose.yml).')
|
|
767
|
+
.option('--env-file <path>', 'Path to the compose env-file (default: docker/compose.env).')
|
|
768
|
+
.option('--nginx-conf <path>', 'Path to the generated nginx config (default: docker/nginx/default.conf).')
|
|
769
|
+
.description('General-purpose Docker Compose development pipeline (mirrors the Kubernetes dev stack).')
|
|
770
|
+
.action(Underpost.dockerCompose.callback);
|
|
771
|
+
|
|
741
772
|
program
|
|
742
773
|
.command('lxd')
|
|
743
774
|
.argument(
|
|
@@ -856,6 +887,42 @@ program
|
|
|
856
887
|
.option('--remove-machines <system-ids>', 'Removes baremetal machines by comma-separated system IDs, or use "all"')
|
|
857
888
|
.option('--clear-discovered', 'Clears all discovered baremetal machines from the database.')
|
|
858
889
|
.option('--commission', 'Init workflow for commissioning a physical machine.')
|
|
890
|
+
.option(
|
|
891
|
+
'--install-disk [device]',
|
|
892
|
+
'Explicit target install disk for Rocky deployment (e.g. /dev/nvme0n1). Omit or leave empty to auto-detect the internal disk.',
|
|
893
|
+
)
|
|
894
|
+
.option(
|
|
895
|
+
'--no-auto-install',
|
|
896
|
+
'Disables the ephemeral runtime AUTO_INSTALL fallback (controller must trigger install).',
|
|
897
|
+
)
|
|
898
|
+
.option('--no-remote-install', 'Skips the controller-side remote install orchestration over SSH.')
|
|
899
|
+
.option(
|
|
900
|
+
'--worker',
|
|
901
|
+
'Post-install infra role: join the deployed node as a Kubernetes worker (requires --control <ip>). Without this flag the node is set up as a control-plane.',
|
|
902
|
+
)
|
|
903
|
+
.option('--control <ip>', 'Control-plane IP the worker node joins (used with --worker for kubeadm infra setup).')
|
|
904
|
+
.option(
|
|
905
|
+
'--ssh-key-dir <dir>',
|
|
906
|
+
'Directory holding the SSH key pair used for commissioning/orchestration (expects <dir>/id_rsa and <dir>/id_rsa.pub). Overrides the workflow "sshKeyDir"; defaults to engine-private/deploy. Supports a leading ~.',
|
|
907
|
+
)
|
|
908
|
+
.option(
|
|
909
|
+
'--deploy-id <deploy-id>',
|
|
910
|
+
'Deployment ID whose user key pair is used for SSH (key from engine-private/conf/<deploy-id>/users/<user>/id_rsa). Same user↔deployId↔key convention as the ssh command.',
|
|
911
|
+
)
|
|
912
|
+
.option(
|
|
913
|
+
'--user <user>',
|
|
914
|
+
'SSH user paired with --deploy-id for key resolution and the login user on an existing control-plane (defaults to root). Mirrors the ssh command --user.',
|
|
915
|
+
)
|
|
916
|
+
.option(
|
|
917
|
+
'--engine-repo <url>',
|
|
918
|
+
'Custom engine repo cloned + normalized to /home/dd/engine on the node (default: <GITHUB_USERNAME>/engine).',
|
|
919
|
+
)
|
|
920
|
+
.option('--engine-branch <branch>', 'Branch of the engine repo to clone on the node.')
|
|
921
|
+
.option(
|
|
922
|
+
'--engine-private-repo <url>',
|
|
923
|
+
'Custom private repo cloned + normalized to /home/dd/engine/engine-private on the node (default: <GITHUB_USERNAME>/engine-<id>-private).',
|
|
924
|
+
)
|
|
925
|
+
.option('--engine-private-branch <branch>', 'Branch of the engine-private repo to clone on the node.')
|
|
859
926
|
.option(
|
|
860
927
|
'--bootstrap-http-server-run',
|
|
861
928
|
'Runs a temporary bootstrap HTTP server for generic purposes such as serving iPXE scripts or ISO images during commissioning.',
|
|
@@ -896,6 +963,14 @@ program
|
|
|
896
963
|
)
|
|
897
964
|
.option('--dev', 'Sets the development context environment for baremetal operations.')
|
|
898
965
|
.option('--ls', 'Lists available boot resources and machines.')
|
|
966
|
+
.option(
|
|
967
|
+
'--resume-infra-setup',
|
|
968
|
+
'Skip commissioning, OS install, and all bootstrapping; resume only the SSH-based infra setup (kubeadm join/init) on a node that already has the OS installed and is reachable via SSH.',
|
|
969
|
+
)
|
|
970
|
+
.option(
|
|
971
|
+
'--resume-join',
|
|
972
|
+
'Skip everything except the kubeadm join command. Assumes engine, Node.js, CRI-O, kubelet, and kubeadm are already installed. Only retrieves a fresh join token from the control-plane and runs kubeadm join.',
|
|
973
|
+
)
|
|
899
974
|
.description(
|
|
900
975
|
'Manages baremetal server operations, including installation, database setup, commissioning, and user management.',
|
|
901
976
|
)
|
package/src/cli/kickstart.js
CHANGED
|
@@ -43,46 +43,168 @@ class UnderpostKickStart {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* @method kickstartPreVariables
|
|
46
|
-
* @description Generates the variable
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
46
|
+
* @description Generates the shell variable-assignment block injected at the top of the
|
|
47
|
+
* kickstart `%pre` script. These variables drive both the ephemeral commissioning runtime
|
|
48
|
+
* and the unattended disk installer in `scripts/rocky-kickstart.sh`. Passwords are emitted
|
|
49
|
+
* base64-encoded (`*_B64`) and decoded by an in-script `ks_b64d` helper; all other values
|
|
50
|
+
* are single-quote escaped so arbitrary content survives the shell/heredoc layers.
|
|
51
|
+
* @param {object} options - Variable values to bake into the `%pre` block.
|
|
52
|
+
* @param {string} [options.rootPassword=''] - root console password (base64-encoded).
|
|
53
|
+
* @param {string} [options.authorizedKeys=''] - SSH public key(s) installed as authorized_keys.
|
|
54
|
+
* @param {string} [options.adminUsername=''] - Primary (MAAS) admin user (defaults to MAAS_ADMIN_USERNAME).
|
|
55
|
+
* @param {string} [options.adminPassword=''] - Primary admin console password (defaults to rootPassword).
|
|
56
|
+
* @param {string} [options.deployUsername=''] - Optional second (deploy) admin user (e.g. admin).
|
|
57
|
+
* @param {string} [options.deployPassword=''] - Deploy user console password (defaults to rootPassword).
|
|
58
|
+
* @param {string} [options.netIp=''] - Static IPv4 for the deployed OS; empty = DHCP.
|
|
59
|
+
* @param {number} [options.netPrefix=24] - IPv4 prefix length for the static address.
|
|
60
|
+
* @param {string} [options.netGateway=''] - Default gateway for the deployed OS.
|
|
61
|
+
* @param {string} [options.netDns=''] - DNS server for the deployed OS.
|
|
62
|
+
* @param {string} [options.timezone=''] - IANA timezone configured in the deployed OS (e.g. America/Santiago).
|
|
63
|
+
* @param {string} [options.keyboardLayout=''] - Console/X11 keyboard layout for the deployed OS (e.g. es).
|
|
64
|
+
* @param {string} [options.chronyConfPath='/etc/chrony.conf'] - chrony config path written in the deployed OS.
|
|
65
|
+
* @param {string} [options.bootstrapUrl=''] - Base URL of the bootstrap HTTP server for this host (status POSTs).
|
|
66
|
+
* @param {string} [options.workflowId=''] - Workflow identifier reported in status metadata.
|
|
67
|
+
* @param {string} [options.systemId=''] - MAAS system id reported in status metadata (if known).
|
|
68
|
+
* @param {string} [options.targetHostname=''] - Hostname reported in status metadata and set on the deployed OS.
|
|
69
|
+
* @param {number} [options.sshPort=22] - SSH port the ephemeral runtime listens on.
|
|
70
|
+
* @param {string} [options.installDiskHint=''] - Optional explicit target disk (e.g. /dev/nvme0n1); empty = auto-detect.
|
|
71
|
+
* @param {boolean} [options.autoInstall=true] - When true, the ephemeral runtime self-installs after a fallback timeout if no remote trigger arrives.
|
|
51
72
|
* @memberof UnderpostKickStart
|
|
52
|
-
* @returns {string}
|
|
73
|
+
* @returns {string} Newline-joined bash variable assignments.
|
|
53
74
|
*/
|
|
54
|
-
kickstartPreVariables: ({
|
|
75
|
+
kickstartPreVariables: ({
|
|
76
|
+
rootPassword = '',
|
|
77
|
+
authorizedKeys = '',
|
|
78
|
+
adminUsername = '',
|
|
79
|
+
adminPassword = '',
|
|
80
|
+
deployUsername = '',
|
|
81
|
+
deployPassword = '',
|
|
82
|
+
netIp = '',
|
|
83
|
+
netPrefix = 24,
|
|
84
|
+
netGateway = '',
|
|
85
|
+
netDns = '',
|
|
86
|
+
timezone = '',
|
|
87
|
+
keyboardLayout = '',
|
|
88
|
+
chronyConfPath = '/etc/chrony.conf',
|
|
89
|
+
bootstrapUrl = '',
|
|
90
|
+
workflowId = '',
|
|
91
|
+
systemId = '',
|
|
92
|
+
targetHostname = '',
|
|
93
|
+
sshPort = 22,
|
|
94
|
+
installDiskHint = '',
|
|
95
|
+
autoInstall = true,
|
|
96
|
+
}) => {
|
|
55
97
|
const sanitizedKeys = (authorizedKeys || '').trim();
|
|
98
|
+
// Passwords are passed base64-encoded so arbitrary characters (quotes,
|
|
99
|
+
// spaces, $, etc.) survive every shell/heredoc layer intact. base64 output
|
|
100
|
+
// never contains single quotes. Decoding tries `base64` then falls back to
|
|
101
|
+
// python3 so a minimal Anaconda environment can never yield empty passwords.
|
|
102
|
+
const b64 = (v) => Buffer.from(String(v || ''), 'utf8').toString('base64');
|
|
103
|
+
const sq = (v) => `'${String(v || '').replace(/'/g, "'\\''")}'`;
|
|
56
104
|
return [
|
|
57
|
-
`
|
|
58
|
-
`
|
|
59
|
-
`
|
|
105
|
+
`ks_b64d() { printf %s "$1" | base64 -d 2>/dev/null || printf %s "$1" | python3 -c 'import sys,base64;sys.stdout.buffer.write(base64.b64decode(sys.stdin.read().strip()))' 2>/dev/null; }`,
|
|
106
|
+
`ROOT_PASS_B64='${b64(rootPassword)}'`,
|
|
107
|
+
`ADMIN_PASS_B64='${b64(adminPassword || rootPassword)}'`,
|
|
108
|
+
`DEPLOY_PASS_B64='${b64(deployPassword)}'`,
|
|
109
|
+
`ROOT_PASS="$(ks_b64d "$ROOT_PASS_B64")"`,
|
|
110
|
+
`ADMIN_PASS="$(ks_b64d "$ADMIN_PASS_B64")"`,
|
|
111
|
+
`DEPLOY_PASS="$(ks_b64d "$DEPLOY_PASS_B64")"`,
|
|
112
|
+
`AUTHORIZED_KEYS=${sq(sanitizedKeys)}`,
|
|
113
|
+
`ADMIN_USER=${sq(adminUsername || process.env.MAAS_ADMIN_USERNAME || 'maas')}`,
|
|
114
|
+
`DEPLOY_USER=${sq(deployUsername)}`,
|
|
115
|
+
`NET_IP=${sq(netIp)}`,
|
|
116
|
+
`NET_PREFIX='${parseInt(netPrefix, 10) || 24}'`,
|
|
117
|
+
`NET_GATEWAY=${sq(netGateway)}`,
|
|
118
|
+
`NET_DNS=${sq(netDns)}`,
|
|
119
|
+
`TIMEZONE=${sq(timezone)}`,
|
|
120
|
+
`KEYBOARD_LAYOUT=${sq(keyboardLayout)}`,
|
|
121
|
+
`CHRONY_CONF_PATH=${sq(chronyConfPath || '/etc/chrony.conf')}`,
|
|
122
|
+
`BOOTSTRAP_URL=${sq(bootstrapUrl)}`,
|
|
123
|
+
`WORKFLOW_ID=${sq(workflowId)}`,
|
|
124
|
+
`SYSTEM_ID=${sq(systemId)}`,
|
|
125
|
+
`TARGET_HOSTNAME=${sq(targetHostname)}`,
|
|
126
|
+
`SSH_PORT='${sshPort || 22}'`,
|
|
127
|
+
`INSTALL_DISK_HINT=${sq(installDiskHint)}`,
|
|
128
|
+
`AUTO_INSTALL='${autoInstall ? '1' : '0'}'`,
|
|
60
129
|
].join('\n');
|
|
61
130
|
},
|
|
62
131
|
|
|
63
132
|
/**
|
|
64
133
|
* @method kickstartFactory
|
|
65
134
|
* @description Generates a complete kickstart configuration by combining the header,
|
|
66
|
-
* variable
|
|
67
|
-
* @param {object} options
|
|
68
|
-
* @param {string} [options.lang='en_US.UTF-8']
|
|
69
|
-
* @param {string} [options.keyboard='us']
|
|
70
|
-
* @param {string} [options.timezone='America/New_York']
|
|
71
|
-
* @param {string} [options.
|
|
72
|
-
* @param {string} [options.
|
|
135
|
+
* the `%pre` variable-assignment block, and the `scripts/rocky-kickstart.sh` body.
|
|
136
|
+
* @param {object} options - Kickstart generation options.
|
|
137
|
+
* @param {string} [options.lang='en_US.UTF-8'] - System language for the ephemeral runtime.
|
|
138
|
+
* @param {string} [options.keyboard='us'] - Keyboard layout for the ephemeral runtime AND the deployed OS.
|
|
139
|
+
* @param {string} [options.timezone='America/New_York'] - Timezone for the ephemeral runtime AND the deployed OS.
|
|
140
|
+
* @param {string} [options.chronyConfPath='/etc/chrony.conf'] - chrony config path written in the deployed OS.
|
|
141
|
+
* @param {string} [options.rootPassword=process.env.MAAS_ADMIN_PASS] - root console password.
|
|
142
|
+
* @param {string} [options.adminUsername=''] - Primary (MAAS) admin user created in the deployed OS.
|
|
143
|
+
* @param {string} [options.adminPassword=''] - Primary admin console password (defaults to rootPassword).
|
|
144
|
+
* @param {string} [options.deployUsername=''] - Optional second (deploy) admin user (e.g. admin).
|
|
145
|
+
* @param {string} [options.deployPassword=''] - Deploy user console password (defaults to rootPassword).
|
|
146
|
+
* @param {string} [options.netIp=''] - Static IPv4 for the deployed OS; empty = DHCP.
|
|
147
|
+
* @param {number} [options.netPrefix=24] - IPv4 prefix length for the static address.
|
|
148
|
+
* @param {string} [options.netGateway=''] - Default gateway for the deployed OS.
|
|
149
|
+
* @param {string} [options.netDns=''] - DNS server for the deployed OS.
|
|
150
|
+
* @param {string} [options.authorizedKeys=''] - SSH public key(s) installed as authorized_keys.
|
|
151
|
+
* @param {string} [options.bootstrapUrl=''] - Base URL of the bootstrap HTTP server (status POSTs).
|
|
152
|
+
* @param {string} [options.workflowId=''] - Workflow identifier reported in status metadata.
|
|
153
|
+
* @param {string} [options.systemId=''] - MAAS system id reported in status metadata (if known).
|
|
154
|
+
* @param {string} [options.targetHostname=''] - Hostname reported in status metadata and set on the deployed OS.
|
|
155
|
+
* @param {number} [options.sshPort=22] - SSH port the ephemeral runtime listens on.
|
|
156
|
+
* @param {string} [options.installDiskHint=''] - Optional explicit target disk; empty = auto-detect.
|
|
157
|
+
* @param {boolean} [options.autoInstall=true] - When true, the runtime self-installs after a fallback timeout.
|
|
73
158
|
* @memberof UnderpostKickStart
|
|
74
|
-
* @returns {string}
|
|
159
|
+
* @returns {string} The full kickstart (ks.cfg) source.
|
|
75
160
|
*/
|
|
76
161
|
kickstartFactory: ({
|
|
77
162
|
lang = 'en_US.UTF-8',
|
|
78
163
|
keyboard = 'us',
|
|
79
164
|
timezone = 'America/New_York',
|
|
165
|
+
chronyConfPath = '/etc/chrony.conf',
|
|
80
166
|
rootPassword = process.env.MAAS_ADMIN_PASS,
|
|
167
|
+
adminUsername = '',
|
|
168
|
+
adminPassword = '',
|
|
169
|
+
deployUsername = '',
|
|
170
|
+
deployPassword = '',
|
|
171
|
+
netIp = '',
|
|
172
|
+
netPrefix = 24,
|
|
173
|
+
netGateway = '',
|
|
174
|
+
netDns = '',
|
|
81
175
|
authorizedKeys = '',
|
|
176
|
+
bootstrapUrl = '',
|
|
177
|
+
workflowId = '',
|
|
178
|
+
systemId = '',
|
|
179
|
+
targetHostname = '',
|
|
180
|
+
sshPort = 22,
|
|
181
|
+
installDiskHint = '',
|
|
182
|
+
autoInstall = true,
|
|
82
183
|
}) => {
|
|
83
|
-
const
|
|
184
|
+
const resolvedAdminUsername = adminUsername || process.env.MAAS_ADMIN_USERNAME || 'maas';
|
|
84
185
|
const header = UnderpostKickStart.API.kickstartHeader({ lang, keyboard, timezone, rootPassword });
|
|
85
|
-
const variables = UnderpostKickStart.API.kickstartPreVariables({
|
|
186
|
+
const variables = UnderpostKickStart.API.kickstartPreVariables({
|
|
187
|
+
rootPassword,
|
|
188
|
+
authorizedKeys,
|
|
189
|
+
adminUsername: resolvedAdminUsername,
|
|
190
|
+
adminPassword,
|
|
191
|
+
deployUsername,
|
|
192
|
+
deployPassword,
|
|
193
|
+
netIp,
|
|
194
|
+
netPrefix,
|
|
195
|
+
netGateway,
|
|
196
|
+
netDns,
|
|
197
|
+
timezone,
|
|
198
|
+
keyboardLayout: keyboard,
|
|
199
|
+
chronyConfPath,
|
|
200
|
+
bootstrapUrl,
|
|
201
|
+
workflowId,
|
|
202
|
+
systemId,
|
|
203
|
+
targetHostname,
|
|
204
|
+
sshPort,
|
|
205
|
+
installDiskHint,
|
|
206
|
+
autoInstall,
|
|
207
|
+
});
|
|
86
208
|
|
|
87
209
|
const scriptPath = path.resolve(__dirname, '../../scripts/rocky-kickstart.sh');
|
|
88
210
|
const scriptBody = fs.readFileSync(scriptPath, 'utf8');
|
package/src/cli/repository.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
buildReplicaId,
|
|
23
23
|
writeEnv,
|
|
24
24
|
} from '../server/conf.js';
|
|
25
|
-
import { buildClient, unzipClientBuild, mergeClientBuildZip } from '../
|
|
25
|
+
import { buildClient, unzipClientBuild, mergeClientBuildZip } from '../client-builder/client-build.js';
|
|
26
26
|
import { DefaultConf } from '../../conf.js';
|
|
27
27
|
import Underpost from '../index.js';
|
|
28
28
|
|
|
@@ -1483,18 +1483,63 @@ Prevent build private config repo.`,
|
|
|
1483
1483
|
},
|
|
1484
1484
|
|
|
1485
1485
|
/**
|
|
1486
|
-
*
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1486
|
+
* Resolves the in-pod site-root directory where a conf route's repository lives.
|
|
1487
|
+
*
|
|
1488
|
+
* General-purpose resolution, independent of any single runtime:
|
|
1489
|
+
* 1. An explicit `directory` (the conf-declared document root) always wins.
|
|
1490
|
+
* 2. Otherwise the runtime's base directory is used (e.g. `wp` → `/opt/lampp/htdocs/wp/<host>`).
|
|
1491
|
+
* 3. A subdirectory route (e.g. `/wp`) appends `<subDir>` to the resolved root.
|
|
1492
|
+
*
|
|
1493
|
+
* This mirrors {@link WpService.createApp}'s `vhostDir`/`wpDir` layout so backups target the
|
|
1494
|
+
* exact directory provisioning created, including subdirectory installs and custom directories.
|
|
1495
|
+
*
|
|
1496
|
+
* @param {object} opts
|
|
1497
|
+
* @param {string} opts.runtime - The runtime identifier (e.g. 'wp').
|
|
1498
|
+
* @param {string} opts.host - The virtual-host name.
|
|
1499
|
+
* @param {string} [opts.routePath='/'] - The conf route path the repository is mounted under.
|
|
1500
|
+
* @param {string} [opts.directory] - Explicit document root from conf; overrides the runtime base.
|
|
1501
|
+
* @returns {string|null} Absolute path inside the pod, or null when neither a directory nor a
|
|
1502
|
+
* known runtime base resolves.
|
|
1491
1503
|
* @memberof UnderpostRepository
|
|
1492
1504
|
*/
|
|
1493
|
-
runtimeSiteRoot(runtime, host) {
|
|
1494
|
-
const
|
|
1505
|
+
runtimeSiteRoot({ runtime, host, routePath = '/', directory } = {}) {
|
|
1506
|
+
const runtimeBase = {
|
|
1495
1507
|
wp: `/opt/lampp/htdocs/wp/${host}`,
|
|
1496
1508
|
};
|
|
1497
|
-
|
|
1509
|
+
const vhostDir = directory || runtimeBase[runtime];
|
|
1510
|
+
if (!vhostDir) return null;
|
|
1511
|
+
const subDir = routePath && routePath !== '/' ? routePath.replace(/^\/+/, '').replace(/\/+$/, '') : '';
|
|
1512
|
+
return subDir ? `${vhostDir}/${subDir}` : vhostDir;
|
|
1513
|
+
},
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Probes a running pod for the first candidate directory that is a git repository
|
|
1517
|
+
* (i.e. contains a `.git` entry). Used to locate a site root before backing it up so a
|
|
1518
|
+
* missing/unprovisioned directory is detected up-front instead of producing an opaque
|
|
1519
|
+
* shell `exit 1` from a failed `cd`.
|
|
1520
|
+
*
|
|
1521
|
+
* @param {object} opts
|
|
1522
|
+
* @param {string} opts.podName - Target pod name.
|
|
1523
|
+
* @param {string} opts.namespace - Kubernetes namespace.
|
|
1524
|
+
* @param {string[]} opts.candidates - Absolute paths to probe, most-specific first.
|
|
1525
|
+
* @returns {string|null} The first candidate that is a git repo, or null if none match.
|
|
1526
|
+
* @memberof UnderpostRepository
|
|
1527
|
+
*/
|
|
1528
|
+
podRepoDir({ podName, namespace, candidates }) {
|
|
1529
|
+
const probe = candidates.map((dir) => `if [ -d '${dir}/.git' ]; then echo '${dir}'; exit 0; fi`).join('; ');
|
|
1530
|
+
let out = '';
|
|
1531
|
+
try {
|
|
1532
|
+
out = Underpost.kubectl.exec({ podName, namespace, command: `${probe}; echo ''` }) || '';
|
|
1533
|
+
} catch (err) {
|
|
1534
|
+
logger.warn(`podRepoDir: probe failed in pod ${podName}`, err.message);
|
|
1535
|
+
return null;
|
|
1536
|
+
}
|
|
1537
|
+
return (
|
|
1538
|
+
out
|
|
1539
|
+
.split('\n')
|
|
1540
|
+
.map((line) => line.trim())
|
|
1541
|
+
.find(Boolean) || null
|
|
1542
|
+
);
|
|
1498
1543
|
},
|
|
1499
1544
|
|
|
1500
1545
|
/**
|
|
@@ -1543,12 +1588,28 @@ Prevent build private config repo.`,
|
|
|
1543
1588
|
const entry = confServer[host][routePath];
|
|
1544
1589
|
if (!entry.repository) continue;
|
|
1545
1590
|
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1591
|
+
const siteRootArgs = { runtime: entry.runtime, host, directory: entry.directory };
|
|
1592
|
+
const repoRoot = Underpost.repo.runtimeSiteRoot({ ...siteRootArgs, routePath });
|
|
1593
|
+
if (!repoRoot) {
|
|
1548
1594
|
logger.warn(`backupPodRepositories: no site-root mapping for runtime '${entry.runtime}' (${host})`);
|
|
1549
1595
|
continue;
|
|
1550
1596
|
}
|
|
1551
1597
|
|
|
1598
|
+
// Probe the pod for the actual git repo so an unprovisioned/missing site root is
|
|
1599
|
+
// detected and skipped cleanly instead of failing the in-pod `cd` with exit 1.
|
|
1600
|
+
// Fall back to the vhost dir (root route) to cover conf/path drift.
|
|
1601
|
+
const vhostRoot = Underpost.repo.runtimeSiteRoot({ ...siteRootArgs, routePath: '/' });
|
|
1602
|
+
const candidates = [...new Set([repoRoot, vhostRoot].filter(Boolean))];
|
|
1603
|
+
const siteRoot = Underpost.repo.podRepoDir({ podName, namespace, candidates });
|
|
1604
|
+
if (!siteRoot) {
|
|
1605
|
+
logger.warn(
|
|
1606
|
+
`backupPodRepositories: no git repository found in pod ${podName} for ${host} (checked ${candidates.join(
|
|
1607
|
+
', ',
|
|
1608
|
+
)}) — site may not be provisioned yet; skipping`,
|
|
1609
|
+
);
|
|
1610
|
+
continue;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1552
1613
|
const repoName = entry.repository.split('/').pop().split('.')[0];
|
|
1553
1614
|
|
|
1554
1615
|
// Build the backup script — secrets are injected as env vars in the exec,
|