device_hiera
Version information
This version is compatible with:
- Puppet Enterprise >= 2015.0.0
- Puppet >= 4.0.0
Start using this module
Add this module to your Puppetfile:
mod 'jorhett-device_hiera', '0.3.0'
Learn more about managing modules with a PuppetfileDocumentation
device_hiera
Table of Contents
- Overview
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with device_hiera
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
- 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
andinterface
)
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.
##2015-12-16 - Release 0.2.3 ###Summary ####Features
- Changed to Apache-2.0 License
- New 'has_facter' fact, the absence of which reliably identifies "puppet device" invocations
- New custom resources network_interfaces (for Cisco NX-OS)
####Bugfixes
- Don't use default description on custom ports
- (for Cisco) Don't pass in VLAN parameters which won't be used
##2015-12-16 - Release 0.2.0 ###Summary
Altered configuration to generate any resource type based on Hiera input.
Define the list of resources using resources
array parameter
####Features
- Support all resource types with defaults and hash merging
##2015-12-15 - Release 0.1.1 ###Summary
Added support for VLAN hash merge from Hiera
####Features
- VLAN hash merge to combine all local VLANs
####Bugfixes
- Return slots to an array so as to allow multiple line definitions
##2015-12-03 - Release 0.1.0 ###Summary
Allow DRY configuration of network interface ports from Hiera.
####Features
- Default interface configuration
- Short list of Slots/Ports to be configured
- Small (DRY) list of customized ports
Dependencies
- puppetlabs/stdlib (>= 4.0.0)
Copyright © 2015 Net Consonance Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.