Skip to content

Commit 2fc3f4d

Browse files
Add RANCID source installation and manual run documentation
- Remove repository-based RANCID installation, install from source only - Add install_rancid_from_source() function with build prerequisites - Update documentation to reflect source installation process - Add section to operators guide for locating cron entries and manually running RANCID - Include commands for running rancid-run for all groups, specific groups, and individual devices
1 parent ccae938 commit 2fc3f4d

4 files changed

Lines changed: 363 additions & 38 deletions

File tree

.cloginrc

Whitespace-only changes.

README.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ deployment script automates the entire setup process on RHEL 10 systems.
4646

4747
### What Gets Installed
4848

49-
- RANCID package and dependencies
49+
- RANCID (compiled and installed from source)
50+
- Build tools and dependencies (gcc, make, expect, perl-devel)
51+
- Runtime dependencies (git, perl-Expect, perl-TermReadKey, net-snmp-utils, openssh-clients)
5052
- RANCID user and group
5153
- Directory structure for device groups
5254
- Git repositories for configuration versioning
@@ -118,21 +120,25 @@ deploy-rancid.sh
118120
- **Operating System**: RHEL 10 (or compatible)
119121
- **Architecture**: x86_64
120122
- **Privileges**: Root access (via `sudo` or direct root login)
121-
- **Network**: Internet access for package installation
123+
- **Network**: Internet access for downloading RANCID source and dependencies
122124

123125
### Software Dependencies
124126

125-
The script automatically installs these packages:
127+
The script automatically installs these packages and builds RANCID from source:
126128

127129
| Package | Purpose | Status |
128130
|---------|---------|--------|
129-
| `rancid` | Main RANCID application | ✅ Required |
131+
| `rancid` | Main RANCID application (installed from source) | ✅ Required |
132+
| `gcc` | C compiler for building RANCID | ✅ Required |
133+
| `make` | Build tool for compiling RANCID | ✅ Required |
134+
| `expect` | Tcl expect (required by RANCID configure) | ✅ Required |
135+
| `perl-devel` | Perl development headers | ✅ Required |
136+
| `curl` | Download tool for RANCID source | ✅ Required |
130137
| `git` | Version control for configs | ✅ Required |
131138
| `perl-Expect` | Device interaction | ✅ Required |
132139
| `perl-TermReadKey` | Terminal input handling | ✅ Required |
133140
| `net-snmp-utils` | SNMP utilities | ✅ Required |
134141
| `openssh-clients` | SSH client tools | ✅ Required |
135-
| `epel-release` | EPEL repository | ✅ Required |
136142

137143
### Pre-Installation Checklist
138144

@@ -357,7 +363,7 @@ sudo ./deploy-rancid.sh --dryrun
357363
- ✅ Directories that would be created
358364
- ✅ Files that would be created or modified
359365
- ✅ Ownership and permission changes
360-
-Package installation commands
366+
-Source installation and build commands
361367
- ✅ User/group creation operations
362368
- ✅ Git repository initialization steps
363369

@@ -482,8 +488,12 @@ The script follows this execution sequence:
482488
483489
4. Package Installation
484490
├─▶ Update system packages
485-
├─▶ Install EPEL repository
486-
└─▶ Install RANCID and dependencies
491+
├─▶ Install runtime dependencies
492+
└─▶ Install RANCID from source (if not already installed)
493+
├─▶ Install build prerequisites
494+
├─▶ Download RANCID source
495+
├─▶ Configure, compile, and install
496+
└─▶ Create symlinks in /usr/bin
487497
488498
5. User/Group Setup
489499
├─▶ Create rancid group (if needed)
@@ -522,7 +532,8 @@ The script follows this execution sequence:
522532

523533
#### Installation Functions
524534

525-
- **`install_packages()`**: Installs RANCID and dependencies via dnf
535+
- **`install_packages()`**: Installs runtime dependencies and RANCID from source
536+
- **`install_rancid_from_source()`**: Downloads, compiles, and installs RANCID from source
526537
- **`create_user_group()`**: Creates rancid user and group
527538
- **`create_base_dirs()`**: Sets up directory structure
528539
- **`write_rancid_conf()`**: Writes main RANCID configuration
@@ -638,10 +649,17 @@ To remove RANCID deployment:
638649
groupdel rancid
639650
```
640651

641-
5. **Uninstall packages** (optional):
652+
5. **Uninstall RANCID binaries** (optional):
642653

643654
```bash
644-
dnf remove rancid perl-Expect perl-TermReadKey net-snmp-utils
655+
# Remove symlinks
656+
rm -f /usr/bin/rancid /usr/bin/rancid-run /usr/bin/clogin
657+
658+
# Remove RANCID installation
659+
rm -rf /usr/local/bin/rancid* /usr/local/bin/clogin* /usr/local/share/rancid
660+
661+
# Remove runtime dependencies (optional, if not used elsewhere)
662+
dnf remove perl-Expect perl-TermReadKey net-snmp-utils
645663
```
646664

647665
### Backup Before Uninstallation
@@ -676,13 +694,13 @@ which dnf
676694
# If missing, you may not be on RHEL 10
677695
```
678696

679-
#### Issue: "Failed to install EPEL repository"
697+
#### Issue: "Failed to download RANCID source"
680698

681-
**Solution**: Check network connectivity and repository access:
699+
**Solution**: Check network connectivity and DNS resolution:
682700

683701
```bash
684702
ping 8.8.8.8
685-
dnf repolist
703+
curl -I http://www.shrubbery.net/pub/rancid/
686704
```
687705

688706
#### Issue: "GIT_NAME is not set (check .env file or defaults)"

deploy-rancid.sh

Lines changed: 146 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#
55
# Description:
66
# This script automates the installation and configuration of RANCID (Really
7-
# Awesome New Cisco confIg Differ) on RHEL 10 systems. It handles package
8-
# installation, user/group creation, directory structure setup, Git repository
9-
# initialization, and cron job configuration.
7+
# Awesome New Cisco confIg Differ) on RHEL 10 systems. It handles RANCID source
8+
# installation (download, compile, install), dependency installation, user/group
9+
# creation, directory structure setup, Git repository initialization, and cron
10+
# job configuration.
1011
#
1112
# Features:
1213
# - Idempotent: Safe to run multiple times
@@ -418,9 +419,9 @@ load_env() {
418419
# Installation Functions
419420
#############################################
420421

421-
# Install required packages via dnf
422+
# Install required packages and RANCID from source
422423
install_packages() {
423-
log "Installing required packages..."
424+
log "Installing required packages and dependencies..."
424425

425426
if ! command_exists dnf; then
426427
die "dnf package manager not found. This script requires RHEL 10 or compatible."
@@ -431,26 +432,148 @@ install_packages() {
431432
die "Failed to update OS packages"
432433
fi
433434

434-
log "Installing EPEL repository..."
435-
if ! dnf -y install epel-release; then
436-
die "Failed to install EPEL repository"
437-
fi
438-
439-
log "Installing RANCID and dependencies..."
435+
log "Installing RANCID runtime dependencies..."
440436
local packages=(
441-
"rancid"
442437
"git"
443438
"perl-Expect"
444439
"perl-TermReadKey"
445440
"net-snmp-utils"
446441
"openssh-clients"
447442
)
448443

444+
# Install runtime dependencies
449445
if ! dnf -y install "${packages[@]}"; then
450-
die "Failed to install RANCID packages"
446+
die "Failed to install RANCID dependencies"
447+
fi
448+
449+
# Check if RANCID is already installed
450+
if command_exists rancid-run; then
451+
log "RANCID appears to be installed (found rancid-run command)"
452+
local version_output
453+
version_output=$(rancid-run -V 2>&1 | head -1 || true)
454+
if [[ -n "${version_output}" ]]; then
455+
log "Version: ${version_output}"
456+
fi
457+
else
458+
log "Installing RANCID from source..."
459+
install_rancid_from_source
460+
fi
461+
462+
log "Package installation completed"
463+
}
464+
465+
# Install RANCID from source
466+
install_rancid_from_source() {
467+
log "Installing RANCID from source..."
468+
469+
# Install build prerequisites
470+
log "Installing build prerequisites..."
471+
local build_packages=(
472+
"gcc"
473+
"make"
474+
"expect"
475+
"perl-devel"
476+
)
477+
478+
if ! dnf -y install "${build_packages[@]}"; then
479+
die "Failed to install build prerequisites for RANCID source installation"
480+
fi
481+
482+
# Check if curl is available (required for download)
483+
if ! command_exists curl; then
484+
log "Installing curl (required for source download)..."
485+
if ! dnf -y install curl; then
486+
die "Failed to install curl, required for downloading RANCID source"
487+
fi
488+
fi
489+
490+
# Set up temporary build directory
491+
local build_dir="/tmp/rancid-build"
492+
local rancid_version="3.13"
493+
local rancid_url="http://www.shrubbery.net/pub/rancid/rancid-${rancid_version}.tar.gz"
494+
local rancid_tarball="${build_dir}/rancid-${rancid_version}.tar.gz"
495+
local rancid_src="${build_dir}/rancid-${rancid_version}"
496+
497+
# Create build directory (clean up if it exists from previous failed attempt)
498+
if [[ -d "${build_dir}" ]]; then
499+
log "Cleaning up previous build directory..."
500+
rm -rf "${build_dir}"
501+
fi
502+
mkdir -p "${build_dir}"
503+
504+
# Download RANCID source
505+
log "Downloading RANCID ${rancid_version} from ${rancid_url}..."
506+
if ! curl -L -f -o "${rancid_tarball}" "${rancid_url}"; then
507+
die "Failed to download RANCID source from ${rancid_url}"
508+
fi
509+
510+
# Verify tarball was downloaded
511+
if [[ ! -f "${rancid_tarball}" ]]; then
512+
die "RANCID tarball not found after download: ${rancid_tarball}"
451513
fi
452514

453-
log "Package installation completed successfully"
515+
# Extract source
516+
log "Extracting RANCID source..."
517+
if ! tar -xzf "${rancid_tarball}" -C "${build_dir}"; then
518+
die "Failed to extract RANCID source tarball"
519+
fi
520+
521+
# Verify source directory exists
522+
if [[ ! -d "${rancid_src}" ]]; then
523+
die "RANCID source directory not found after extraction: ${rancid_src}"
524+
fi
525+
526+
# Configure, compile, and install (use subshell to avoid changing working directory)
527+
log "Configuring RANCID build..."
528+
(
529+
cd "${rancid_src}" || die "Failed to change to RANCID source directory: ${rancid_src}"
530+
531+
if ! ./configure --prefix=/usr/local --sysconfdir=/etc/rancid; then
532+
die "Failed to configure RANCID build"
533+
fi
534+
535+
log "Compiling RANCID..."
536+
if ! make; then
537+
die "Failed to compile RANCID"
538+
fi
539+
540+
log "Installing RANCID..."
541+
if ! make install; then
542+
die "Failed to install RANCID"
543+
fi
544+
)
545+
546+
# Create symlinks in /usr/bin for PATH compatibility
547+
log "Creating symlinks in /usr/bin..."
548+
local binaries=("rancid" "rancid-run" "clogin")
549+
for binary in "${binaries[@]}"; do
550+
if [[ -f "/usr/local/bin/${binary}" ]]; then
551+
if [[ -L "/usr/bin/${binary}" ]] || [[ -f "/usr/bin/${binary}" ]]; then
552+
log "Symlink or file already exists: /usr/bin/${binary}, skipping"
553+
else
554+
ln -sf "/usr/local/bin/${binary}" "/usr/bin/${binary}"
555+
log "Created symlink: /usr/bin/${binary} -> /usr/local/bin/${binary}"
556+
fi
557+
else
558+
log_warn "Binary not found after installation: /usr/local/bin/${binary}"
559+
fi
560+
done
561+
562+
# Clean up build directory
563+
log "Cleaning up build directory..."
564+
rm -rf "${build_dir}"
565+
566+
# Verify installation
567+
if command_exists rancid-run; then
568+
log "RANCID installed successfully from source"
569+
local version_output
570+
version_output=$(rancid-run -V 2>&1 | head -1 || true)
571+
if [[ -n "${version_output}" ]]; then
572+
log "Version: ${version_output}"
573+
fi
574+
else
575+
die "RANCID installation completed but rancid-run command not found"
576+
fi
454577
}
455578

456579
# Create RANCID user and group
@@ -729,13 +852,19 @@ ${CRON_LINE}"
729852
post_checks() {
730853
log "Performing post-installation validation..."
731854

732-
# Verify RANCID commands are available
855+
# Verify RANCID commands are available (warn if not found, don't fail)
733856
if ! command_exists rancid-run; then
734-
die "rancid-run not found on PATH after installation"
857+
log_warn "rancid-run not found on PATH"
858+
log_warn "RANCID may need to be installed from source"
859+
log_warn "See: https://www.shrubbery.net/rancid/ for installation instructions"
860+
else
861+
log "RANCID commands verified: rancid-run found"
735862
fi
736863

737864
if ! command_exists rancid; then
738-
die "rancid not found on PATH after installation"
865+
log_warn "rancid command not found on PATH"
866+
else
867+
log "RANCID commands verified: rancid found"
739868
fi
740869

741870
log "Verifying ownership and permissions..."

0 commit comments

Comments
 (0)