Network Config Backup from IP Fabric to Git
Project description
Network Config Backup from IP Fabric to Github
As a User of the IP Fabric product, I want to copy the network device configuration from IP Fabric into a Git repository.
This tool takes inspiration from the netcfgbu project that backs up network configuration using a direct SSH-to-device approach.
Quick Start
Once you've configured your ipfnetcfgbu.toml
configuration file, you can run the following
command to backup all devices, using "start of today" as the timestamp basis:
ipf-netcfgbu backup --force
To backup only those devices whose configurations have actually changed since "start of today":
ipf-netcfgbu backup
To save these configurations into your remote git repository:
ipf-netcfgbu vcs save
Installation
This package is not yet in PyPi. To install:
pip install ipf-netcfgbu@git+https://github.com/jeremyschulman/ipf-netcfgbu.git
Usage
Usage: ipf-netcfgbu [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
backup Backup network configurations.
vcs Version Control System subcommands.
Backup Command
The backup command provides the following options:
Usage: ipf-netcfgbu backup [OPTIONS]
Backup network configurations.
Options:
-C, --config FILENAME
--start-date <DATE-TIME> Identifies the starting timestamp date/time
--end-date <DATE-TIME> Identifies the ending timestamp date/time
--force Force backup of all configs, not just those that
changed
--dry-run Use to see device list that would be backed up
--filters TEXT Override the `filters` option in the config file
--help Show this message and exit.
The start-date
and end-date
syntax follows values allowed by the Maya package. For example
you can use expressions like "2 days ago" or explicit dates like "2020-sep-16". You can
also provide a time with the date, for example "yesterday noon" or "2020-sep-16 2:30 pm"
The filters
enables any IP Fabric allowable API filter; the expression syntax
is defined in the aio-ipfabric
filters
module. Here are some examples:
# Hostname starts with "abc"
--filters 'hostname =~ "abc.*"'
# Site is "atl" or Hostname contains the substring "sw2"
--filters "or(site = atl, hostname has sw2)"
# Either:
# (a) Site is "atl" and Hostname contains subscript "core"
# (b) Site is "chc" and Hostname ends in "club-switch21" or "club-switch22"
--filters 'or(and(site = atl, hostname has core), and(site = chc, hostname =~ ".*club-switch2[12]"))'
More docs on that comming soon. Ask for help via github issue if you need.
Configuration File
The ipf-netcfgbu
looks for a TOML based configuration file in one of the following places
- As specified by the
-C
option - As specified by the
IPFNETCFGBU_CONFIGFILE
enviornment variable - $PWD/ipfnetcfgbu.toml
See Example: ipfnetcfgbu.toml
The configuration file has the following sections:
defaults
config_dir
- The local filesystem directory where the network configuration files will be stored after they are retrieved from IP Fabric.
ipfabric
credentials.username
- The IP Fabric login user-namecredentials.password
- The IP Fabric login passwordcredentials.token
- The IP Fabric authentication token
NOTE: Either the token
or the (username
, password
) options must be provided.
server_url
- The HTTPS URL to the IP Fabric systemfilters
- A string representing an IP Fabric filter expression used to limit the device records retrieved from IP Fabric that are used as the inventory for backup purposes. If nofilters
is provided, then all devices will be scoped for backup.strip_hostname_domains
- A list of string values that are domain-name suffix values you want to remove from the IP Fabric device stored hostname value. In some device cases, NX-OS for example, the IP Fabric system stores the device FQDN.
git
This is the same configuration structure as netcfgbu
.
See docs for details.
loggers
This is the same configuration structure as netcfgbu
.
See example ipfnetcfgbu.toml file for details.
Environment Variables
IPFNETCFGBU_CONFIGFILE
- filepath to your configuration file
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ipf_netcfgbu-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7756d995dad5be2236ff63dd3cdd35d531b51a328603f0cbbbe92d40af13674 |
|
MD5 | b917fcbd19946918dc750fa6703c1632 |
|
BLAKE2b-256 | ba8939d1bfcb11e5e59013dcc60dd4fc9c1b5d736b007a7240d2a8ed510c7399 |