Skip to main content

Network Config Builder

Project description

Network Config Builder

As a network automation engineer I need to template build network device configurations. I want to use Jinja2 as my templating language. I want to be able to use the Jinaj include directive so that I can include relative template files. I want the ability to dynamically create variable collections for each host using native Python, and have a tool that correlates these variables based on a priority ordering.

This repostory provides such a tool.

$ netcfg-builder --template <template-file.j2> -e <extra-variables>

When -e <varname>=<value>, then the variable name varname is defined with the value <value>.

For example, define a varialbe called varsdir that has the value /usr/local/myvars.

$ netcfg-build --template <template-file> -e vardirs=/usr/local/lib/myvars

When <extra-varialbes> is a .py file, that file needs to decorator functions; each of these functions will be called in priority order. Priority 0 is first.

For example:

from pathlib import Path
from netcfg_builder.variables import ingest, load_directory

@ingest(0)
def load_variables(tvars: dict, **extras):
    varsdir = Path(extras['varsdir'])
    tvars.update(load_directory(varsdir.joinpath('common')))
    tvars.update(load_directory(varsdir.joinpath(extras['hostname'])))

The first parameter, tvars to the decordated function is current set of template variables. The second parameter, **extras are any extra variables defined on the command line.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netcfg-builder-0.3.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netcfg_builder-0.3.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file netcfg-builder-0.3.0.tar.gz.

File metadata

  • Download URL: netcfg-builder-0.3.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3

File hashes

Hashes for netcfg-builder-0.3.0.tar.gz
Algorithm Hash digest
SHA256 94a01899393a3364cc9c311d45ccd24267e1dc8a087f759653b592f0bb80c351
MD5 ebf7044e1cb026e3b6dd3f642898c1b1
BLAKE2b-256 00dd45fdb0dafd819b85c6cb3a41ca7def1e818261517df461cd423668984d37

See more details on using hashes here.

File details

Details for the file netcfg_builder-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: netcfg_builder-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3

File hashes

Hashes for netcfg_builder-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 138622c2f5586bdc63e67ed4535036341441365cfda0a1186dc91278ad3d0c49
MD5 432a9d86b4f764e22fda5693e843cabf
BLAKE2b-256 c636846b0106c7a487b3efbef6a2f85a6c9950fac13d6d30c7cb5d4c54d6b7c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page