A powerful command-line interface tool for network configuration analysis, remediation, and rollback built on top of the Hier Config library.
hier-config-cli helps network engineers analyze configuration differences, generate remediation commands, prepare rollback procedures, and predict configuration states across multiple network platforms. It's an essential tool for network automation workflows, change management, and configuration compliance.
- 🔄 Remediation Generation: Automatically generate commands to transform running config into intended config
- ⏮️ Rollback Planning: Create rollback procedures before making changes
- 🔮 Future State Prediction: Preview the complete configuration after applying changes
- 🌐 Multi-Platform Support: Works with Cisco, Juniper, Arista, HP, Fortinet, VyOS, and more
- 📊 Multiple Output Formats: Export as text, JSON, or YAML
- 🎯 Type-Safe: Fully typed Python code with mypy support
- ✅ Well-Tested: Comprehensive test suite with high code coverage
- 📝 Detailed Logging: Verbose and debug modes for troubleshooting
pip install hier-config-clipoetry add hier-config-cligit clone https://github.com/netdevops/hier-config-cli.git
cd hier-config-cli
poetry installhier-config-cli list-platformsOutput:
=== Available Platforms ===
eos
fortios
generic
hp_comware5
hp_procurve
ios
iosxr
junos
nxos
vyos
Compare your running configuration with the intended configuration and generate the commands needed to remediate:
hier-config-cli remediation \
--platform ios \
--running-config running.conf \
--generated-config intended.confPrepare rollback commands before making changes:
hier-config-cli rollback \
--platform ios \
--running-config running.conf \
--generated-config intended.confSee what the complete configuration will look like after applying changes:
hier-config-cli future \
--platform ios \
--running-config running.conf \
--generated-config intended.confhier-config-cli remediation \
--platform ios \
--running-config examples/cisco_ios_running.conf \
--generated-config examples/cisco_ios_intended.confOutput:
=== Remediation Configuration ===
no hostname router-01
hostname router-01-updated
interface GigabitEthernet0/0
no description WAN Interface
description WAN Interface - Updated
interface Vlan20
description Guest VLAN
ip address 10.0.20.1 255.255.255.0
router ospf 1
network 10.0.20.0 0.0.0.255 area 0
ntp server 192.0.2.1
hier-config-cli remediation \
--platform ios \
--running-config running.conf \
--generated-config intended.conf \
--format jsonhier-config-cli remediation \
--platform nxos \
--running-config running.conf \
--generated-config intended.conf \
--format yamlhier-config-cli remediation \
--platform iosxr \
--running-config running.conf \
--generated-config intended.conf \
--output remediation_commands.txt# INFO level logging
hier-config-cli -v remediation \
--platform ios \
--running-config running.conf \
--generated-config intended.conf
# DEBUG level logging
hier-config-cli -vv remediation \
--platform ios \
--running-config running.conf \
--generated-config intended.confGenerates the commands needed to transform the running configuration into the intended configuration.
Options:
--platform: Target platform (required) - seelist-platformsfor options--running-config: Path to running configuration file (required)--generated-config: Path to intended/generated configuration file (required)--format: Output format -text,json, oryaml(default: text)--output, -o: Write output to file instead of stdout
Generates the commands needed to revert from the intended configuration back to the running configuration. Useful for preparing rollback procedures before making changes.
Options: Same as remediation
Predicts what the complete configuration will look like after applying the intended configuration to the running configuration.
Options: Same as remediation
Lists all supported network platforms.
Shows the installed version of hier-config-cli.
| Platform | Code | Description |
|---|---|---|
| Cisco IOS | ios |
Cisco IOS routers and switches |
| Cisco NX-OS | nxos |
Cisco Nexus switches |
| Cisco IOS XR | iosxr |
Cisco IOS XR routers |
| Arista EOS | eos |
Arista switches |
| Juniper JunOS | junos |
Juniper routers and switches |
| VyOS | vyos |
VyOS routers |
| Fortinet FortiOS | fortios |
Fortinet firewalls |
| HP Comware5 | hp_comware5 |
HP Comware5 switches |
| HP ProCurve | hp_procurve |
HP ProCurve switches |
| Generic | generic |
Generic/unknown platform |
from nornir import InitNornir
from nornir.core.task import Task
import subprocess
def generate_remediation(task: Task) -> None:
"""Generate remediation for a device."""
result = subprocess.run(
[
"hier-config-cli",
"remediation",
"--platform", task.host.platform,
"--running-config", f"configs/{task.host.name}_running.conf",
"--generated-config", f"configs/{task.host.name}_intended.conf",
"--output", f"remediation/{task.host.name}_remediation.txt",
],
capture_output=True,
text=True,
)
return result.stdout
nr = InitNornir(config_file="config.yaml")
results = nr.run(task=generate_remediation)- name: Generate configuration remediation
hosts: network_devices
tasks:
- name: Run hier-config-cli remediation
command: >
hier-config-cli remediation
--platform {{ platform }}
--running-config /tmp/{{ inventory_hostname }}_running.conf
--generated-config /tmp/{{ inventory_hostname }}_intended.conf
--output /tmp/{{ inventory_hostname }}_remediation.txt
register: remediation_result
- name: Display remediation
debug:
msg: "{{ remediation_result.stdout }}"# .github/workflows/config-validation.yml
name: Validate Network Configs
on: [push, pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install hier-config-cli
run: pip install hier-config-cli
- name: Generate remediation
run: |
hier-config-cli remediation \
--platform ios \
--running-config prod/running.conf \
--generated-config staging/intended.conf \
--output remediation.txt
- name: Upload remediation
uses: actions/upload-artifact@v4
with:
name: remediation-config
path: remediation.txt- Python 3.9 or higher
- Poetry (for dependency management)
# Clone the repository
git clone https://github.com/netdevops/hier-config-cli.git
cd hier-config-cli
# Install dependencies
poetry install
# Activate virtual environment
poetry shell# Run all tests
pytest
# Run with coverage
pytest --cov=hier_config_cli --cov-report=html
# Run specific test file
pytest tests/test_cli.py
# Run with verbose output
pytest -v# Format code with black
black src/ tests/
# Lint with ruff
ruff check src/ tests/
# Type check with mypy
mypy src/
# Run all quality checks
black src/ tests/ && ruff check src/ tests/ && mypy src/ && pytestContributions are welcome! Please see CONTRIBUTING.md for details on:
- Code of conduct
- Development workflow
- Pull request process
- Coding standards
For security issues, please see SECURITY.md for our security policy and how to report vulnerabilities.
See CHANGELOG.md for a detailed list of changes between versions.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Documentation: https://github.com/netdevops/hier-config-cli
- PyPI: https://pypi.org/project/hier-config-cli/
- Issues: https://github.com/netdevops/hier-config-cli/issues
- Hier Config Library: https://github.com/netdevops/hier_config
Built on top of the excellent Hier Config library by James Williams and contributors.
- 📫 Open an issue: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📧 Email: james.williams@packetgeek.net