Forge Home

device_hiera

Utilize Hiera hierachies and default resource parameters for DRY network device configuration.

8,228 downloads

7,806 latest version

3.8 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.3.0 (latest)
  • 0.2.0
released Dec 19th 2015
This version is compatible with:
  • Puppet Enterprise >= 2015.0.0
  • Puppet >= 4.0.0

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'jorhett-device_hiera', '0.3.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add jorhett-device_hiera
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install jorhett-device_hiera --version 0.3.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

jorhett/device_hiera — version 0.3.0 Dec 19th 2015

device_hiera

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with device_hiera
  4. Usage - Configuration options and additional functionality
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module

Overview

TL;DR - DRY network device configuration

Network device configuration (e.g. Cisco, Juniper, Arista, etc) using individual resources is messy and repetitive. This module takes advantage of Hiera hierarchies and hash merging to simplify and centralize network device configuration.

This module can reduce the configuration of a distribution campus switch environment from thousands of lines to a few dozen.

Module Description

Device Hiera makes uses of Hiera data and Hiera hierarchies to provide complete network device configurations with a DRY and minimal data input format. This module does no implementation, it simply utilizes Hiera's hash merging capabilities to creates the appropriate device-specific resources.

Setup

No setup required other than

  • define the Hiera data for each type as documented
  • ensure that you've installed modules which provide the device resource you want (e.g. anything other than vlan and interface)

Setup Requirements

Define Hiera data as documented here or in the module examples.

Usage

List the resource types you wish to load from Hiera data.

  • interfaces to provide slots and port ranges (notice plural)
  • vlan to manage vlans
  • ...any other type provided by modules you have installed

Declare the base class, and list the resource types which should be used from Hiera.

classes:
  - device_hiera

device_hiera::resources:
  - vlan
  - interfaces

For each resource type you can define defaults which will be used if not overridden in the specific definition. For example, interface definition:

device_hiera::defaults::interface:
  description  : 'Default interface configuration'
  mode         : 'dynamic auto'
  encapsulation: 'negotiate'
  access_vlan  : '200'

Interfaces are special because we provide the ability to list slots in the chassis along with a list of ports, which obviously the interface parameter doesn't handle.

First define an array which contains a single key of the slot name, and a value containing a single range of ports MIN-MAX. The slot can defined multiple times.

device_hiera::interfaces::ports:
  - 'FastEthernet0'     : '2-23'
  - 'GigabitEthernet1/0': '1-2'
  - 'GigabitEthernet1/0': '5-6'

Then define the custom parameters for any port with a non-default configuration. These ports can fall inside or outside of the slots and ranges supplied above.

device_hiera::interfaces::custom:
  'GigabitEthernet1/0/3':
     description  : 'Uplink to core'
     mode         : 'trunking'
     encapsulation: 'dot1q'
     native_vlan  : 200

Any other resource type can also be created with parameters supplied in a hash under their title. They can likewise fall back on default values for the type.

Values for the resource types and parameters should be taken from the module which provides the resource type in question. Documentation for the vlan type used below can be found at https://docs.puppetlabs.com/references/latest/type.html#vlan

device_hiera::resources:
  - vlan

device_hiera::defaults::vlan:
  ensure: present

device_hiera::vlan:
  200: 
    description: 'vlan200_Funtime :'
  400: 
    description: 'vlan400_fail'

For another example, if you have installed the puppetlabs/ciscopuppet module, you could use this for OSPF configuration:

device_hiera::resources:
  - cisco_interface_ospf

device_hiera::defaults::cisco_interface_ospf:
  ensure: present
  cost  : 200
  ospf  : default

device_hiera::cisco_interface_ospf:
  'Ethernet1/2 default': 
    area: '172.16.0.0'

What device_hiera affects

  • Uses Hiera hierarchy and data merging to simplify multiple device configuration
  • Allows definition of port defaults which reduces repetitive data entry (DRY)
  • Can be used with any network device vendor

...etc

Limitations

You will need to include any vendor-specific modules necessary to implement the resources created by device_hiera.

Development

Any and all patches or features welcome and encouraged.