Import devices from RANCID into rConfig V8 Core
The RANCID Import Tool migrates network devices from RANCID into rConfig V8 Core using the command line. After reading this page, you can map RANCID device types to rConfig templates, extract credentials from .cloginrc, generate an import file from router.db, and bulk import the devices with their vendors, categories, tags, and prompts.
When to use this
Section titled “When to use this”Use this tool when you are moving an existing RANCID deployment to rConfig V8 Core and want to onboard devices in bulk rather than adding them by hand. It suits a one-time migration or a phased cut-over where RANCID and rConfig run in parallel while you validate connectivity. For a handful of devices, adding them through the UI is usually quicker.
Prerequisites
Section titled “Prerequisites”Before importing devices, ensure you have:
- Access to a RANCID installation with
router.dbfiles - Read access to
.cloginrcfor credential extraction (optional but recommended) - Administrator access to rConfig V8 Core
- Device templates configured in rConfig that match your RANCID device types
- At least one credential set created in rConfig (required for devices without
.cloginrccredentials) - SSH/command-line access to the rConfig server
How the import works
Section titled “How the import works”The import runs in three commands, each a distinct stage:
- Create device type mappings: define how RANCID device types translate to rConfig templates, vendors, and categories.
- Load devices from RANCID: parse
router.db, extract credentials from.cloginrc, and generate an import-ready JSON file. - Import devices to rConfig: bulk import the devices with validated configurations.
File locations
Section titled “File locations”The tool uses the following paths:
- Mappings file:
storage/app/rconfig/rancid_mappings.json - Temporary files:
storage/app/rconfig/tempdir/ - Import JSON files:
storage/app/rconfig/tempdir/rconfig_import_YYYY-MM-DD_HH-mm-ss.json - Failure logs:
storage/app/rconfig/tempdir/rancid_import_failures_[group]_YYYY-MM-DD_HH-mm-ss.txt
These directories are created automatically if they do not exist.
Step 1: Create device type mappings
Section titled “Step 1: Create device type mappings”Run the mappings command:
php /var/www/html/rconfig/artisan rconfig:rancid-device-mappingsOptions
Section titled “Options”--list- Display all existing device type mappings--add- Create a new device type mapping interactively--edit=TYPE- Modify an existing mapping for the specified device type--delete=TYPE- Remove a device type mapping--info- Display command help and usage information
Create a new mapping
Section titled “Create a new mapping”php /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --addYou are prompted to provide:
- RANCID device type: the device type from your RANCID
router.db(for examplecisco,juniper,foundry) - rConfig device type: the internal device type name (for example
cisco_ios) - rConfig template: the device template ID to use for this device type
- Vendor: the vendor ID associated with this device type
- Category: the category ID for organising devices
- Tags: multi-select tags for device classification (use Space to select, Enter to confirm)
- Prompts: device enable and main prompts (use
{device_name}as the placeholder)
Common RANCID device types
Section titled “Common RANCID device types”cisco: Cisco IOS devices (routers, switches)juniper: Juniper JunOS devicesfoundry: Foundry/Brocade deviceshp: HP ProCurve switchesextreme: Extreme Networks devicesarista: Arista Networks devicesforce10: Force10/Dell devices
View existing mappings
Section titled “View existing mappings”php /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --listThe output displays all configured mappings:
=== CISCO ===rConfig Type: cisco_iosTemplate ID: 1Vendor ID: 1Category ID: 2Prompts: - device_enable_prompt: {device_name}> - device_main_prompt: {device_name}#Tags: 5, 8Edit or delete mappings
Section titled “Edit or delete mappings”# Edit existing mappingphp /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --edit=cisco
# Delete mappingphp /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --delete=ciscoStep 2: Load devices from RANCID
Section titled “Step 2: Load devices from RANCID”Run the load command:
php /var/www/html/rconfig/artisan rconfig:rancid-load-devicesOptions
Section titled “Options”--rancid-base=/path- Specify the RANCID base directory (auto-detected if not provided)--group=groupname- Import only a specific RANCID group--info- Display command help and usage information
RANCID directory structure
Section titled “RANCID directory structure”RANCID uses one of two structures, both auto-detected by the tool.
Debian/Ubuntu:
/usr/local/rancid/├── .cloginrc # Credentials file├── etc/rancid.conf # RANCID configuration└── var/ # Device data ├── group1/ │ ├── router.db # Device list │ └── configs/ # Configuration files └── group2/ ├── router.db └── configs/RHEL/Rocky/CentOS:
/var/lib/rancid/├── .cloginrc├── group1/ # Groups directly under base│ ├── router.db│ └── configs/└── group2/ ├── router.db └── configs/RANCID base directory auto-detection
Section titled “RANCID base directory auto-detection”If --rancid-base is not specified, the tool checks these paths in order:
/usr/local/rancid/var/lib/rancid/var/rancid/opt/rancid
If none are found, you are prompted to enter the path manually.
router.db file format
Section titled “router.db file format”hostname:device_type:statusRANCID 3.0+ also supports a semicolon delimiter:
hostname;device_type;statusExamples:
# Devices marked as "up" (will be imported)router1.example.com:cisco:upswitch1.example.com:hp:upfw1.example.com:juniper:up
# Devices marked as "down" (will be skipped)router2.example.com:cisco:down
# RANCID 3.0+ formatrouter3.example.com;cisco;upCredential extraction from .cloginrc
Section titled “Credential extraction from .cloginrc”The tool parses .cloginrc to extract credentials per device.
.cloginrc format:
# Username for specific devicesadd user router1.example.com adminadd user 192.168.1.* netadmin
# Password (and optional enable password)add password router1.example.com myPassword myEnablePasswordadd password *.example.com defaultPass defaultEnable
# Glob patterns are supportedadd user *.core.* coreuseradd password *.core.* corepassCredential matching works as follows:
- The tool checks
.cloginrcfor patterns matching each device’s hostname or IP. - If a match is found, the credentials are embedded in the JSON (
device_cred_id = 0). - If no match is found, the device uses the default credential set you select.
Default credential selection
Section titled “Default credential selection”If devices have no credentials in .cloginrc, you are prompted to pick a default:
Select a default credential to use for devices without specific credentials in .cloginrc:
Which credential would you like to use as default? ID #1: Production SSH Credentials ID #2: Lab CredentialsWhat happens during loading
Section titled “What happens during loading”- RANCID directory detection: locates the RANCID base directory
- Group discovery: finds all groups with
router.dbfiles - Group selection: you select a specific group or all groups
- Prerequisite checks: validates that mappings and credential sets exist
- router.db parsing: reads device lists from each group
- Status filtering: skips devices not marked as “up”
- Device type validation: checks a mapping exists for each device type
- DNS resolution: resolves hostnames to IP addresses
- Config file verification: ensures a config file exists
- Config analysis: extracts model and version information from config files
- Credential extraction: parses
.cloginrcfor device credentials - JSON generation: creates a timestamped import file per group
- Failure logging: records validation issues per group
Output files
Section titled “Output files”The command generates two files per group.
Success file: storage/app/rconfig/tempdir/rconfig_import_2025-01-25_14-30-45.json
Failures file: storage/app/rconfig/tempdir/rancid_import_failures_networking_2025-01-25_14-30-45.txt
Example JSON output:
[ { "device_name": "router1.example.com", "device_ip": "192.168.1.1", "device_model": "7206VXR", "template_id": 1, "vendor_id": 1, "device_category_id": 2, "prompts": { "device_enable_prompt": "router1.example.com>", "device_main_prompt": "router1.example.com#" }, "tags": [5, 8], "rancid_group": "networking", "device_cred_id": 0, "device_username": "admin", "device_password": "myPassword", "device_enable_password": "myEnablePassword", "connection_type": "ssh", "port": 22 }, { "device_name": "switch1.example.com", "device_ip": "192.168.1.2", "device_model": "3750", "template_id": 1, "vendor_id": 1, "device_category_id": 2, "prompts": { "device_enable_prompt": "switch1.example.com>", "device_main_prompt": "switch1.example.com#" }, "tags": [5, 8], "rancid_group": "networking", "device_cred_id": 1, "connection_type": "ssh", "port": 22 }]Credential assignment logic
Section titled “Credential assignment logic”device_cred_id = 0: the device uses embedded credentials from.cloginrc(username/password in the JSON).device_cred_id > 0: the device uses the specified credential set ID from rConfig.
Step 3: Import devices to rConfig
Section titled “Step 3: Import devices to rConfig”Run the import command, passing the generated JSON file:
php /var/www/html/rconfig/artisan rconfig:rancid-import-devices /path/to/rconfig_import.jsonOptions
Section titled “Options”--group=ID- Assign all imported devices to the specified device group (default: 1)--dry-run- Preview the import without modifying the database--info- Display command help and usage information
Interactive import options
Section titled “Interactive import options”When run without a file path, the command offers a menu:
What would you like to do? Show information about this command Import devices from a JSON file Import from the latest available JSON file Select from all available import files Exit- Latest file mode: automatically finds and uses the most recent JSON file.
- Select file mode: displays all available import files with filename, date, size, and device count.
Import process flow
Section titled “Import process flow”- JSON validation: verifies file structure and required fields
- Device validation: checks each device for required fields and valid IDs
- Transaction-based import: all valid devices are imported in a single database transaction
- Device creation: creates device records with mapped configurations
- Relationship linking: associates tags, vendors, categories, and templates
- Duplicate handling: skips devices that already exist
- Summary report: displays import statistics
Device relationships created
Section titled “Device relationships created”For each imported device, rConfig links:
- Tags: many-to-many relationship with the selected tags
- Vendor: single vendor
- Category: single category
- Template: single template
Validation rules
Section titled “Validation rules”Required fields:
device_namedevice_ip(must be a valid IP format)device_modeltemplate_id(must exist in the database)vendor_id(must exist in the database)device_category_id(must exist in the database)prompts(must containdevice_enable_promptanddevice_main_prompt)
Credential validation:
- If
device_cred_id = 0:device_usernameanddevice_passwordare required. - If
device_cred_id > 0: the credential set must exist in the database.
Duplicate detection:
- No existing device with the same
device_name - No existing device with the same
device_ip
Dry run mode
Section titled “Dry run mode”Test the import without making changes:
php /var/www/html/rconfig/artisan rconfig:rancid-import-devices \ --dry-run \ /path/to/rconfig_import.jsonOutput preview:
Running in dry-run mode - no database changes will be made
Validating devices ████████████████████ 100%
12 devices failed validation:Device: router99.example.com - Template ID 99 not found
Continue with 188 valid devices? (yes/no)
Dry run completed. 188 devices would be imported.Production import
Section titled “Production import”Execute the actual import:
php /var/www/html/rconfig/artisan rconfig:rancid-import-devices \ --group=5 \ /path/to/rconfig_import.jsonImport results:
Found 200 devices in the import file
Validating devices ████████████████████ 100%
Importing devices ████████████████████ 100%
Import completed successfully!Imported: 195 devicesSkipped: 5 devices (already exist)Complete workflow example
Section titled “Complete workflow example”# Step 1: Create device type mappingsphp /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --add
# Add mappings for common RANCID types: cisco, juniper, hp, etc.
# Verify mappingsphp /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --list
# Step 2: Load devices from RANCIDphp /var/www/html/rconfig/artisan rconfig:rancid-load-devices
# The command will:# - Auto-detect the RANCID installation# - Show available groups# - Extract credentials from .cloginrc# - Generate a timestamped JSON file
# Review failures logcat storage/app/rconfig/tempdir/rancid_import_failures_networking_2025-01-25_14-30-45.txt
# Step 3: Preview import (dry run)php /var/www/html/rconfig/artisan rconfig:rancid-import-devices \ --dry-run \ storage/app/rconfig/tempdir/rconfig_import_2025-01-25_14-30-45.json
# Step 4: Execute production importphp /var/www/html/rconfig/artisan rconfig:rancid-import-devices \ --group=1 \ storage/app/rconfig/tempdir/rconfig_import_2025-01-25_14-30-45.json
# Or use the latest file automaticallyphp /var/www/html/rconfig/artisan rconfig:rancid-import-devices# Select: "Import from the latest available JSON file"Troubleshooting
Section titled “Troubleshooting”RANCID directory not found
Section titled “RANCID directory not found”Symptom: Could not find RANCID installation directory.
Specify the RANCID base directory explicitly:
php /var/www/html/rconfig/artisan rconfig:rancid-load-devices \ --rancid-base=/custom/path/to/rancidNo RANCID groups found
Section titled “No RANCID groups found”Symptom: No RANCID groups found in: /path/to/rancid/var.
Verify the directory structure and that router.db files exist:
# Check for groupsls -la /usr/local/rancid/var/
# Verify router.db existsls -la /usr/local/rancid/var/*/router.dbNo credential sets exist
Section titled “No credential sets exist”Symptom: No device credentials found in the system, and the import halts before processing devices.
Create at least one credential set in rConfig:
- Navigate to Settings > Credentials.
- Create a new credential set with valid SSH credentials.
- Re-run the load devices command.
Device type mapping not found
Section titled “Device type mapping not found”Symptom: devices logged to the failures file with Unknown device type 'xyz'. No mapping found..
Create the missing mapping, then verify:
php /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --addphp /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --listInvalid template, vendor, or category ID
Section titled “Invalid template, vendor, or category ID”Symptom: Template ID X does not exist or Vendor ID X not found.
Verify the IDs exist in rConfig:
- Navigate to Settings > Templates (or Vendors/Categories) and note the correct ID numbers.
- Update the mapping with the correct IDs:
php /var/www/html/rconfig/artisan rconfig:rancid-device-mappings --edit=ciscoDNS resolution failures
Section titled “DNS resolution failures”Symptom: devices logged to the failures file with Could not resolve hostname to IP address.
Verify DNS is working on the rConfig server:
nslookup router1.example.comhost router1.example.comThen resolve by adding entries to /etc/hosts, configuring DNS servers in /etc/resolv.conf, or updating router.db to use IP addresses instead of hostnames.
Config file not found
Section titled “Config file not found”Symptom: devices logged to the failures file with Config file not found in /path/configs.
Verify config files exist, and run RANCID to collect them if needed:
ls -la /usr/local/rancid/var/groupname/configs/rancid-run groupname.cloginrc parsing errors
Section titled “.cloginrc parsing errors”Symptom: all devices use the default credential set despite .cloginrc existing.
Verify the file format and permissions so the web server user can read it:
ls -la /usr/local/rancid/.cloginrcchmod 644 /usr/local/rancid/.cloginrc
# Valid format:# add user router1.example.com admin# add password router1.example.com myPass myEnableDevices marked as “down” being skipped
Section titled “Devices marked as “down” being skipped”Symptom: many devices logged with Device status is not 'up'.
This is intentional. Only devices marked as “up” in router.db are imported. To include down devices, temporarily edit router.db:
# Backup firstcp router.db router.db.backup
# Change status to upsed -i 's/:down$/:up/g' router.dbrouter.db format errors
Section titled “router.db format errors”Symptom: devices logged with Invalid router.db format.
Verify the format and remove blank lines:
# Valid formats:# hostname:device_type:status (legacy)# hostname;device_type;status (RANCID 3.0+)
sed -i '/^$/d' router.dbTransaction rollback on import
Section titled “Transaction rollback on import”Symptom: Import failed: [error message], and zero devices imported despite validation passing.
Check the application logs, then re-run with --dry-run to identify the issue:
tail -f storage/logs/laravel.log
php /var/www/html/rconfig/artisan rconfig:rancid-import-devices \ --dry-run \ /path/to/file.jsonCommon gotchas
Section titled “Common gotchas”Post-import tasks
Section titled “Post-import tasks”After a successful import:
- Verify the device inventory: navigate to Devices and confirm all devices imported correctly.
- Review credentials: check that devices have the appropriate credential assignments.
- Test connectivity: use the device debug command to verify connections to sample devices.
- Organise devices: create device groups matching your RANCID organisation.
- Configure schedules: set up automated backup schedules for device groups.
- Archive RANCID data: back up the RANCID directories for historical reference.
What’s next
Section titled “What’s next”- Manage devices in rConfig V8 Core - Review and edit the devices you just imported.
- Configure connection templates - Tune the templates and credentials used to reach each device.
- Schedule configuration backups - Automate backups for the imported device groups.