Skip to content

Commit 7bcf435

Browse files
feat: comprehensive updates for deployment system
Major Features: - Add remote repository setup automation (setup-remote-repo.sh) - Add log tailer service for real-time log monitoring - Implement UID migration to 30000 with automatic handling - Update OXIDIZED_HOME to /var/lib/oxidized with SSH symlinks - Enhanced README.md in repo with GitHub UI and CLI usage guides Scripts & Tools: - setup-remote-repo.sh: Interactive GitHub/GitLab remote configuration - oxidized-log-tailer.sh: Real-time container log streaming - test-device.sh: Add SSH password and Telnet authentication support - uninstall.sh: Enhanced robustness with complete cleanup - deploy.sh: Install sshpass and expect, handle home directory migration Documentation: - Reorganize all docs into docs/ directory - Add CHANGELOG.md tracking all changes - Add UID_MIGRATION_30000.md with migration guide - Add REMOTE_REPOSITORY.md with setup instructions - Enhanced repo README with deployment code references Fixes: - Fix setup-remote-repo.sh to run all git commands as oxidized user - Fix ownership issues in git repository - Fix uninstall.sh to remove logger service and user - Fix test-device.sh password authentication - Add telnet support to test-device.sh Dependencies: - Add sshpass for SSH password authentication - Add expect for Telnet automation
1 parent 3563fb7 commit 7bcf435

24 files changed

Lines changed: 2977 additions & 195 deletions

README.md

Lines changed: 100 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Production-grade deployment framework for running [Oxidized](https://github.com/yggdrasil-network/oxidized)
1010
as a containerized service on RHEL 10/9 using **Podman Quadlets** and **systemd**.
1111

12-
**For Oxidized usage and configuration**, see [README-OXIDIZED.md](README-OXIDIZED.md).
12+
**For Oxidized usage and configuration**, see [docs/README-OXIDIZED.md](docs/README-OXIDIZED.md).
1313

1414
---
1515

@@ -40,7 +40,7 @@ This repository provides automated deployment scripts and configuration template
4040
Oxidized is a network device configuration backup tool that automatically backs up network device
4141
configurations, tracks changes using Git, and supports 130+ device models.
4242

43-
**Full Oxidized documentation**: [README-OXIDIZED.md](README-OXIDIZED.md)
43+
**Full Oxidized documentation**: [docs/README-OXIDIZED.md](docs/README-OXIDIZED.md)
4444

4545
### Why This Repository?
4646

@@ -70,7 +70,7 @@ configurations, tracks changes using Git, and supports 130+ device models.
7070
- **Git versioning**: Every config change tracked automatically
7171
- **CSV inventory**: Simple, colon-delimited device list (`router.db`)
7272
- **Log rotation**: Automated via logrotate
73-
- **Backup procedures**: Scripts and documentation provided
73+
- **Backup procedures**: Local git + optional remote repository (GitHub/GitLab)
7474

7575
### 🔍 Monitoring & Management
7676

@@ -228,20 +228,19 @@ sudo ./scripts/health-check.sh
228228
**Post-deployment**:
229229

230230
```bash
231+
# Add devices interactively (recommended)
232+
sudo /var/lib/oxidized/scripts/add-device.sh
231233

232-
# Create device inventory
233-
234+
# OR manually edit device inventory
234235
sudo cp inventory/router.db.template /var/lib/oxidized/config/router.db
235236
sudo vim /var/lib/oxidized/config/router.db
236237
sudo chown 30000:30000 /var/lib/oxidized/config/router.db
237238
sudo chmod 644 /var/lib/oxidized/config/router.db
238239

239-
# Restart to load inventory
240-
241-
sudo systemctl restart oxidized.service
240+
# Reload devices (no restart needed)
241+
curl -X GET http://127.0.0.1:8889/reload
242242

243243
# Check status
244-
245244
sudo systemctl status oxidized.service
246245
```
247246

@@ -258,7 +257,7 @@ sudo systemctl status oxidized.service
258257
> 1. ✅ Leave it during initial deployment/testing
259258
> 2. ❌ **Remove or replace it** before production use with your real devices
260259
>
261-
> See [DEVICE-MANAGEMENT.md](/var/lib/oxidized/docs/DEVICE-MANAGEMENT.md) for adding real devices.
260+
> See [docs/DEVICE-MANAGEMENT.md](docs/DEVICE-MANAGEMENT.md) for adding real devices.
262261
263262
**Access Web UI**: `http://<your-server-ip>:8888`
264263
@@ -344,15 +343,17 @@ sudo ./scripts/deploy.sh
344343

345344
This script:
346345

347-
1. Creates system user (`oxidized`, UID 2000)
348-
2. Creates directory structure under `/var/lib/oxidized`
349-
3. Generates Oxidized config from templates
350-
4. Installs Podman Quadlet service
351-
5. Sets up logrotate
352-
6. Pulls container image
353-
7. Starts service
346+
1. Creates system user (`oxidized`, UID 30000)
347+
2. Migrates existing users from old UID 2000 to 30000 (automatic)
348+
3. Creates directory structure under `/var/lib/oxidized`
349+
4. Generates Oxidized config from templates
350+
5. Installs Podman Quadlet service
351+
6. Sets up logrotate and log tailer
352+
7. Installs helper scripts
353+
8. Pulls container image
354+
9. Starts services (oxidized + logger)
354355

355-
**The deployment is idempotent** - safe to re-run.
356+
**The deployment is idempotent** - safe to re-run for upgrades.
356357

357358
#### 6. Create Device Inventory
358359

@@ -378,7 +379,7 @@ sudo systemctl restart oxidized.service
378379

379380
**Format**: `name:ip:model:group:username:password`
380381

381-
See [README-OXIDIZED.md - Device Inventory](README-OXIDIZED.md#-device-inventory-routerdb) for complete documentation.
382+
See [docs/README-OXIDIZED.md - Device Inventory](docs/README-OXIDIZED.md#-device-inventory-routerdb) for complete documentation.
382383

383384
#### 7. Verify Deployment
384385

@@ -415,11 +416,11 @@ sudo journalctl -u oxidized.service -f
415416

416417
```bash
417418

418-
# System user (runs container)
419+
# System user (matches container UID)
419420

420421
OXIDIZED_USER="oxidized"
421-
OXIDIZED_UID=2000
422-
OXIDIZED_GID=2000
422+
OXIDIZED_UID=30000 # Matches container's internal oxidized user
423+
OXIDIZED_GID=30000
423424

424425
# Data directory (all persistent data)
425426

@@ -493,6 +494,10 @@ edge-switch01:10.1.2.1:procurve:distribution:admin:password123
493494

494495
This repository includes automated scripts for common operations:
495496

497+
### Overview
498+
499+
All scripts are deployed to `/var/lib/oxidized/scripts/` for easy access after deployment.
500+
496501
### Deployment Script
497502

498503
**Path**: `scripts/deploy.sh`
@@ -635,6 +640,8 @@ sudo ./scripts/health-check.sh
635640
sudo /var/lib/oxidized/scripts/add-device.sh
636641
```
637642

643+
**NEW**: Backups are automatically organized in `/var/lib/oxidized/config/backup-routerdb/`
644+
638645
**Features**:
639646

640647
- Interactive prompts with validation for hostname, IP, model, and group
@@ -644,7 +651,7 @@ sudo /var/lib/oxidized/scripts/add-device.sh
644651
- Optional per-device credential override
645652
- Comprehensive spell checking with 50+ typo patterns
646653
- Intelligent suggestions for common mistakes (tp-link → tplink, arista → eos)
647-
- Automatic timestamped backups in `/var/lib/oxidized/config/backup/`
654+
- Automatic timestamped backups in `/var/lib/oxidized/config/backup-routerdb/`
648655
- Full syntax validation after addition
649656
- Append-only operation (never overwrites router.db)
650657

@@ -743,6 +750,29 @@ sudo /var/lib/oxidized/scripts/add-device.sh
743750
/var/lib/oxidized/scripts/test-device.sh core-router01
744751
```
745752

753+
### Remote Repository Setup Script
754+
755+
**Path**: `scripts/setup-remote-repo.sh`
756+
757+
**Purpose**: Configure remote git repository (GitHub/GitLab) for backup redundancy
758+
759+
**Usage**:
760+
```bash
761+
sudo /var/lib/oxidized/scripts/setup-remote-repo.sh
762+
```
763+
764+
**Features**:
765+
766+
- Interactive SSH key generation
767+
- GitHub/GitLab integration instructions
768+
- Automatic push configuration (optional timer)
769+
- Connection testing before setup
770+
- Multi-remote support
771+
772+
**Documentation**:
773+
- Quick Start: [docs/QUICK_START_REMOTE_REPO.md](docs/QUICK_START_REMOTE_REPO.md)
774+
- Full Guide: [docs/REMOTE_REPOSITORY.md](docs/REMOTE_REPOSITORY.md)
775+
746776
### Uninstall Script
747777

748778
**Path**: `scripts/uninstall.sh`
@@ -872,7 +902,7 @@ This deployment includes multiple security hardening measures:
872902
- NoNewPrivileges flag
873903
- Dedicated bridge network
874904

875-
For detailed security analysis and trade-offs, see [DEPLOYMENT-NOTES.md](DEPLOYMENT-NOTES.md).
905+
For detailed security analysis and trade-offs, see [docs/DEPLOYMENT-NOTES.md](docs/DEPLOYMENT-NOTES.md).
876906

877907
### Security Best Practices
878908

@@ -890,7 +920,7 @@ For detailed security analysis and trade-offs, see [DEPLOYMENT-NOTES.md](DEPLOYM
890920
sudo -u oxidized ssh-copy-id -i /var/lib/oxidized/ssh/id_ed25519.pub admin@device
891921
```
892922

893-
📖 **For detailed SSH key setup**, see [SSH Key Authentication](README-OXIDIZED.md#ssh-key-authentication-recommended) in README-OXIDIZED.md
923+
📖 **For detailed SSH key setup**, see [SSH Key Authentication](docs/README-OXIDIZED.md#ssh-key-authentication-recommended) in docs/README-OXIDIZED.md
894924

895925
3. **Secure the `.env` file**:
896926

@@ -940,27 +970,53 @@ For detailed security analysis and trade-offs, see [DEPLOYMENT-NOTES.md](DEPLOYM
940970

941971
### Repository Documentation
942972

943-
> **📖 Not sure which doc to read?** See **[DOCUMENTATION-GUIDE.md](DOCUMENTATION-GUIDE.md)** for a complete guide to our documentation structure.
944-
945-
- **[QUICK-START.md](QUICK-START.md)** - ⚡ Quick reference guide for deployment and common tasks
946-
- **[DEVICE-MANAGEMENT.md](DEVICE-MANAGEMENT.md)** - 📱 Complete device management, groups, logging, and validation
947-
- **[DIRECTORY-STRUCTURE.md](DIRECTORY-STRUCTURE.md)** - 📁 Directory layout and file locations explained
948-
- **[CREDENTIALS-GUIDE.md](CREDENTIALS-GUIDE.md)** - 🔑 **IMPORTANT:** Understanding the TWO sets of credentials
949-
- **[DEPLOYMENT-NOTES.md](DEPLOYMENT-NOTES.md)** - ⭐ Deployment improvements, testing notes, and troubleshooting
950-
- **[AUTHENTICATION-SETUP.md](AUTHENTICATION-SETUP.md)** - 🔒 Web UI login configuration and management
951-
- **[SECURITY-AUTHENTICATION.md](SECURITY-AUTHENTICATION.md)** - ⚠️ Security options and considerations
952-
- **[FIREWALL-IMPLEMENTATION.md](FIREWALL-IMPLEMENTATION.md)** - Automatic firewall configuration details
953-
- **[README-OXIDIZED.md](README-OXIDIZED.md)** - Oxidized usage, configuration, and troubleshooting
973+
> **📖 Not sure which doc to read?** See **[docs/DOCUMENTATION-GUIDE.md](docs/DOCUMENTATION-GUIDE.md)** for a complete guide to our documentation structure.
974+
975+
#### Getting Started
976+
- **[docs/QUICK-START.md](docs/QUICK-START.md)** - ⚡ Quick reference guide for deployment and common tasks
954977
- **[docs/INSTALL.md](docs/INSTALL.md)** - Detailed installation guide
978+
- **[docs/PREREQUISITES.md](docs/PREREQUISITES.md)** - System requirements and dependencies
979+
- **[docs/README-OXIDIZED.md](docs/README-OXIDIZED.md)** - Oxidized usage and configuration
980+
981+
#### Configuration & Management
955982
- **[docs/CONFIGURATION.md](docs/CONFIGURATION.md)** - Configuration deep-dive
956983
- **[docs/ENV-ARCHITECTURE.md](docs/ENV-ARCHITECTURE.md)** - Environment variable architecture
984+
- **[docs/DEVICE-MANAGEMENT.md](docs/DEVICE-MANAGEMENT.md)** - 📱 Complete device management guide
985+
- **[docs/ADD-DEVICE.md](docs/ADD-DEVICE.md)** - Interactive device addition guide
986+
- **[docs/DIRECTORY-STRUCTURE.md](docs/DIRECTORY-STRUCTURE.md)** - 📁 Directory layout explained
987+
- **[docs/SERVICE-MANAGEMENT.md](docs/SERVICE-MANAGEMENT.md)** - Service operations guide
988+
989+
#### Security & Authentication
990+
- **[docs/CREDENTIALS-GUIDE.md](docs/CREDENTIALS-GUIDE.md)** - 🔑 **IMPORTANT:** Understanding credentials
957991
- **[docs/SECURITY-HARDENING.md](docs/SECURITY-HARDENING.md)** - Security best practices
992+
- **[docs/SECURITY-AUTHENTICATION.md](docs/SECURITY-AUTHENTICATION.md)** - Authentication options
993+
- **[docs/AUTHENTICATION-SETUP.md](docs/AUTHENTICATION-SETUP.md)** - Web UI login setup
994+
- **[docs/FIREWALL-IMPLEMENTATION.md](docs/FIREWALL-IMPLEMENTATION.md)** - Firewall configuration
995+
996+
#### Remote Backups (NEW)
997+
- **[docs/QUICK_START_REMOTE_REPO.md](docs/QUICK_START_REMOTE_REPO.md)** - ⭐ Remote repository quick start
998+
- **[docs/REMOTE_REPOSITORY.md](docs/REMOTE_REPOSITORY.md)** - Complete remote repo guide
999+
- **[docs/UID_MIGRATION_30000.md](docs/UID_MIGRATION_30000.md)** - UID migration documentation
1000+
1001+
#### Operations & Troubleshooting
1002+
- **[docs/DEPLOYMENT-NOTES.md](docs/DEPLOYMENT-NOTES.md)** - Deployment improvements and notes
1003+
- **[docs/TROUBLESHOOTING-WEB-UI.md](docs/TROUBLESHOOTING-WEB-UI.md)** - Web UI troubleshooting
9581004
- **[docs/UPGRADE.md](docs/UPGRADE.md)** - Upgrade procedures
959-
- **[docs/PREREQUISITES.md](docs/PREREQUISITES.md)** - Prerequisite details
960-
- **[docs/DECISIONS.md](docs/DECISIONS.md)** - Architecture decisions
961-
- **[docs/TROUBLESHOOTING-WEB-UI.md](docs/TROUBLESHOOTING-WEB-UI.md)** - Web UI / Backend Not Responding troubleshooting
1005+
- **[docs/GIT-REPOSITORY-STRUCTURE.md](docs/GIT-REPOSITORY-STRUCTURE.md)** - Git repo structure
1006+
- **[docs/PATH-MAPPINGS.md](docs/PATH-MAPPINGS.md)** - Container path mappings
1007+
1008+
#### Advanced Topics
1009+
- **[docs/CUSTOM-MODELS.md](docs/CUSTOM-MODELS.md)** - Custom device models
1010+
- **[docs/TP-LINK-SX3008F.md](docs/TP-LINK-SX3008F.md)** - TP-Link switch support
1011+
- **[docs/TELNET-CONFIGURATION.md](docs/TELNET-CONFIGURATION.md)** - Telnet setup
1012+
- **[docs/DEVICE-INPUT-CONFIGURATION.md](docs/DEVICE-INPUT-CONFIGURATION.md)** - Input methods
9621013
- **[docs/monitoring/ZABBIX.md](docs/monitoring/ZABBIX.md)** - Zabbix monitoring setup
9631014

1015+
#### Project Documentation
1016+
- **[docs/DECISIONS.md](docs/DECISIONS.md)** - Architecture decisions
1017+
- **[docs/DOCUMENTATION-GUIDE.md](docs/DOCUMENTATION-GUIDE.md)** - Documentation structure
1018+
- **[docs/DOCUMENTATION-CONSOLIDATION.md](docs/DOCUMENTATION-CONSOLIDATION.md)** - Doc organization
1019+
9641020
### Templates
9651021

9661022
- **`env.example`** - Environment variable template with extensive documentation
@@ -1048,8 +1104,9 @@ Full license text: [LICENSE](LICENSE)
10481104

10491105
**Quick Links**:
10501106

1051-
- [Oxidized Usage Guide](README-OXIDIZED.md)
1052-
- [Device Inventory Setup](README-OXIDIZED.md#-device-inventory-routerdb)
1053-
- [Service Management](README-OXIDIZED.md#-service-management)
1054-
- [Troubleshooting](README-OXIDIZED.md#-troubleshooting)
1107+
- [Oxidized Usage Guide](docs/README-OXIDIZED.md)
1108+
- [Quick Start Guide](docs/QUICK-START.md)
1109+
- [Device Management](docs/DEVICE-MANAGEMENT.md)
1110+
- [Remote Repository Setup](docs/QUICK_START_REMOTE_REPO.md)
1111+
- [Troubleshooting](docs/TROUBLESHOOTING-WEB-UI.md)
10551112
- [Security Hardening](docs/SECURITY-HARDENING.md)

config/oxidized/config.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ output:
8080
# Example with device credentials:
8181
# switch01:10.1.1.1:ios:datacenter:admin:password123
8282
#
83-
# Example with global credentials (empty username/password):
84-
# switch02:10.1.1.2:ios:datacenter::
83+
# Example with global credentials (OMIT username/password fields):
84+
# switch02:10.1.1.2:ios:datacenter
8585
#
8686
# CREDENTIAL MODES:
8787
# Mode A - Per-device: Specify username/password in each line (fields 4 & 5)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# Oxidized Log Tailer
3+
# This script tails the Oxidized container logs and writes them to the log file
4+
# Run by systemd as a companion service to oxidized.service
5+
6+
set -euo pipefail
7+
8+
LOG_FILE="/var/lib/oxidized/data/oxidized.log"
9+
CONTAINER_NAME="oxidized"
10+
11+
# Ensure log file exists and is writable
12+
touch "${LOG_FILE}"
13+
chown 30000:30000 "${LOG_FILE}"
14+
chmod 644 "${LOG_FILE}"
15+
16+
# First, capture last 100 lines of existing logs (only if log file is empty)
17+
if [[ ! -s "${LOG_FILE}" ]]; then
18+
podman logs --tail=100 "${CONTAINER_NAME}" >> "${LOG_FILE}" 2>&1
19+
fi
20+
21+
# Then tail new logs continuously
22+
exec podman logs -f --since=5s "${CONTAINER_NAME}" >> "${LOG_FILE}" 2>&1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=Oxidized Log Tailer Service
3+
After=oxidized.service
4+
Requires=oxidized.service
5+
PartOf=oxidized.service
6+
7+
[Service]
8+
Type=simple
9+
ExecStart=/usr/bin/podman logs -f oxidized
10+
Restart=always
11+
RestartSec=5
12+
StandardOutput=append:/var/lib/oxidized/data/oxidized.log
13+
StandardError=append:/var/lib/oxidized/data/oxidized.log
14+
15+
[Install]
16+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)