Giter Site home page Giter Site logo

ddevalco / configmerge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jamiecaesar/configmerge

0.0 2.0 0.0 272 KB

Python script for creating IOS/NX-OS configurations. It will take a template configuration file and a variables file. The script will read in the variables for each device from the variables file, and then create a configuration from each device based on the template file.

License: MIT License

Python 100.00%

configmerge's Introduction

ConfigMerge

ConfigMerge is a Python script for creating multiple IOS/NX-OS configurations based on a template. It requires the following:

  • a template configuration file
  • a variables file, which contains replacement values for every host that a config should be generated for.

The script will parse a list of replacement variables for each host from the variables file, and then create a configuration for each device based on the template file. In short, this is an automated "Find and Replace", or Mail Merge for configuration files. There are some additional checks of the data to help catch errors and/or missing data.

ExTemplate.txt is an example template file that you would use as input for the script. ExampleVars.csv is an example variables file. This file is in Comma Separated Value (CSV) format so that values can be easily added in Excel. This file can be generated by the script, after it has collected all the variables in the template file. Once modified for each device, is used as input to create individual config files.

##Additional Features (beyond basic find/replace)

  • Verifies the template has a unique key (default: <HOSTNAME>) variable. This unique key is used to identify each individual device/config that is being generated by this script.
  • Checks for duplicate hostnames in the variables file (in the case of copy/paste errors).
  • Will verify all variables in the template file are in the CSV file (and vice versa)
  • --key (-k) option allow changing the unique key variable to something different, in case the default doesn't work for your particular use case.
  • --single_mode (-s) option can be used when the script will only be performing find/replace logic on a single configuration file. This ignores the requirement for a unique key. It will also only read the first non-header line in the CSV file when creating the config.
  • --help (-h) option that explains the syntax of the command as well as available flags.

##Using the script

  • Once you have the "golden" configuration template. Replace any part of the configuration file that needs to be changed per-device to a variable name (i.e. <IP_ADDR>)
  • Once you have your template configuration file, use the cmerge.py script to create the variables CSV file with only the header row.
python cmerge.py <template_filename> -o <output_filename.csv>
  • Modify the output variables file by adding a line for each device with all the appropriate information.

  • NOTE: If you leave a variable empty, the script will delete any lines that contain that variable.

  • Run the cmerge script, using your modified .csv file as the input file:

python cmerge.py <template_filename> -i <variable_filename>
  • Gather your configuration files from the configs/ directory, which was created by the script.

configmerge's People

Contributors

jamiecaesar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.