Skip to content

Installation Guide

Complete installation instructions for the Train-Juniper plugin.

Quick Start

New to Train-Juniper? Follow Method 1 for the fastest installation experience.

Prerequisites

Ruby Environment

  • Ruby: 3.0+ (3.1.6+ recommended)
  • Bundler: Latest version
  • InSpec: 6.0+ (latest recommended)

System Requirements

  • SSH Client: OpenSSH or compatible
  • Network Access: Connectivity to target Juniper devices
  • Platform: Linux, macOS, or Windows with WSL

Installation Methods

Method 1: From RubyGems

  1. Recommended for most users
# Install by name from RubyGems (once published)
inspec plugin install train-juniper

# Verify installation
inspec plugin list

Installation Complete

If you see train-juniper in the plugin list, you're ready to go!

Get Started with Basic Usage

Method 2: Local Gem Installation

Development Installation

This method is for development and testing. Use Method 1 for production.

git clone https://github.com/mitre/train-juniper.git
cd train-juniper
bundle install
gem build train-juniper.gemspec
inspec plugin install ./train-juniper-0.4.0.gem
  1. Clone repository

    git clone https://github.com/mitre/train-juniper.git
    cd train-juniper
    

  2. Install dependencies

    bundle install
    

  3. Build gem file

    gem build train-juniper.gemspec
    

  4. Install local gem

    inspec plugin install ./train-juniper-0.4.0.gem
    

Method 3: Bundle Development (Developers)

# Clone repository
git clone https://github.com/mitre/train-juniper.git
cd train-juniper

# Install dependencies
bundle install

# Use with bundle exec
bundle exec inspec detect -t juniper://device.example.com

Verification

Test Plugin Loading

# Verify plugin is registered
inspec plugin list
# Should show: train-juniper

# Test URI scheme recognition
inspec detect -t juniper://
# Should show usage help, not "unsupported scheme"

Test Mock Connection

# Test with mock mode
inspec detect -t juniper://mock --reporter json

Expected output:

{
  "platform": {
    "name": "juniper",
    "families": ["bsd", "unix", "os"],
    "release": "0.4.0"
  }
}

Test Real Device Connection

# Test with real device (replace with your device)
inspec detect -t juniper://admin@device.example.com

Expected output:

You are currently running on:
    Name:      juniper
    Families:  bsd, unix, os
    Release:   23.4R1.9
    Arch:      amd64

Configuration

SSH Configuration

The plugin respects standard SSH configuration:

~/.ssh/config:

Host *.juniper.lab
  User admin
  Port 2222
  IdentityFile ~/.ssh/juniper_key
  StrictHostKeyChecking no

Host jump.example.com
  User admin
  IdentityFile ~/.ssh/bastion_key

Environment Variables

Set these for convenience:

# Device credentials
export JUNIPER_HOST=device.example.com
export JUNIPER_USER=admin
export JUNIPER_PASSWORD=secret123

# Bastion configuration
export JUNIPER_BASTION_HOST=jump.example.com
export JUNIPER_BASTION_USER=admin

# Connection tuning
export JUNIPER_TIMEOUT=60
export JUNIPER_PORT=22

Troubleshooting Installation

Common Installation Issues

Having trouble? Check these common problems and solutions.

Plugin Not Found

Error Message

Can't find train plugin juniper

Solutions:

# Verify plugin is installed
inspec plugin list
# Remove and reinstall
inspec plugin uninstall train-juniper
inspec plugin install train-juniper
# Verify gem is available
gem list train-juniper

InSpec Plugin Manager Issues

Error: Plugin failed to load

Debug Steps:

# Test gem loads in Ruby
ruby -e "require 'train-juniper'; puts 'OK'"

# Check InSpec gem compatibility
inspec version
ruby --version

# Clean plugin cache
rm -rf ~/.inspec/plugins/
inspec plugin install train-juniper

Dependency Conflicts

Error: Gem::ConflictError

Solution: Use bundle development mode:

git clone https://github.com/mitre/train-juniper.git
cd train-juniper
bundle install
bundle exec inspec detect -t juniper://device.example.com

SSH Connection Issues

Error: SSH authentication failed

Debug Steps:

# Test SSH manually
ssh admin@device.example.com

# Enable SSH debug in plugin
TRAIN_DEBUG=true inspec detect -t juniper://admin@device.example.com

# Check SSH agent
ssh-add -l

Development Setup

For plugin development and contribution:

1. Clone and Setup

git clone https://github.com/mitre/train-juniper.git
cd train-juniper
bundle install

2. Run Tests

# All tests
bundle exec rake test

# Unit tests only
bundle exec ruby -Ilib:test test/unit/transport_test.rb

# Code coverage
bundle exec rake test
open coverage/index.html

3. Code Quality

# Linting
bundle exec rubocop

# Security audit
bundle exec bundle-audit check

4. Local Testing

# Build and test gem
gem build train-juniper.gemspec
inspec plugin install train-juniper-0.4.0.gem

# Test with real device
inspec detect -t juniper://admin@your-device.com

Next Steps

Support