underpost 2.8.817 → 2.8.821
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 +2 -2
- package/bin/deploy.js +2 -1252
- package/cli.md +24 -16
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
- package/manifests/maas/device-scan.sh +43 -0
- package/manifests/maas/maas-setup.sh +81 -26
- package/manifests/maas/nat-iptables.sh +26 -0
- package/package.json +1 -1
- package/src/cli/baremetal.js +1233 -46
- package/src/cli/cloud-init.js +537 -0
- package/src/cli/index.js +15 -10
- package/src/index.js +26 -16
- package/src/server/runtime.js +0 -5
- package/src/server/ssl.js +1 -12
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.821
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -29,7 +29,7 @@ Commands:
|
|
|
29
29
|
test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
|
|
30
30
|
monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
|
|
31
31
|
lxd [options] Manages LXD containers and virtual machines.
|
|
32
|
-
baremetal [options]
|
|
32
|
+
baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
|
|
33
33
|
help [command] display help for command
|
|
34
34
|
|
|
35
35
|
```
|
|
@@ -592,29 +592,37 @@ Options:
|
|
|
592
592
|
|
|
593
593
|
### `baremetal` :
|
|
594
594
|
```
|
|
595
|
-
Usage: underpost baremetal [options]
|
|
595
|
+
Usage: underpost baremetal [options] [workflow-id] [hostname] [ip-address]
|
|
596
596
|
|
|
597
597
|
Manages baremetal server operations, including installation, database setup,
|
|
598
|
-
and user management.
|
|
598
|
+
commissioning, and user management.
|
|
599
599
|
|
|
600
600
|
Options:
|
|
601
601
|
--control-server-install Installs the baremetal control server.
|
|
602
|
-
--control-server-
|
|
603
|
-
|
|
602
|
+
--control-server-uninstall Uninstalls the baremetal control server.
|
|
603
|
+
--control-server-db-install Installs up the database for the baremetal
|
|
604
|
+
control server.
|
|
604
605
|
--control-server-db-uninstall Uninstalls the database for the baremetal
|
|
605
606
|
control server.
|
|
606
|
-
--
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
--
|
|
611
|
-
|
|
612
|
-
--
|
|
613
|
-
|
|
614
|
-
--
|
|
615
|
-
|
|
607
|
+
--commission Init workflow for commissioning a physical
|
|
608
|
+
machine.
|
|
609
|
+
--nfs-build Builds an NFS root filesystem for a workflow
|
|
610
|
+
id config architecture using QEMU emulation.
|
|
611
|
+
--nfs-mount Mounts the NFS root filesystem for a workflow
|
|
612
|
+
id config architecture.
|
|
613
|
+
--nfs-unmount Unmounts the NFS root filesystem for a
|
|
614
|
+
workflow id config architecture.
|
|
615
|
+
--nfs-sh Copies QEMU emulation root entrypoint shell
|
|
616
|
+
command to the clipboard.
|
|
617
|
+
--cloud-init-update Updates cloud init for a workflow id config
|
|
618
|
+
architecture.
|
|
619
|
+
--cloud-init-reset Resets cloud init for a workflow id config
|
|
620
|
+
architecture.
|
|
621
|
+
--logs <log-id> Displays logs for log id: dhcp, cloud,
|
|
622
|
+
machine, cloud-config.
|
|
616
623
|
--dev Sets the development context environment for
|
|
617
624
|
baremetal operations.
|
|
625
|
+
--ls Lists available boot resources and machines.
|
|
618
626
|
-h, --help display help for command
|
|
619
627
|
|
|
620
628
|
```
|
package/docker-compose.yml
CHANGED
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-template-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.821
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-template-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.821
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
for iface_path in /sys/class/net/*; do
|
|
4
|
+
name=$(basename "$iface_path")
|
|
5
|
+
mac=$(< "$iface_path/address")
|
|
6
|
+
ip=$(ip -4 addr show dev "$name" \
|
|
7
|
+
| grep -oP '(?<=inet\s)\d+(\.\d+){3}' || echo "—")
|
|
8
|
+
operstate=$(< "$iface_path/operstate")
|
|
9
|
+
mtu=$(< "$iface_path/mtu")
|
|
10
|
+
|
|
11
|
+
# Driver: módulo kernel que maneja esta interfaz
|
|
12
|
+
if [ -L "$iface_path/device/driver" ]; then
|
|
13
|
+
driver=$(basename "$(readlink -f "$iface_path/device/driver")")
|
|
14
|
+
else
|
|
15
|
+
driver="—"
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# Vendor:Device ID PCI
|
|
19
|
+
pci_dev="$iface_path/device"
|
|
20
|
+
if [ -f "$pci_dev/vendor" ] && [ -f "$pci_dev/device" ]; then
|
|
21
|
+
vendor_id=$(< "$pci_dev/vendor")
|
|
22
|
+
device_id=$(< "$pci_dev/device")
|
|
23
|
+
# pasamos de 0x8086 a 8086, etc.
|
|
24
|
+
vendor_id=${vendor_id#0x}
|
|
25
|
+
device_id=${device_id#0x}
|
|
26
|
+
pci="${vendor_id}:${device_id}"
|
|
27
|
+
else
|
|
28
|
+
pci="—"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Link Speed: lectura directa de /sys/class/net/<iface>/speed
|
|
32
|
+
speed=$(cat "$iface_path/speed" 2>/dev/null || echo "—")
|
|
33
|
+
|
|
34
|
+
echo "Interface: $name"
|
|
35
|
+
echo " MAC: $mac"
|
|
36
|
+
echo " IPv4: $ip"
|
|
37
|
+
echo " State: $operstate"
|
|
38
|
+
echo " MTU: $mtu"
|
|
39
|
+
echo " Driver: $driver"
|
|
40
|
+
echo " PCI Vendor:Device ID: $pci"
|
|
41
|
+
echo " Link Speed: ${speed}Mb/s"
|
|
42
|
+
echo
|
|
43
|
+
done
|
|
@@ -1,39 +1,23 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
|
+
# Install jq for JSON parsing
|
|
4
5
|
sudo snap install jq
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
# Install MAAS
|
|
6
8
|
sudo snap install maas
|
|
7
9
|
|
|
8
10
|
# Get default interface and IP address
|
|
9
11
|
INTERFACE=$(ip route | grep default | awk '{print $5}')
|
|
10
12
|
IP_ADDRESS=$(ip -4 addr show dev "$INTERFACE" | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
|
|
11
13
|
|
|
12
|
-
#
|
|
13
|
-
sudo systemctl disable --now iptables
|
|
14
|
-
sudo systemctl disable --now ufw
|
|
15
|
-
sudo systemctl disable --now firewalld
|
|
16
|
-
|
|
17
|
-
# Enable IP forwarding and configure NAT
|
|
18
|
-
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
|
|
19
|
-
echo "net.ipv6.conf.all.forwarding = 1" | sudo tee -a /etc/sysctl.conf
|
|
20
|
-
sudo sysctl -p
|
|
21
|
-
|
|
22
|
-
# Accept all traffic
|
|
23
|
-
sudo iptables -P INPUT ACCEPT
|
|
24
|
-
sudo iptables -P FORWARD ACCEPT
|
|
25
|
-
sudo iptables -P OUTPUT ACCEPT
|
|
26
|
-
|
|
27
|
-
# List iptables rules
|
|
28
|
-
sudo iptables -L -n
|
|
29
|
-
sysctl net.ipv4.ip_forward
|
|
30
|
-
|
|
14
|
+
# Change to the engine directory (assuming this is where your MAAS related configs are)
|
|
31
15
|
cd /home/dd/engine
|
|
32
16
|
|
|
33
|
-
# Load secrets
|
|
17
|
+
# Load secrets for MAAS database and admin credentials
|
|
34
18
|
underpost secret underpost --create-from-file /home/dd/engine/engine-private/conf/dd-cron/.env.production
|
|
35
19
|
|
|
36
|
-
# Extract
|
|
20
|
+
# Extract configuration values from secrets
|
|
37
21
|
DB_PG_MAAS_USER=$(node bin config get --plain DB_PG_MAAS_USER)
|
|
38
22
|
DB_PG_MAAS_PASS=$(node bin config get --plain DB_PG_MAAS_PASS)
|
|
39
23
|
DB_PG_MAAS_HOST=$(node bin config get --plain DB_PG_MAAS_HOST)
|
|
@@ -43,23 +27,94 @@ MAAS_ADMIN_USERNAME=$(node bin config get --plain MAAS_ADMIN_USERNAME)
|
|
|
43
27
|
MAAS_ADMIN_EMAIL=$(node bin config get --plain MAAS_ADMIN_EMAIL)
|
|
44
28
|
MAAS_ADMIN_PASS=$(node bin config get --plain MAAS_ADMIN_PASS)
|
|
45
29
|
|
|
46
|
-
# Initialize MAAS
|
|
30
|
+
# Initialize MAAS region+rack controller
|
|
47
31
|
maas init region+rack \
|
|
48
32
|
--database-uri "postgres://${DB_PG_MAAS_USER}:${DB_PG_MAAS_PASS}@${DB_PG_MAAS_HOST}/${DB_PG_MAAS_NAME}" \
|
|
49
33
|
--maas-url http://${IP_ADDRESS}:5240/MAAS
|
|
50
34
|
|
|
51
|
-
#
|
|
35
|
+
# Allow MAAS to initialize (wait for services to come up)
|
|
36
|
+
echo "Waiting for MAAS to initialize..."
|
|
52
37
|
sleep 30
|
|
53
38
|
|
|
54
|
-
# Create
|
|
39
|
+
# Create MAAS administrator account
|
|
55
40
|
maas createadmin \
|
|
56
41
|
--username "$MAAS_ADMIN_USERNAME" \
|
|
57
42
|
--password "$MAAS_ADMIN_PASS" \
|
|
58
43
|
--email "$MAAS_ADMIN_EMAIL"
|
|
59
44
|
|
|
45
|
+
# Get the API key for the admin user
|
|
60
46
|
APIKEY=$(maas apikey --username "$MAAS_ADMIN_USERNAME")
|
|
61
47
|
|
|
62
|
-
# Login to MAAS
|
|
48
|
+
# Login to MAAS using the admin profile
|
|
49
|
+
echo "Logging into MAAS..."
|
|
63
50
|
maas login "$MAAS_ADMIN_USERNAME" "http://localhost:5240/MAAS/" "$APIKEY"
|
|
64
51
|
|
|
52
|
+
# Set upstream DNS for MAAS
|
|
53
|
+
echo "Setting upstream DNS to 8.8.8.8..."
|
|
65
54
|
maas "$MAAS_ADMIN_USERNAME" maas set-config name=upstream_dns value=8.8.8.8
|
|
55
|
+
|
|
56
|
+
# echo "Downloading Ubuntu Noble amd64/ga-24.04 image..."
|
|
57
|
+
# maas $MAAS_ADMIN_USERNAME boot-source-selections create 1 \
|
|
58
|
+
# os="ubuntu" release="noble" arches="amd64" \
|
|
59
|
+
# subarches="ga-24.04" labels="*"
|
|
60
|
+
|
|
61
|
+
echo "Downloading Ubuntu Noble arm64/ga-24.04 image..."
|
|
62
|
+
maas $MAAS_ADMIN_USERNAME boot-source-selections create 1 \
|
|
63
|
+
os="ubuntu" release="noble" arches="arm64" \
|
|
64
|
+
subarches="ga-24.04" labels="*"
|
|
65
|
+
|
|
66
|
+
# Import the newly selected boot images
|
|
67
|
+
echo "Importing boot images (this may take some time)..."
|
|
68
|
+
maas "$MAAS_ADMIN_USERNAME" boot-resources import
|
|
69
|
+
|
|
70
|
+
# Disable the MAAS HTTP proxy
|
|
71
|
+
echo "Disabling MAAS HTTP proxy..."
|
|
72
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=enable_http_proxy value=false
|
|
73
|
+
|
|
74
|
+
# Disable DNSSEC validation
|
|
75
|
+
echo "Disabling DNSSEC validation..."
|
|
76
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=dnssec_validation value=no
|
|
77
|
+
|
|
78
|
+
# Set network discovery interval to 10 minutes (600 seconds)
|
|
79
|
+
echo "Setting network discovery interval to 10 minutes..."
|
|
80
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=active_discovery_interval value=600
|
|
81
|
+
|
|
82
|
+
SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
|
|
83
|
+
maas $MAAS_ADMIN_USERNAME sshkeys create "key=$SSH_KEY"
|
|
84
|
+
|
|
85
|
+
echo "MAAS setup script completed with new configurations."
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=default_storage_layout value=lvm
|
|
89
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=network_discovery value=disabled
|
|
90
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=enable_analytics value=false
|
|
91
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=enable_third_party_drivers value=false
|
|
92
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=curtin_verbose value=true
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
echo "Configuring DHCP for fabric-1 (untagged VLAN)..."
|
|
97
|
+
|
|
98
|
+
# Get the FABRIC_ID for "fabric-1"
|
|
99
|
+
SUBNET_CIDR="192.168.1.0/24"
|
|
100
|
+
SUBNET_ID=$(maas "$MAAS_ADMIN_USERNAME" subnets read | jq -r '.[] | select(.cidr == "'"$SUBNET_CIDR"'") | .id')
|
|
101
|
+
FABRIC_ID=$(maas "$MAAS_ADMIN_USERNAME" fabrics read | jq -r '.[] | select(.name == "fabric-1") | .id')
|
|
102
|
+
RACK_CONTROLLER_ID=$(maas "$MAAS_ADMIN_USERNAME" rack-controllers read | jq -r '.[] | select(.ip_addresses[] == "'"$IP_ADDRESS"'") | .system_id')
|
|
103
|
+
START_IP="192.168.1.191"
|
|
104
|
+
END_IP="192.168.1.254"
|
|
105
|
+
|
|
106
|
+
if [ -z "$FABRIC_ID" ]; then
|
|
107
|
+
echo "Error: Could not find FABRIC_ID for 'fabric-1'. Please ensure 'fabric-1' exists in MAAS."
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Enable DHCP on the untagged VLAN (VLAN tag 0)
|
|
112
|
+
echo "Enabling DHCP on VLAN 0 for fabric-1 (ID: $FABRIC_ID)..."
|
|
113
|
+
maas "$MAAS_ADMIN_USERNAME" vlan update "$FABRIC_ID" 0 dhcp_on=true primary_rack="$RACK_CONTROLLER_ID"
|
|
114
|
+
|
|
115
|
+
# Create a Dynamic IP Range for enlistment, commissioning, and deployment
|
|
116
|
+
echo "Creating dynamic IP range from $START_IP to $END_IP..."
|
|
117
|
+
maas "$MAAS_ADMIN_USERNAME" ipranges create type=dynamic start_ip="$START_IP" end_ip="$END_IP"
|
|
118
|
+
|
|
119
|
+
echo "Setting gateway IP for subnet $SUBNET_CIDR (ID: $SUBNET_ID) to $IP_ADDRESS..."
|
|
120
|
+
maas "$MAAS_ADMIN_USERNAME" subnet update $SUBNET_ID gateway_ip=$IP_ADDRESS
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Disable firewalld
|
|
5
|
+
sudo systemctl disable --now iptables
|
|
6
|
+
sudo systemctl disable --now ufw
|
|
7
|
+
sudo systemctl disable --now firewalld
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Remove any existing entries, then append exactly one
|
|
11
|
+
sudo sed -i '/^net.ipv4.ip_forward/d' /etc/sysctl.conf
|
|
12
|
+
sudo sed -i '/^net.ipv6.conf.all.forwarding/d' /etc/sysctl.conf
|
|
13
|
+
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
|
|
14
|
+
echo "net.ipv6.conf.all.forwarding = 1" | sudo tee -a /etc/sysctl.conf
|
|
15
|
+
# ---
|
|
16
|
+
|
|
17
|
+
sudo sysctl -p
|
|
18
|
+
|
|
19
|
+
# Accept all traffic
|
|
20
|
+
sudo iptables -P INPUT ACCEPT
|
|
21
|
+
sudo iptables -P FORWARD ACCEPT
|
|
22
|
+
sudo iptables -P OUTPUT ACCEPT
|
|
23
|
+
|
|
24
|
+
# List iptables rules and forwarding flag
|
|
25
|
+
sudo iptables -L -n
|
|
26
|
+
sysctl net.ipv4.ip_forward net.ipv6.conf.all.forwarding
|
package/package.json
CHANGED