example42/puppet-network

Name: puppet-network

Owner: Example42

Description: Puppet module to manage networking on Debian and RedHat. Based on stdmod naming standards

Created: 2013-11-18 18:55:14.0

Updated: 2017-12-15 01:00:07.0

Pushed: 2018-01-03 21:51:24.0

Homepage: null

Size: 339

Language: Puppet

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

network

Build Status

Table of Contents
  1. Overview
  2. Module Description
  3. Setup
  4. Usage
  5. Hiera examples
  6. Operating Systems Support
  7. Development
Overview

This module configures network interfaces and parameters.

Module Description

The module is based on stdmod naming standards version 0.9.0.

Refer to http://github.com/stdmod/ for complete documentation on the common parameters.

Setup
Resources managed by network module
Setup Requirements
Beginning with module network

The main class arguments can be provided either via Hiera (from Puppet 3.x) or direct parameters:

    class { 'network':
      parameter => value,
    }

The module provides a generic network::conf define to manage any file in the config_dir_path which is:

On 'Debian' osfamily: '/etc/network',

On 'Redhat' osfamily: '/etc/sysconfig/network-scripts',

On 'Suse' osfamily: '/etc/sysconfig/network',

    network::conf { 'if-up.d/my_script':
      template => 'site/network/my_script',
    }

The module provides a cross OS compliant define to manage single interfaces: network::interface

IMPORTANT NOTICE: On Debian if you use network::interface once you must provide ALL the network::interface defines for all your interfaces

To configure a dhcp interface

    network::interface { 'eth0':
      enable_dhcp => true,
    }

To configure a static interface with basic parameters

    network::interface { 'eth1':
      ipaddress => '10.42.42.50',
      netmask   => '255.255.255.0',
    }
Usage

You have different possible approaches in the usage of this module. Use the one you prefer.

You can then add routes to this routing table:

   network::route { 'eth1':
     ipaddress => [ '192.168.22.0', ],
     netmask   => [ '255.255.255.0', ],
     gateway   => [ '192.168.22.1', ],
     table     => [ 'vlan22' ],
   }

If adding routes to a routing table on an interface with multiple routes, it is necessary to specify false or 'main' for the table on the other routes. The 'main' routing table is where routes are added by default. E.g. this:

   network::route { 'bond0':
     ipaddress => [ '192.168.2.0', '10.0.0.0', ]
     netmask   => [ '255.255.255.0', '255.0.0.0', ],
     gateway   => [ '192.168.1.1', '10.0.0.1', ],
   }

   network::route { 'bond0':
     ipaddress => [ '192.168.3.0', ],
     netmask   => [ '255.255.255.0', ],
     gateway   => [ '192.168.3.1', ],
     table     => [ 'vlan22' ],
   }

would need to become:

   network::route { 'bond0':
     ipaddress => [ '192.168.2.0', '10.0.0.0', '192.168.3.0', ]
     netmask   => [ '255.255.255.0', '255.0.0.0', '255.255.255.0', ],
     gateway   => [ '192.168.1.1', '10.0.0.1', '192.168.3.1', ],
     table     => [ false, false, 'vlan22' ],
   }

The same applies if adding scope, source or gateway, i.e. false needs to be specified for those routes without values for those parameters, if defining multiple routes for the same interface.

The following definition:

   network::route { 'bond2':
     ipaddress => [ '0.0.0.0', '192.168.3.0' ]
     netmask   => [ '0.0.0.0', '255.255.255.0' ],
     gateway   => [ '192.168.3.1', false ],
     scope     => [ false, 'link', ],
     source    => [ false, '192.168.3.10', ],
     table     => [ 'vlan22' 'vlan22', ],
   }

yields the following routes in table vlan22:

   # ip route show table vlan22
   default via 192.168.3.1 dev bond2
   192.168.3.0/255.255.255.0 dev bond2 scope link src 192.168.3.10

Normally the link level routing (192.168.3.0/255.255.255.0) is added automatically by the kernel when an interface is brought up. When using routing rules and routing tables, this does not happen, so this route must be added manually.

Hiera examples

Here are some examples of usage via Hiera (with yaml backend).

Main class settings:

network::hostname: 'web01'
network::gateway: 192.168.0.1 # Default gateway (on RHEL systems)
network::hiera_merge: true # Use hiera_hash() instead of hiera() to resolve the values for the following hashes

Configuration of interfaces (check `network::interface` for all the available params.

Single interface via dhcp:

network::interfaces_hash:
  eth0:
    enable_dhcp: true

Bond interface:

eth0:
  method: manual
  bond_master: 'bond3'
  allow_hotplug: 'eth0'
  manage_order: '08'
eth1:
  method: manual
  bond_master: 'bond3'
  allow_hotplug: 'eth1'
  manage_order: '08'
bond3:
  ipaddress: "10.0.28.10"
  netmask: '255.255.248.0'
  gateway: "10.0.24.1"
  dns_nameservers: "8.8.8.8 8.8.4.4"
  dns_search: 'my.domain'
  bond_mode: 'balance-alb'
  bond_miimon: '100'
  bond_slaves: []

Configuration of multiple static routes (using the `network::route` define, when more than one route is added the elements of the arrays have to be ordered coherently):

network::routes_hash:
  eth0:
    ipaddress:
      - 99.99.228.0
      - 100.100.244.0
    netmask:
      - 24
      - 22
    gateway:
      - 192.168.0.1
      - 174.136.107.1

Configuration of multiple static routes (using the newer `network::mroute` define) you can specify as gateway either a device or an IP:

network::mroutes_hash:
  eth0:
    routes:
      99.99.228.0/24: eth0
      100.100.244.0/22: 174.136.107.1
Operating Systems Support

This is tested on these OS:

Development

Pull requests (PR) and bug reports via GitHub are welcomed.

When submitting PR please follow these quidelines:

When submitting bug report please include or link:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.