feat: add boot staging configuration and automation utility scripts
This commit is contained in:
66
scripts/run_provision_21.py
Normal file
66
scripts/run_provision_21.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import paramiko
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect('140.44.4.21', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=15)
|
||||
|
||||
script = """#!/bin/bash
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
echo "=== 1. Root Filesystem Hardening ==="
|
||||
tune2fs -l /dev/mmcblk0p2 | grep -i "error.*behavior"
|
||||
|
||||
echo "=== 2. Time Synchronization Setup ==="
|
||||
cat << 'EOF' > /etc/systemd/timesyncd.conf
|
||||
[Time]
|
||||
NTP=140.44.4.11 14.4.4.44
|
||||
FallbackNTP=time.cloudflare.com time.google.com 0.us.pool.ntp.org 1.us.pool.ntp.org
|
||||
PollIntervalMinSec=32
|
||||
PollIntervalMaxSec=512
|
||||
EOF
|
||||
systemctl restart systemd-timesyncd.service
|
||||
echo "Timesync status: $(systemctl is-active systemd-timesyncd)"
|
||||
|
||||
echo "=== 3. Zabbix Agent 2 Installation & Configuration ==="
|
||||
apt-get update -y
|
||||
apt-get install -y zabbix-agent2
|
||||
|
||||
mkdir -p /etc/zabbix
|
||||
echo "a1142332ccfa9c53040e36171bb551ceb2865fb4051d203404df39e88ebe94f0" > /etc/zabbix/zabbix_agent2.psk
|
||||
chmod 600 /etc/zabbix/zabbix_agent2.psk
|
||||
chown zabbix:zabbix /etc/zabbix/zabbix_agent2.psk 2>/dev/null || true
|
||||
|
||||
cat << 'EOF' > /etc/zabbix/zabbix_agent2.conf
|
||||
Server=zabbix.snarfnet.net
|
||||
ServerActive=zabbix.snarfnet.net
|
||||
HostnameItem=system.hostname
|
||||
HostMetadata=Linux
|
||||
TLSConnect=psk
|
||||
TLSAccept=psk
|
||||
TLSPSKIdentity=PSK_autoregister
|
||||
TLSPSKFile=/etc/zabbix/zabbix_agent2.psk
|
||||
LogFile=/var/log/zabbix/zabbix_agent2.log
|
||||
LogFileSize=10
|
||||
BufferSend=5
|
||||
BufferSize=100
|
||||
EOF
|
||||
systemctl enable --now zabbix-agent2.service
|
||||
echo "Zabbix-agent2 status: $(systemctl is-active zabbix-agent2)"
|
||||
|
||||
echo "=== 4. K3s Agent Installation (v1.30.6+k3s1) ==="
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.30.6+k3s1 K3S_URL=https://140.44.4.11:6443 K3S_TOKEN=myworstkeptsecret44 sh -
|
||||
|
||||
echo "K3s-agent status: $(systemctl is-active k3s-agent)"
|
||||
echo "=== ALL PROVISIONING TASKS COMPLETE ==="
|
||||
"""
|
||||
|
||||
print("Running provisioning script on sninfr2lnxwrk01...")
|
||||
stdin, stdout, stderr = ssh.exec_command(script, get_pty=True)
|
||||
|
||||
for line in iter(stdout.readline, ""):
|
||||
print(line, end="")
|
||||
|
||||
exit_code = stdout.channel.recv_exit_status()
|
||||
print(f"\nFinished with exit code: {exit_code}")
|
||||
|
||||
ssh.close()
|
||||
Reference in New Issue
Block a user