Skip to main content

Stockpiler

Stockpiler gathers network device configurations and stores them in a local Git repository.

Stockpiler utilizes Nornir, Netmiko, and GitPython for a fully self-contained backup solution, and has been tested to function on Linux, MacOS, and Windows.

Using Stockpiler

Once installed in an environment Stockpiler can be called directly/ad-hoc, or more commonly, by a Cron Job or other system scheduling tool such as creating a Systemd service.

The most basic execution of Stockpiler would be simply executing the following:

stockpiler

This will read the credentials from the Inventory or the environment, then attempt a backup of devices in the Nornir Inventory at /etc/stockpiler/inventory and put the resultant backups into a Git repository in /opt/stockpiler.

However, there are many configuration options available as well to specify Inventory location, provide custom credentials, utilize a SOCKS proxy, and so forth.

Another, more complex execution example could be:

 stockpiler \
 --inventory /home/brett/mah_inventory \
 --output /home/brett/stockpiler_backups \
 --proxy localhost:8000 \
 --log_level DEBUG \
 --logging_dir /home/brett/stockpiler_logs \
 --prompt_for_credentials

See stockpiler --help for full command information.

Credentials

By default, Stockpiler will look in the follwoing three Environment Variables for the username/password/enable_password to use:

  • STOCKPILER_USER
  • STOCKPILER_PW
  • STOCKPILER_ENABLE

Note that if STOCKPILER_ENABLE is not set, Stockpiler will utilize the STOCKPILER_PW for both values.

In addition, if these values are not set, you must tell Stockpiler to prompt you for credentials with the argument --prompt_for_credentials. By default it will not do so, as it is intended to be run in a non-interactive scenario, i.e. by a Cron job, and will simply raise an IOError and exit.

Configuration

As Stockpiler utilizes Nornir for the underlying inventory and task handling, see the Nornir documentation for more information on creating an inventory file or your configuration options

While we have provided a simple nornir_conf.yaml file, you are welcome to provide your own or customize the one provided by the package. See the Nornir documentation on Configuration for more information on the options available to you.

If you are using Windows (or wish to host your inventory in a different location than /etc/stockpiler/inventory), you will need to create a custom Nornir config file with your inventory paths.

Installation

Notes:

  1. Stockpiler utilizes a very recent release of Netmiko. This requires some specific handling (as outlined below), until other libraries update their dependencies.
  2. Stockpiler requires Python 3.7 or higher.
  3. Stockpiler utilizes Python Virtual Environments for isolation of the code/environment.

Installation Steps

  1. Create a directory for the Stockpiler virtual environment: mkdir stockpiler
  2. Create a virtual environment in that directory: python3 -m venv stockpiler
  3. Navigate to the new directory and activate it: cd stockpiler;source bin/activate
  4. Install Stockpiler: pip install stockpiler
  5. Edit the dependencies, this will require you to find the Napalm and Nornir METADATA files in your virtual environment:
    • Paths should be similar to:
      • lib/python3.7/site-packages/napalm-2.5.0.dist-info/METADATA
    • In each file, find the lines similar to below that reference Netmiko:
      • Requires-Dist: netmiko (==2.4.2)
    • Edit it to include 3.0.0, similar to the below:
      • Requires-Dist: netmiko (>=2.4.2)

Metadata

Release files for stockpiler 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stockpiler 0.5.3
File Size Uploaded
stockpiler-0.5.3.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stockpiler 0.5.3
File Interpreter ABI Platform
stockpiler-0.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / stockpiler-0.5.3.tar.gz

Download URL stockpiler-0.5.3.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b26e83349ced105cb8cc1faf32ee73c4b2924f190f50abce9e37c4c989ef6189
BLAKE2b-256 checksum
How to use checksums
82ccf6c6a7980de3ad4d372b412c170cccc0c1aee8e2bff25271ce833da4dfcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / stockpiler-0.5.3-py3-none-any.whl

Download URL stockpiler-0.5.3-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6032812c37d8745f3471caca1e33527e786c4abeadd7b63eaf30e2931fd1e556
BLAKE2b-256 checksum
How to use checksums
bb2f8ead9f4fc38746900cbcfb471d4551e150947118d1910469fcb3d013bb35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.5.3 This release

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page