Giter Club home page Giter Club logo

puppet-network's Introduction

Network module for Puppet

Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores puppetmodule.info docs Apache-2 License

Overview

Manage non-volatile network and route configuration.

Usage

Interface configuration

network_config { 'eth0':
  ensure  => 'present',
  family  => 'inet',
  method  => 'dhcp',
  onboot  => 'true',
  hotplug => 'true',
  options => {'pre-up' => 'sleep 2'},
}

network_config { 'lo':
  ensure => 'present',
  family => 'inet',
  method => 'loopback',
  onboot => 'true',
}

network_config { 'eth1':
  ensure    => 'present',
  family    => 'inet',
  ipaddress => '169.254.0.1',
  method    => 'static',
  netmask   => '255.255.0.0',
  onboot    => 'true',
}

Route configuration

Route resources should be named in CIDR notation. If not, they will not be properly mapped to existing routes and puppet will apply them on every run. Default routes should be named 'default'.

For Debian:

network_route { '172.17.67.0/24':
  ensure    => 'present',
  gateway   => '172.18.6.2',
  interface => 'vlan200',
  netmask   => '255.255.255.0',
  options   => 'table 200',
}

For RedHat Enterprise:

network_route { '172.17.67.0/24':
  ensure    => 'present',
  gateway   => '10.0.2.2',
  interface => 'eth0',
  netmask   => '255.255.255.0',
  network   => '172.17.67.0',
  options   => 'table 200',
}
network_route { 'default':
  ensure    => 'present',
  gateway   => '10.0.2.2',
  interface => 'eth0',
  netmask   => '0.0.0.0',
  network   => 'default'
}
network_route { '10.0.0.2':
  ensure    => 'present',
  network   => 'local',
  interface => 'eth0',
  options   => 'proto 66 scope host table local',
}

For SLES:

network_route { 'default':
  ensure    => 'present',
  gateway   => '10.0.2.2',
  interface => 'eth0',
  netmask   => '0.0.0.0',
  network   => 'default'
}

Create resources on the fly with the puppet resource command:

root@debian-6:~# puppet resource network_config eth1 ensure=present family=inet method=static ipaddress=169.254.0.1 netmask=255.255.0.0
notice: /Network_config[eth1]/ensure: created
network_config { 'eth1':
  ensure    => 'present',
  family    => 'inet',
  ipaddress => '169.254.0.1',
  method    => 'static',
  netmask   => '255.255.0.0',
  onboot    => 'true',
}

# puppet resource network_route 23.23.42.0 ensure=present netmask=255.255.255.0 interface=eth0 gateway=192.168.1.1
notice: /Network_route[23.23.42.0]/ensure: created
network_route { '23.23.42.0':
  ensure    => 'present',
  gateway   => '192.168.1.1',
  interface => 'eth0',
  netmask   => '255.255.255.0',
  options   => 'table 200',
}

Dependencies

This module requires the FileMapper mixin, available at https://github.com/voxpupuli/puppet-filemapper. The network_config type requires the Boolean mixin, available at https://github.com/adrienthebo/puppet-boolean.

The debian routes provider requires the package ifupdown-extra. ifupdown-extra can be installed automatically using the network class. To use it, include it like so in your manifests:

include 'network'

This class also provides fine-grained control over which packages to install and how to install them. The documentation for the parameters exposed can be found here.

Bonding on Debian requires the package ifenslave, which is installed automatically when a bond is defined. This package was renamed in Debian 9, and therefore bonding does not work on Debian versions prior to 9.

Note: you may also need to update your master's plugins (run on your puppet master):

puppet agent -t --noop

Or on puppet 3.8.7/4.x:

puppet plugin download

Contact

puppet-network's People

Contributors

adrienthebo avatar alexjfisher avatar bastelfreak avatar canihavethisone avatar dhoppe avatar dustyhorizon avatar ekohl avatar ericsakowski avatar ffrank avatar igalic avatar imp- avatar jhoblitt avatar jordiclariana avatar juniorsysadmin avatar jyaworski avatar keithward avatar llowder avatar natemccurdy avatar nibalizer avatar rnelson0 avatar rski avatar runejuhl avatar sandra-thieme avatar silug avatar simonhoenscheid avatar smortex avatar treydock avatar vstone avatar wyardley avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-network's Issues

interfaces provider fails when given a second interface to manage

root@jafir:~# puppet agent -t  --trace
info: Retrieving plugin
info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
info: Loading facts in /var/lib/puppet/lib/facter/confenv.rb
info: Loading facts in /var/lib/puppet/lib/facter/bacula.rbinfo: Loading facts in /var/lib/puppet/lib/facter/certname.rbinfo: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rbinfo: Loading facts in /var/lib/puppet/lib/facter/root_home.rbinfo: Loading facts in /var/lib/puppet/lib/facter/lastuser.rbinfo: Loading facts in /var/lib/puppet/lib/facter/haszfs.rbinfo: Loading facts in /var/lib/puppet/lib/facter/systemid.rb
info: Loading facts in /var/lib/puppet/lib/facter/printers.rb
info: Caching catalog for jafir.dc1.puppetlabs.net
info: Applying configuration version 'e4bc986'
notice: /Stage[main]//Node[jafir]/Network_config[vlan1000]/ensure: created
/var/lib/puppet/lib/puppet/provider/network_config/interfaces.rb:175:in `sort'
/var/lib/puppet/lib/puppet/provider/network_config/interfaces.rb:175:in `format_resources'
/var/lib/puppet/lib/puppet/provider/isomorphism.rb:169:in `flush'
/var/lib/puppet/lib/puppet/provider/isomorphism.rb:44:in `flush'
/usr/lib/ruby/1.8/puppet/type.rb:661:in `flush'/usr/lib/ruby/1.8/puppet/transaction/resource_harness.rb:139:in `evaluate'/usr/lib/ruby/1.8/puppet/transaction.rb:49:in `apply'/usr/lib/ruby/1.8/puppet/transaction.rb:84:in `eval_resource'/usr/lib/ruby/1.8/puppet/transaction.rb:104:in `evaluate'/usr/lib/ruby/1.8/puppet/util.rb:484:in `thinmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/1.8/puppet/util.rb:483:in `thinmark'
/usr/lib/ruby/1.8/puppet/transaction.rb:104:in `evaluate'
/usr/lib/ruby/1.8/puppet/transaction.rb:386:in `traverse'
/usr/lib/ruby/1.8/puppet/transaction.rb:99:in `evaluate'
/usr/lib/ruby/1.8/puppet/resource/catalog.rb:141:in `apply'
/usr/lib/ruby/1.8/puppet/configurer.rb:122:in `retrieve_and_apply_catalog'
/usr/lib/ruby/1.8/puppet/util.rb:159:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/1.8/puppet/util.rb:158:in `benchmark'
/usr/lib/ruby/1.8/puppet/configurer.rb:121:in `retrieve_and_apply_catalog'
/usr/lib/ruby/1.8/puppet/configurer.rb:152:in `run'/usr/lib/ruby/1.8/puppet/agent.rb:43:in `run'
/usr/lib/ruby/1.8/puppet/agent/locker.rb:21:in `lock'
/usr/lib/ruby/1.8/puppet/agent.rb:43:in `run'
/usr/lib/ruby/1.8/sync.rb:230:in `synchronize'
/usr/lib/ruby/1.8/puppet/agent.rb:43:in `run'
/usr/lib/ruby/1.8/puppet/agent.rb:95:in `with_client'
/usr/lib/ruby/1.8/puppet/agent.rb:41:in `run'
/usr/lib/ruby/1.8/puppet/application.rb:172:in `call'
/usr/lib/ruby/1.8/puppet/application.rb:172:in `controlled_run'
/usr/lib/ruby/1.8/puppet/agent.rb:39:in `run'
/usr/lib/ruby/1.8/puppet/application/agent.rb:337:in `onetime'
/usr/lib/ruby/1.8/puppet/application/agent.rb:311:in `run_command'
/usr/lib/ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/1.8/puppet/application.rb:416:in `hook'
/usr/lib/ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/1.8/puppet/application.rb:407:in `exit_on_fail'
/usr/lib/ruby/1.8/puppet/application.rb:309:in `run'
/usr/lib/ruby/1.8/puppet/util/command_line.rb:69:in `execute'
/usr/bin/puppet:4
err: /Stage[main]//Node[jafir]/Network_config[vlan1000]: Could not evaluate: undefined method `<=>' for nil:NilClass
notice: Finished catalog run in 4.58 seconds

Remove dependencies

Hi,

I am wondering if the dependencies to adrienthebo/puppet-filemapper and adrienthebo/puppet-boolean are part of the future, or the past of this module. Is this the direction you want to move towards, or something you would get rid of at some point?

I mean, you don't seem to solve anything that can't be solved with templates, and having additional dependencies make this module less clean... hope you agree (and somehow I think you won't xD)

Thanks!

Invalid value for method => loopback

network_config { 'lo':
  ensure => 'present',
  family => 'inet',
  method => 'loopback',
  onboot => 'true',
}
root@foo:~# ralsh network_config lo | puppet apply
Parameter method failed: Invalid value "loopback". Valid values are static, manual, dhcp.  at line 6

It seems method => loopback isn't supported at all?

Multiple 'up' lines in options hash

Debian allows multiple 'up' lines in iface stanza. They will be executed in the order written to the file.

But this isn't possible as there can only be one key in the options hash.

auto line is removed with reimplement_debian_parsing

In deploying a full replacement of the interfaces file with 3 interfaces defined, I either loose the eth1 "auto" inclusion, or loose all my interfaces in the auto line post puppet run.

(private_interface is eth0, external_interface is eth1)

network_config { "$::private_interface":
ensure => 'present',
hotplug => false,
family => 'inet',
ipaddress => "$::controller_node_address",
method => 'static',
netmask => "$::controller_node_netmask",
options => {
"dns-search" => "$::domain_name",
"dns-nameservers" => "$::cobbler_node_ip",
"gateway" => "$::node_gateway"
},
onboot => 'true',
notify => Service['networking'],
}

network_config { 'lo':
ensure => 'present',
hotplug => false,
family => 'inet',
method => 'loopback',
onboot => 'true',
notify => Service['networking'],
}

network_config { "$::external_interface":
ensure => 'present',
hotplug => false,
family => 'inet',
method => 'static',
ipaddress => '0.0.0.0',
netmask => '255.255.255.255',
onboot => 'true',
notify => Service['networking'],
}

service {'networking':
ensure => 'running',
restart => 'true',
}

produces something like:

root@compute1:~# cat /etc/network/interfaces

HEADER: This file is is being managed by puppet. Changes to

HEADER: interfaces that are not being managed by puppet will persist;

HEADER: however changes to interfaces that are being managed by puppet will

HEADER: be overwritten. In addition, file order is NOT guaranteed.

HEADER: Last generated at: Thu Jan 10 05:53:41 +0000 2013

The following interfaces will be started on boot

auto

The following interfaces are hotpluggable

allow-hotplug

iface eth0 inet static
netmask 255.255.255.0
address 192.168.25.10
dns-nameservers 192.168.25.254
dns-search dmz25.lab
gateway 192.168.25.1

iface eth1 inet static
netmask 255.255.255.255
address 0.0.0.0
down ifconfig eth1 down
up ifconfig eth1 up

iface lo inet loopback

Malformed debian interfaces file - duplicated iface lines?

We have an issue where the network_config is giving a malformed debian interfaces file when reading the interfaces file.

Ive added some additional debugging into the code and narrowed it down to the code thinking it has seen an interface line twice

 (
        if match = line.match(/^iface\s+(\S+)\s+(\S+)\s+(\S+)/)
...
          raise_malformed if Instance[name] and Instance[name].family
)

However, the line only occurs once in the file but seems to be seen twice.

It also does not happen on a regular basis, running it manually using puppet agent --test seems to work every time, but automated runs will fail.

puppet config:

        network_config { 'lo:park':
                ensure    => 'present',
                family    => 'inet',
                ipaddress => 'x.x.x.x',
                method    => 'static',
                netmask   => '255.255.255.255',
                onboot    => 'true',
        }

        network_config { 'lo:mta':
                ensure    => 'present',
                family    => 'inet',
                ipaddress => 'x.x.x.x',
                method    => 'static',
                netmask   => '255.255.255.255',
                onboot    => 'true',
        }

        network_config { 'lo:inbound':
                ensure    => 'present',
                family    => 'inet',
                ipaddress => 'x.x.x.x',
                method    => 'static',
                netmask   => '255.255.255.255',
                onboot    => 'true',
        }

Note, however that these add fine, and the error is related to the eth0 line which is configured on the server rather than puppet:

iface eth0 inet static
address x.x.x.x
netmask 255.255.255.0
gateway x.x.x.x

As I mentioned this does work some of the time, so the file has been modified to look like this:

# HEADER: This file is is being managed by puppet. Changes to
# HEADER: interfaces that are not being managed by puppet will persist;
# HEADER: however changes to interfaces that are being managed by puppet will
# HEADER: be overwritten. In addition, file order is NOT guaranteed.
# HEADER: Last generated at: Thu Jun 13 10:48:50 +1200 2013


auto eth0 lo:park lo:inbound lo:mta

allow-hotplug lo:park lo:inbound lo:mta

iface eth0 inet static
address x.x.x.x
netmask 255.255.255.0
gateway x.x.x.x

iface lo inet loopback

iface lo:park inet static
address x.x.x.x
netmask 255.255.255.255


iface lo:inbound inet static
address x.x.x.x
netmask 255.255.255.255

iface lo:mta inet static
address x.x.x.x
netmask 255.255.255.255

My extra debugging determined that the line which originally set Instance[name] and Instance[name].family was:
iface eth0 inet static
and the line being processed when the if statement is tripped is:
iface eth0 inet static

While configuration checked interface incorrectly marked as changed

OS: RedHat
CHANGES TO CONFIGURATION: only by puppet

LOG:
...
/Network_config[bond0.126:111]/family: family changed '' to 'inet'
/Network_config[bond0.126:111]/onboot: onboot changed 'true' to 'true'
Info: FileBucket adding {md5}2ace49d5d0d14c1220b6d8a6b0cb0e72
Info: /Network_config[bond0.126:111]: Scheduling refresh of Service[network]
Info: /Network_config[bond0.126:111]: Scheduling refresh of Service[network]
...

Network refresh makes server unavailible for a couple seconds every puppet lunch without any changes to configuration.

network_route does not catch nor fix invalid routes

I had accidently set:
other routes.. and then:
network_route { '10.97.0.0/16':
ensure => 'present',
gateway => '192.168.22.50',
interface => 'eth0',
netmask => '8',
network => '10.97.0.0'
}

Which wrote this in the route-eth0 file:
10.0.0.0/255.0.0.0 via 192.168.22.1 dev eth0
10.0.0.0/255.255.0.0 via 192.168.22.50 dev eth0
192.168.0.0/255.255.0.0 via 192.168.22.1 dev eth0
default via 192.168.22.50 dev eth0

When I then corrected it to netmask => 16 and network 10.97.0.0 - it spit out errors, instead of fixing it:
Could not evaluate: undefined method `[]' for nil:NilClass

bond config in CentOS 6 work with this

Hello,

    # Bonded master interface - static:
    # local
    network::bond { 'bond0':
        onboot          => 'yes',
        netmask         => '255.255.0.0',
        ipaddress       => '172.16.1.101',
        family          => 'inet',
        ensure          => present,
        method          => 'none',
        gateway         => $defaultgateway,
        bondingopt  => 'mode=balance-rr miimon=100',
        hotplug         => 'no',
        slaves          => ['eth0','eth3',],
    }
    # redondance
    network::bond { 'bond1':
        onboot          => 'yes',
        netmask         => '255.255.0.0',
        ipaddress       => '172.18.1.101',
        family          => 'inet',
        ensure          => present,
        method          => 'none',
        gateway         => '',
        bondingopt  => 'mode=balance-rr miimon=100',
        hotplug         => 'no',
        slaves          => ['eth1','eth2',],
    }

This example work with this code

I have change

# = Define: network::bond
#
# Instantiate cross-platform bonded interfaces
#
# == Parameters
#
#
# == Examples
#
#
#        network::bond { 'bond0':
#            ipaddress => '172.16.1.2',
#            netmask     => '255.255.128.0',
#            ensure     => present,
#            slaves     => ['eth0', 'eth1'],
#        }
#
# == See also
#
# * Linux Ethernet Bonding Driver HOWTO, Section 2 "Bonding Driver Options" http://www.kernel.org/doc/Documentation/networking/bonding.txt
#
define network::bond(
    $slaves,
    $ensure     = present,
    $ipaddress = undef,
    $netmask     = undef,
    $method     = undef,
    $family     = undef,
    $onboot     = undef,
    $gateway        = undef,
    $bondingopt = undef,
    $hotplug        = undef,
) {

    require network::bond::setup

    kmod::alias { $name:
        source => 'bonding',
        ensure => $ensure,
    }

    case $osfamily {
        Debian: {
            network::bond::debian { $name:
                slaves      => $slaves,
                ensure      => $ensure,
                ipaddress => $ipaddress,
                netmask  => $netmask,
                family      => $family,
                onboot      => $onboot,
                require  => Kmod::Alias[$name],
            }
        }
        RedHat: {
            network::bond::redhat { $name:
                slaves          => $slaves,
                ensure          => $ensure,
                ipaddress   => $ipaddress,
                netmask         => $netmask,
                family          => $family,
                onboot          => $onboot,
                method          => $method,
                gateway         => $gateway,
                bondingopt  => $bondingopt,
                hotplug         => $hotplug,
                require         => Kmod::Alias[$name],
            }
        }
    }
}

I have change network::bond::redhat with

# = Define: network::bond::redhat
#
# Instantiate bonded interfaces on RedHat based systems.
#
# ==
define network::bond::redhat(
    $slaves,
    $ensure         = present,
    $ipaddress  = undef,
    $netmask        = undef,
    $gateway        = '',
    $method         = undef,
    $family         = undef,
    $onboot         = undef,
    $bondingopt = undef,
    $hotplug        = undef,
) {

    network_config { $name:
        ensure      => $ensure,
        ipaddress => $ipaddress,
        netmask     => $netmask,
        family      => $family,
        onboot      => $onboot,
        method      => $method,
        hotplug     => $hotplug,
        options     => {
            'GATEWAY'               => $gateway,
            'BONDING_OPTS'  => $bondingopt,
        },
    }

    file { "/etc/sysconfig/network-scripts/ifcfg-$name": 
        ensure => present,
        mode        => '0644',
        owner    => 'root',
        group    => 'root',
        require => Network_config[$name],
    }

    network::slave::redhat { $slaves:
        ensure => $ensure,
        master => $name,
        require => [ Network_config[$name], File["/etc/sysconfig/network-scripts/ifcfg-$name"] ]
    }
}

And i add network::slave::redhat

# = Define: network::bond::redhat::slave
#
# Instantiate bonded interfaces on RedHat based systems.
#
# ==
define network::slave::redhat (
    $master,
    $ensure         = present,
    $onboot         = true,
    $userctl        = 'no',
    $bootproto  = 'none',
    $hotplug        = 'no',
) {
    network_config { $name:
        ensure => $ensure,
        onboot => $onboot,
        method      => $bootproto,
        hotplug     => $hotplug,
        options => {
            'MASTER'    => $master,
            'SLAVE'     => 'yes',
            'HWADDR'    => getvar("::macaddress_$name"),
            'USERCTL'       => $userctl,
        }
    }

    file { "/etc/sysconfig/network-scripts/ifcfg-$name": 
        ensure => present,
        mode        => '0644',
        owner    => 'root',
        group    => 'root',
        require => Network_config[$name],
    }

}

network_route Error on CentOS

The first run of network_route on CentOS create a file in /etc/sysconfig/network-scripts with name
route-eth0
with some comments and all routes I set in the manifest. The 2nd run of the puppet agent
brings
Notice: /Stage[main]/Servernetz::Routen/Network_route[10.0.38.0]/ensure: created
Error: /Stage[main]/Servernetz::Routen/Network_route[10.0.38.0]: Could not evaluate: undefined method `[]' for nil:NilClass
This for all routes and nothing changes in the file. This behave is not, if the file does not exists or if there only comments in the file.
Any Idea?
plugin module 0.4.1
CentOs 6.5 x86_64
Puppet 3.4.2
rubyversion 1.8.7

Regards
CMe

Deprecate/Remove :family property, add :ip6address property, add :ipv6 and :ipv4 features

As exposed by #9 and as demonstrated as a byproduct of #13, the :family property doesn't actually make sense. Both Redhat and Debian both treat ipv6 configuration as separate from ipv4, and #9 demonstrates that in fact you can't have an IPv6 interface without an IPv6 interface.

The summary of this is that the :family property needs to be deprecated and removed. In place of that, features should be used for this sort of thing. the :ipv4 feature will be a requirement for :ipaddress and :netmask, and the :ipv6 feature will be a requirement for the :ip6address property.

Bogus error - Could not evaluate: Unable to support multiple interfaces in a single file

OS: CentOS 6.3
Puppet version (client): 2.7.17
Puppet version (master): 3.0.0
puppet-network version: 0.4.0

I got the following error in my Puppet logs, but the interface is only defined once in the manifest. This is an intermittent error, it does not occur in a reproducible fashion AFAICT.

Sun May 19 03:39:24 +0000 2013 /Network_config[lo:6] (err): Could not evaluate: Unable to support multiple interfaces [lo:6,lo:6] in a single file /etc/sysconfig/network-scripts/ifcfg-lo:6

After which a new error popped up (although the odd "method static->loopback" behavior always happens even on "clean" runs):

Sun May 19 04:09:24 +0000 2013 /Network_config[lo:6]/method (notice): method changed 'static' to 'loopback'
Sun May 19 04:09:24 +0000 2013 Puppet::Type::Network_config::ProviderRedhat (err): redhat is in an error state, refusing to flush file /etc/sysconfig/network-scripts/ifcfg-lo:6

Here's the manifest that is generating the ifcfg files.

class proxy::dev {

  network_config { 'lo:1':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.18',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
    }

  network_config { 'lo:2':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.19',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
  }

  network_config { 'lo:3':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.20',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
  }

  network_config { 'lo:4':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.21',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
  }

  network_config { 'lo:5':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.22',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
  }

  network_config { 'lo:6':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.23',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
  }

  network_config { 'lo:7':
    ensure      => 'present',
    family      => 'inet',
    method      => 'loopback',
    ipaddress   => '10.12.16.24',
    netmask     => '255.255.255.255',
    onboot      => 'true',
    reconfigure => 'true',
  }

}

The ifcfg files created all look identical except for the fourth octet of the IP and the virtual interface identifier:

IPADDR=10.12.16.##
DEVICE=lo:#
ONBOOT=yes
BOOTPROTO=loopback
HOTPLUG=yes
NETMASK=255.255.255.255

Malformed debian interfaces file error when running puppet daemon

I'm observing some unusual behavior with Puppet is version 2.7.18 running on Ubuntu 12.10.

When puppet is run manually with puppet agent -t or if the puppet daemon is restarted then the manifests runs fine, but after a few runs it starts throwing:

Could not prefetch network_config provider 'interfaces': Malformed debian interfaces file; cannot instantiate network_config resources

I suspect on machines configured to run the puppet agent from a cron job will not throw this error.

This is similar to what's reported in #44

Unable to find property, Puppet 3.2.3

Tested:

network_config { 'eth1':
ensure => 'present',
family => 'inet',
ipaddress => '169.254.0.1',
method => 'static',
netmask => '255.255.0.0',
onboot => 'true',
}

within my nodes.pp file under my host.

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not autoload puppet/type/network_config: no such file to load -- puppet/property/boolean on node myhost.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I am running puppet 3.2.3

I have the boolean module installed.

Looks like it is setup on the host in:

/var/lib/puppet/lib/puppet/property/boolean.rb

Could not autoload puppet/provider/network_config/interfaces: no such file to load -- puppetx/filemapper

I installed the package by calling puppet module install adrien-network
I've added a simple static entry to a node:

network_config { 'lo':
    ensure => 'present',
    family => 'inet',
    method => 'loopback',
    onboot => 'true',
}

deployment fails with the following error:

Could not autoload puppet/provider/network_config/interfaces: no such file to load -- puppetx/filemapper
Could not autoload puppet/type/network_config: Could not autoload puppet/provider/network_config/interfaces: no such file to load -- puppetx/filemapper
Could not autoload puppet/type/network_config: Could not autoload puppet/provider/network_config/interfaces: no such file to load -- puppetx/filemapper on node xxxx

filemapper is installed inside /etc/puppet/modules/filemapper

I'd be happy to help debug the problem. I'm using puppet 3.4.3 & puppet-master 3.4.3.

List of installed packages:
$ sudo puppet module list
/etc/puppet/modules
โ”œโ”€โ”€ adrien-boolean (v1.0.1)
โ”œโ”€โ”€ adrien-filemapper (v1.1.2)
โ”œโ”€โ”€ adrien-network (v0.4.1)

network_config should support vlan interfaces

It's highly desirable to be able to configure tagged vlan interfaces for a multiple of reasons but in particular when configuring a host to act as a Linux kernel based hypervisor. In the specific hypervisor scenario (under linux) there is normally a chain of interfaces like:

eth0 (raw interface) -> eth0.100 (802.1q tagged interfaces) -> br100 (bridge interface)

or

eth0/eth1/etc. (raw interfaces) -> bond0 (bond interface) -> eth0.100 (802.1q tagged interfaces) -> br100 (bridge interface)

The $::osfamily == debian and redhat configuration file approach for modeling the the relationship of the raw interfaces and the vlan interface are flexible but there is at least one syntax that is fairly similar between them.

On redhat, the ifcfg configuration file DEVICE variable provides both the name of the parent raw device and the vlan tag ID. The VLAN variable also needs to be declared to invoke this magic device name parsing (it has not be tested if it it works without doing this but the VLAN variable is required per the rhel documenation)

DEVICE=ethX.192
..
VLAN=yes

(from: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-networkscripts-interfaces_802.1q-vlan-tagging.html)

On debian, the iface declaration seems to declare the vlan tag (similar to the redhat DEVICE variable) but doesn't auto-magically seem to imply the parent raw device. A separate sub declaration of vlan-raw-device is needed.

iface eth0.110 inet manual
        vlan-raw-device eth0

(from: http://wiki.debian.org/NetworkConfiguration#Howto_use_vlan_.28dot1q.2C_802.1q.2C_trunk.29_.28Etch.2C_Lenny.29)

allow-hotplug section mangles interfaces file

The odd handling of allow-hotplug and allow-auto sections is causing those values to be improperly flushed.

root@ubuntu:/vagrant/puppet/manifests# puppet apply --trace /vagrant/puppet/manifests/test.pp`
 
Error: Could not prefetch network_config provider 'interfaces': undefined method `[]' for nil:NilClass
/etc/puppet/modules/network/lib/puppet/provider/network_config/interfaces.rb:164:in `parse_file'
/etc/puppet/modules/network/lib/puppet/provider/network_config/interfaces.rb:59:in `each'
/etc/puppet/modules/network/lib/puppet/provider/network_config/interfaces.rb:59:in `parse_file'
/etc/puppet/modules/filemapper/lib/puppetx/filemapper.rb:157:in `load_all_providers_from_disk'
/etc/puppet/modules/filemapper/lib/puppetx/filemapper.rb:156:in `each_pair'
/etc/puppet/modules/filemapper/lib/puppetx/filemapper.rb:156:in `load_all_providers_from_disk'
/etc/puppet/modules/filemapper/lib/puppetx/filemapper.rb:93:in `instances'
/etc/puppet/modules/filemapper/lib/puppetx/filemapper.rb:179:in `prefetch'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:284:in `prefetch'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:272:in `prefetch_if_necessary'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:376:in `traverse'
/usr/lib/ruby/vendor_ruby/puppet/transaction.rb:99:in `evaluate'
/usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:144:in `apply'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:122:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:179:in `benchmark'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:178:in `benchmark'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:121:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/configurer.rb:179:in `run'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:265:in `apply_catalog'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:213:in `main'
/usr/lib/ruby/vendor_ruby/puppet/application/apply.rb:146:in `run_command'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:346:in `run'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:438:in `plugin_hook'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:346:in `run'
/usr/lib/ruby/vendor_ruby/puppet/util.rb:500:in `exit_on_fail'
/usr/lib/ruby/vendor_ruby/puppet/application.rb:346:in `run'
/usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:87:in `execute'
/usr/bin/puppet:4
node default {
 
  network_config { 'eth1':
    ensure    => 'present',
    family    => 'inet',
    ipaddress => '192.168.50.2',
    method    => 'static',
    netmask   => '255.255.255.0',
    onboot    => 'true',
  }
 
}
 
root@ubuntu:/vagrant/puppet/manifests# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:d2:e8:7b  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed2:e87b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19865 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10612 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:10252479 (10.2 MB)  TX bytes:1024905 (1.0 MB)
 
eth1      Link encap:Ethernet  HWaddr 08:00:27:9f:a6:0f  
          inet addr:192.168.50.2  Bcast:192.168.50.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe9f:a60f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1403 errors:0 dropped:0 overruns:0 frame:0
          TX packets:695 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:273922 (273.9 KB)  TX bytes:125286 (125.2 KB)
 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:260 (260.0 B)  TX bytes:260 (260.0 B)
 
 
root@ubuntu:/vagrant/puppet/manifests# cat /etc/network/interfaces
# HEADER: This file is is being managed by puppet. Changes to
# HEADER: interfaces that are not being managed by puppet will persist;
# HEADER: however changes to interfaces that are being managed by puppet will
# HEADER: be overwritten. In addition, file order is NOT guaranteed.
# HEADER: Last generated at: Tue Nov 27 01:11:36 +0200 2012
 
 
# The following interfaces will be started on boot
auto eth0 eth1 lo
 
iface eth0 inet dhcp
allow-hotplug true
pre-up sleep 2
 
iface eth1 inet static
netmask 255.255.255.0
address 192.168.50.2
 
iface lo inet loopback

rspec failures on RHEL6

[root@puppetski puppet-network]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.3 (Santiago)
[root@puppetski puppet-network]#
[root@puppetski puppet-network]# git pull
Already up-to-date.
[root@puppetski puppet-network]# git log -1
commit a137f37
Author: Adrien Thebo [email protected]
Date: Wed Mar 13 22:29:58 2013 -0700

Add puppet doc for network::bond

[root@puppetski puppet-network]# bundle exec rspec
.......................................................................................................................*._...............................FF_FFF*FFFFFFF.

Pending:
Puppet::Type::Network_config when validating the attribute options should be a descendant of the KeyValue property
# on conversion to specific type
# ./spec/unit/type/network_config_spec.rb:69
Puppet::Type::Network_config when validating the attribute value ipaddress should fail if a malformed address is used
# implementation of IP address validation
# ./spec/unit/type/network_config_spec.rb:104
Puppet::Type::Network_config when validating the attribute value ipaddress using the inet family should fail when passed an IPv6 address
# implementation of IP address validation
# ./spec/unit/type/network_config_spec.rb:88
Puppet::Type::Network_config when validating the attribute value ipaddress using the inet6 family should fail when passed an IPv4 address
# implementation of IP address validation
# ./spec/unit/type/network_config_spec.rb:98
Puppet::Type::Network_config when validating the attribute value netmask should validate a CIDR netmask
# Not yet implemented
# ./spec/unit/type/network_config_spec.rb:111
Puppet::Type::Network_config when validating the attribute value netmask should fail if an invalid CIDR netmask is used
# implementation of IP address validation
# ./spec/unit/type/network_config_spec.rb:112
network::bond::debian with default bonding params should add a network_config resource for bond0
# rspec-puppet support for unordered hash matching
# ./spec/defines/bond/debian_spec.rb:32
network::bond::debian with non-default bonding params should add a network_config resource for bond0
# rspec-puppet support for unordered hash matching
# ./spec/defines/bond/debian_spec.rb:77

Failures:

  1. network::bond::debian with default bonding params should add a network_config resource for eth0
    Failure/Error: should contain_network_config(slave).with_ensure('absent')
    Puppet::Error:
    Unknown function join at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond/debian.pp:28 on node puppetski.service.datapipe.net

    ./spec/defines/bond/debian_spec.rb:28

  2. network::bond::debian with default bonding params should add a network_config resource for eth1
    Failure/Error: should contain_network_config(slave).with_ensure('absent')
    Puppet::Error:
    Unknown function join at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond/debian.pp:28 on node puppetski.service.datapipe.net

    ./spec/defines/bond/debian_spec.rb:28

  3. network::bond::debian with non-default bonding params should add a network_config resource for eth0
    Failure/Error: should contain_network_config(slave).with_ensure('absent')
    Puppet::Error:
    Unknown function join at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond/debian.pp:28 on node puppetski.service.datapipe.net

    ./spec/defines/bond/debian_spec.rb:73

  4. network::bond::debian with non-default bonding params should add a network_config resource for eth1
    Failure/Error: should contain_network_config(slave).with_ensure('absent')
    Puppet::Error:
    Unknown function join at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond/debian.pp:28 on node puppetski.service.datapipe.net

    ./spec/defines/bond/debian_spec.rb:73

  5. network::bond::debian with non-default bonding params should add a network_config resource for eth2
    Failure/Error: should contain_network_config(slave).with_ensure('absent')
    Puppet::Error:
    Unknown function join at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond/debian.pp:28 on node puppetski.service.datapipe.net

    ./spec/defines/bond/debian_spec.rb:73

  6. network::bond on platform RedHat should create 'network::bond::redhat'
    Failure/Error: should contain_network__bond__redhat('bond0')
    Puppet::Error:
    Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net

    ./spec/defines/bond_spec.rb:30

  7. network::bond on platform RedHat should forward all options to 'network::bond::redhat'
    Failure/Error: should contain_network__bond__redhat('bond0').with(params)
    Puppet::Error:
    Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net

    ./spec/defines/bond_spec.rb:34

  8. network::bond on platform Debian should create 'network::bond::debian'
    Failure/Error: should contain_network__bond__debian('bond0')
    Puppet::Error:
    Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net

    ./spec/defines/bond_spec.rb:42

  9. network::bond on platform Debian should forward all options to 'network::bond::debian'
    Failure/Error: should contain_network__bond__debian('bond0').with(params)
    Puppet::Error:
    Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net

    ./spec/defines/bond_spec.rb:46

  10. network::bond on platform on an unsupported osfamily should fail to compile
    Failure/Error: expect { subject }.to raise_error Puppet::Error, /network::bond does not support osfamily 'SparrowOS'/
    expected Puppet::Error with message matching /network::bond does not support osfamily 'SparrowOS'/, got #<Puppet::Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net>
    # ./spec/defines/bond_spec.rb:54

  11. network::bond configuring the kernel bonding device
    Failure/Error: it { should include_class('network::bond::setup') }
    Puppet::Error:
    Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net
    # ./spec/defines/bond_spec.rb:62

  12. network::bond configuring the kernel bonding device should add a kernel module alias for the bonded device
    Failure/Error: })
    Puppet::Error:
    Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type kmod::alias at /tmp/puppet-network/spec/fixtures/modules/network/manifests/bond.pp:148 on node puppetski.service.datapipe.net
    # ./spec/defines/bond_spec.rb:68

Finished in 3.13 seconds
172 examples, 12 failures, 8 pending

Failed examples:

rspec ./spec/defines/bond/debian_spec.rb:27 # network::bond::debian with default bonding params should add a network_config resource for eth0
rspec ./spec/defines/bond/debian_spec.rb:27 # network::bond::debian with default bonding params should add a network_config resource for eth1
rspec ./spec/defines/bond/debian_spec.rb:72 # network::bond::debian with non-default bonding params should add a network_config resource for eth0
rspec ./spec/defines/bond/debian_spec.rb:72 # network::bond::debian with non-default bonding params should add a network_config resource for eth1
rspec ./spec/defines/bond/debian_spec.rb:72 # network::bond::debian with non-default bonding params should add a network_config resource for eth2
rspec ./spec/defines/bond_spec.rb:29 # network::bond on platform RedHat should create 'network::bond::redhat'
rspec ./spec/defines/bond_spec.rb:33 # network::bond on platform RedHat should forward all options to 'network::bond::redhat'
rspec ./spec/defines/bond_spec.rb:41 # network::bond on platform Debian should create 'network::bond::debian'
rspec ./spec/defines/bond_spec.rb:45 # network::bond on platform Debian should forward all options to 'network::bond::debian'
rspec ./spec/defines/bond_spec.rb:53 # network::bond on platform on an unsupported osfamily should fail to compile
rspec ./spec/defines/bond_spec.rb:62 # network::bond configuring the kernel bonding device
rspec ./spec/defines/bond_spec.rb:64 # network::bond configuring the kernel bonding device should add a kernel module alias for the bonded device
[root@puppetski puppet-network]#

network_* facts don't work on OpenVZ

If OpenVZ (or Virtuozzo) is being used for virtualization the facts network_nexthop_ip, network_primary_interface, and network_primary_ip do not work because the default route is set to a (virtual) ethernet device instead of an IP address.

dev:~# facter virtual
openvz
dev:~# facter interfaces
lo,venet0,venet0_0
dev:~# /sbin/ip route show 0/0
default dev venet0  scope link 

This leads to warnings on every Puppet run:

dev:~# puppet agent --noop -t
Info: Retrieving plugin
Info: Loading facts in /etc/puppet/modules/network/lib/facter/network.rb
[...]
need at least destination address
Could not retrieve network_primary_ip: private method `split' called for nil:NilClass
need at least destination address
Could not retrieve network_primary_ip: private method `split' called for nil:NilClass
need at least destination address
Could not retrieve network_primary_ip: private method `split' called for nil:NilClass
need at least destination address
Could not retrieve network_primary_interface: private method `split' called for nil:NilClass
need at least destination address
Could not retrieve network_primary_interface: private method `split' called for nil:NilClass
need at least destination address
Could not retrieve network_primary_interface: private method `split' called for nil:NilClass
[...]

umask for built module is broken

The umask used while running puppet module build is used in the tarball and can mean that the installed files are unreadable by the puppet user if installed by root. There should be some sort of rake task to ensure that the module is built with the right umask.

setting the default route on Debian

I'm using the following manifest:

network_config { 'lo':
  ensure => 'present',
  family => 'inet',
  method => 'loopback',
  onboot => 'true',
}

network_config { 'eth0':
  ensure    => 'present',
  family    => 'inet',
  ipaddress => '10.4.8.23',
  method    => 'static',
  netmask   => '255.255.0.0',
  onboot    => 'true',
}

network_route { 'default':
  ensure    => 'present',
  gateway   => '10.4.0.1',
  interface => 'eth0',
  netmask   => '0.0.0.0',
  network   => 'default',
}

In /etc/network/routes the route is getting added twice:

# HEADER: This file is is being managed by puppet. Changes to
# HEADER: routes that are not being managed by puppet will persist;
# HEADER: however changes to routes that are being managed by puppet will
# HEADER: be overwritten. In addition, file order is NOT guaranteed.
# HEADER: Last generated at: 2013-10-24 16:33:34 +0200
default 0.0.0.0 10.4.0.1 eth0
default 0.0.0.0 10.4.0.1 eth0

And on every puppet run I'm getting:

Notice: /Stage[main]//Network_route[default]/ensure: created

No longer finding interface config scripts in CentOS

Since the resolving #36 and #37 the network module no longer seems to be detecting interface configuration files in CentOS 6.4.

err: Could not prefetch network_config provider 'redhat': No resource and no name in property hash in redhat instance
notice: /Stage[main]//Node[login.tamaki.test.nesi.org.nz]/Network_config[eth0]/ensure: created
err: /Stage[main]//Node[login.tamaki.test.nesi.org.nz]/Network_config[eth0]: Could not evaluate: No resource and no name in property hash in redhat instance
err: /Stage[main]//Node[login.tamaki.test.nesi.org.nz]/Network_config[eth1]/ensure: change from absent to present failed: Puppet::Type::Network_config::ProviderRedhat is in an error state

Network module responds poorly to ifcfg-NNN.bak files

...
notice: /Stage[main]/Rsyslog/Exec[Stop syslog]/returns: executed successfully
notice: /Stage[main]/Network/Network_config[eth2]/ipaddress: ipaddress changed '' to '10.10.10.114'
notice: /Stage[main]/Network/Network_config[eth2]/netmask: netmask changed '' to '255.255.255.0'
notice: /Stage[main]/Network/Network_config[eth2]/method: method changed 'dhcp' to 'static'
notice: /Stage[main]/Network/Network_config[eth2]/onboot: onboot changed 'false' to 'true'
notice: /Stage[main]/Network/Network_config[eth2]/hotplug: hotplug changed '' to 'true'
err: /Stage[main]/Network/Network_config[eth2]: Could not evaluate: Unable to support multiple interfaces [eth2,eth2] in a single file /etc/sysconfig/network-scripts/ifcfg-eth2
notice: Finished catalog run in 17.96 seconds
notice: Caught INT; calling stop
[root@grr network-scripts]# cat ifcfg-eth2*
Xen Virtual Ethernet
DEVICE=eth2
BOOTPROTO=dhcp
ONBOOT=no
HWADDR=d6:11:a6:10:f8:56
Xen Virtual Ethernet
DEVICE=eth2
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=22:77:d7:36:89:8f
BROADCAST=127.255.255.255
[root@grr network-scripts]# ls ifcfg-eth2*
ifcfg-eth2 ifcfg-eth2.bak
[root@grr network-scripts]# rm ifcfg-eth2.bak
rm: remove regular file `ifcfg-eth2.bak'? y
info: Applying configuration version '1366207647'
notice: /Stage[main]/Rsyslog/Exec[Stop syslog]/returns: executed successfully
notice: /Stage[main]/Network/Network_config[eth2]/ipaddress: ipaddress changed '' to '10.10.10.114'
notice: /Stage[main]/Network/Network_config[eth2]/netmask: netmask changed '' to '255.255.255.0'
notice: /Stage[main]/Network/Network_config[eth2]/method: method changed 'dhcp' to 'static'
notice: /Stage[main]/Network/Network_config[eth2]/onboot: onboot changed 'false' to 'true'
notice: /Stage[main]/Network/Network_config[eth2]/hotplug: hotplug changed '' to 'true'
info: FileBucket adding
{md5}
d7d7e6d693435d8f9bd8252a1b3fdb2a
notice: Finished catalog run in 11.87 seconds

network_config properties should be validated

Pending:
  Puppet::Type::Network_config::ProviderInterfaces when parsing should parse out mapping lines
    # Not yet implemented
    # ./spec/unit/provider/network_config/interfaces_spec.rb:63
  Puppet::Type::Network_config::ProviderInterfaces when parsing should parse out lines following mapping lines
    # Not yet implemented
    # ./spec/unit/provider/network_config/interfaces_spec.rb:64
  Puppet::Type::Network_config::ProviderInterfaces when parsing should allow for multiple pre and post up sections
    # Not yet implemented
    # ./spec/unit/provider/network_config/interfaces_spec.rb:66
  Puppet::Type::Network_config::ProviderRedhat when parsing the method property when static 
    # Munging of BOOTPROTO none <-> static
    # ./spec/unit/provider/network_config/redhat_spec.rb:34
  Puppet::Type::Network_config::ProviderRedhat when formatting resources with a valid configuration 
    # Munging of onboot yes <-> true
    # ./spec/unit/provider/network_config/redhat_spec.rb:256
  Puppet::Type::Network_config::ProviderRedhat when formatting resources with a valid configuration 
    # Munging of BOOTPROTO none <-> static
    # ./spec/unit/provider/network_config/redhat_spec.rb:260
  Puppet::Type::Network_config when validating the attribute options should be a descendant of the KeyValue property
    # on conversion to specific type
    # ./spec/unit/type/network_config_spec.rb:46
  Puppet::Type::Network_config when validating the attribute value ipaddress should fail if a malformed address is used
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:81
  Puppet::Type::Network_config when validating the attribute value ipaddress using the inet family should fail when passed an IPv6 address
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:65
  Puppet::Type::Network_config when validating the attribute value ipaddress using the inet6 family should fail when passed an IPv4 address
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:75
  Puppet::Type::Network_config when validating the attribute value netmask should validate a CIDR netmask
    # Not yet implemented
    # ./spec/unit/type/network_config_spec.rb:88
  Puppet::Type::Network_config when validating the attribute value netmask should fail if an invalid CIDR netmask is used
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:89

Lame.

/etc/network/routes updated on every run

I've got the following config:
network_route { 'default':
ensure => 'present',
gateway => 10.0.0.2,
interface => 'bond0',
netmask => '0.0.0.0',
network => 'default',
}

resulting in the following file:
root@myserver:~# cat /etc/network/routes

HEADER: This file is is being managed by puppet. Changes to

HEADER: routes that are not being managed by puppet will persist;

HEADER: however changes to routes that are being managed by puppet will

HEADER: be overwritten. In addition, file order is NOT guaranteed.

HEADER: Last generated at: Mon Mar 24 13:23:26 +0100 2014

default 0.0.0.0 10.0.0.2 bond0
default 0.0.0.0 10.0.0.2 bond0

and on each puppet agent -t run i get:
notice: /Stage[main]/Site000::Profiles::Network::Lacp/Network_route[default]/ensure: created

This is on ubuntu precise. ifupdown-extra is installed.

Skip munge in full netmask addresses

The parser tries to evaluate full IP netmask addresses but can only take in CIDR notation.

Skip the IPAddr.new('255.255.255.255').mask(value.strip.to_i).to_s line in lib/puppet/type/network_route.rb if netmask matches the IP regex.

Multiple interfaces with different families not supported

Adding an interface (eth0:0) with address families inet and inet6 is not possible, as this will result in a duplicate definition error message.

One possible solution would be, to add a parameter 'device'.

If I'm missing something, please let me know.

Reconfigure option does not work

If I set reconfigure => true, in network_config class nothing happens. It should restart the networking service, or at least make a ifdown/ifup.

Support ONPARENT option for aliases

Fairly self-explanatory I guess. There's currently no support built in for the ONPARENT optiion of an interface alias. Useful for floating IP type vips that shouldn't automatically come up when the parent does.

Spec failures on ruby 1.9.3

Failures:

  1) Puppet::Type::Network_config::ProviderInterfaces when formatting writing the allow-hotplug section should allow at most one section
     Failure/Error: content.select {|line| line.match(/^allow-hotplug /)}.length.should == 1
     NoMethodError:
       private method `select' called for #
     # ./spec/unit/provider/network_config/interfaces_spec.rb:117:in `block (4 levels) in '

  2) Puppet::Type::Network_config::ProviderInterfaces when formatting writing the allow-hotplug section should have the correct interfaces appended
     Failure/Error: content.find {|line| line.match(/^allow-hotplug /)}.should be_include("allow-hotplug eth0 lo")
     NoMethodError:
       undefined method `find' for #
     # ./spec/unit/provider/network_config/interfaces_spec.rb:121:in `block (4 levels) in '

  3) Puppet::Type::Network_config::ProviderInterfaces when formatting writing iface blocks should produce an iface block for each interface
     Failure/Error: content.select {|line| line.match(/iface eth0 inet static/)}.length.should == 1
     NoMethodError:
       private method `select' called for #
     # ./spec/unit/provider/network_config/interfaces_spec.rb:129:in `block (4 levels) in '

The redhat provider needs config <-> resource munging

network-scripts config files use 'yes' and 'no' for booleans, which adds the need for mapping. In addition, the BOOTPROTO value considers everything but 'bootp' or 'dhcp' to indicate static, so 'none' or 'static' is used. These values need to be normalized.

Spec failures on redhat

Failures:
  1) Puppet::Type::Network_config::ProviderInterfaces when formatting writing iface blocks should add all options following the iface block
     Failure/Error: content.split('\n').find {|line| line.match(/iface eth0/)}.should be_include(block)
       expected include?("iface eth0 inet static\naddress 169.254.0.1\nnetmask 255.255.0.0") to return true, got false
     # ./spec/unit/provider/network_config/interfaces_spec.rb:174
Finished in 0.5945 seconds
143 examples, 1 failure, 9 pending
Failed examples:
rspec ./spec/unit/provider/network_config/interfaces_spec.rb:168 # Puppet::Type::Network_config::ProviderInterfaces when formatting writing iface blocks should add all options following the iface block

This occurs when running on redhat version 6.3.

Facts for default interface

Hey there, I have 4 facts that are relatively useful and I thought of joining them to this repository instead of opening a new one with just the facts.

The facts they expose are:

  • defaultgw_gw_address - default gateway address
  • defaultgw_interface - main interface on machine (one that is used with the default gateway)
  • defaultgw_address - address of main machine interface (one that is used on the default gateway)
  • defaultgw_internet_address - our external address as the internet sees us (because we might be behind NAT)

I'll attach the code in a comment as it is not that long...

Could not autoload network_config

I'm just starting with puppet, I'm not using puppet master, I just execute puppet apply directly on the node.
I've tried to add simple network_config to my node but puppet apply fails with:

Could not autoload network_config: no such file to load -- puppet/property/boolean at...

I'm using puppet 2.7.23 and librarian to manage modules, 'librarian-puppet show' outputs:
adrien/boolean (1.0.1)
adrien/filemapper (1.1.2)
adrien/network (0.4.1)

Any clues?

Thanks,
Pawel

Readme.md: network_route requires 'network' parameter

Readme.md needs some additions in order to prevent stupid people like me from scratching their head at error messages like:
Error: /Stage[main]/Profiles::Portal::Webserver/Network_route[10.0.0.0]: Could not evaluate: 10.0.0.0 does not have a network.

Add validation for type values

Pending:
  Puppet::Type::Network_config when validating the attribute options should be a descendant of the KeyValue property
    # on conversion to specific type
    # ./spec/unit/type/network_config_spec.rb:46
  Puppet::Type::Network_config when validating the attribute value ipaddress should fail if a malformed address is used
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:81
  Puppet::Type::Network_config when validating the attribute value ipaddress using the inet family should fail when passed an IPv6 address
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:65
  Puppet::Type::Network_config when validating the attribute value ipaddress using the inet6 family should fail when passed an IPv4 address
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:75
  Puppet::Type::Network_config when validating the attribute value netmask should validate a CIDR netmask
    # Not yet implemented
    # ./spec/unit/type/network_config_spec.rb:88
  Puppet::Type::Network_config when validating the attribute value netmask should fail if an invalid CIDR netmask is used
    # implementation of IP address validation
    # ./spec/unit/type/network_config_spec.rb:89

This should be not pending.

Interfaces are "created" every puppet run

For some reason every run of Puppet the /etc/sysconfig/network-scripts/ifcfg-* files managed by this module are "created", even if they already exist. This seems to be caused by the order of the lines in the file changing each time it is generated?

Here's a diff of one of the interface files showing how it changed between runs, although the key value pairings are all the same.

$ sudo diff --side-by-side /etc/sysconfig/network-scripts/ifcfg-lo\:1 /tmp/ifcfg-lo\:1 
DEVICE=lo:1                           | BOOTPROTO=loopback
ONBOOT=yes                          ONBOOT=yes
IPADDR=10.12.16.18                        <
NETMASK=255.255.255.255                     NETMASK=255.255.255.255
                                  >  IPADDR=10.12.16.18
HOTPLUG=yes                         HOTPLUG=yes
BOOTPROTO=loopback                        | DEVICE=lo:1

This is not causing a functional problem at the moment, however it does clutter the logs substantially.

Request for comments: static routing configuration

One of the features that has been asked for frequently is support for static network routes. This is a feature I hope to add, but I would like feedback on how the type should be implemented - that is, what are the types of information needed in the type. For example:

network_route { 'default':
  family  => 'inet',
  type    => 'network',
  netmask => '0/0',
  device  => 'eth0',
  gateway => '1.2.3.4',
  metric  => '0',
}

This is one suggested interface for the network_route type. What I need are example types like this and the expected output, so I can get an idea of what attributes need to be handled and how.

default network example does not work on RHEL

If I do:

    network_route { '10.0.0.0/8':
      ensure    => 'present',
      gateway   => '192.168.63.1',
      interface => 'eth0',
      netmask   => '8',
      network   => '10.0.0.0'
    }
    network_route { '192.168.0.0/16':
      ensure    => 'present',
      gateway   => '192.168.63.1',
      interface => 'eth0',
      netmask   => '16',
      network   => '192.168.0.0'
    }
    network_route { 'default':
      ensure    => 'present',
      gateway   => '192.168.63.50',
      interface => 'eth0',
      netmask   => '',
      network   => 'default'
    }

I get this in /etc/sysconfig/network-scripts/route-eth0:

10.0.0.0/255.0.0.0 via 192.168.63.1 dev eth0
192.168.0.0/255.255.0.0 via 192.168.63.1 dev eth0
default via 192.168.63.50 dev eth0

Which doesn't actually work :(

The only valid format for that file, that I know of, is:

GATEWAY1=192.168.63.1
ADDRESS1=192.168.0.0
NETMASK1=255.255.0.0

GATEWAY2=192.168.63.1
ADDRESS2=10.0.0.0
NETMASK2=255.0.0.0

and unlike what I'd normally expect (like what firewall module does) - the routes are NOT setup at puppet agent runtime - but one needs to reboot (or reload networking).

The resulting routes, after reboot, looks like this:

192.168.63.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.0.0     192.168.63.1    255.255.0.0     UG    0      0        0 eth0
10.0.0.0        192.168.63.1    255.0.0.0       UG    0      0        0 eth0
0.0.0.0         192.168.63.1    0.0.0.0         UG    0      0        0 eth0

As far as I can see, the conclusions seem to be:

  1. one cannot set default gw in routes-ethX (it's set in the ifcfg-ethX file)
  2. ip commands like the ones used, does not work, and should probably use the officially supported format (or may it's just done wrongly in the module example or something - and is actually supported) ?
  3. changes are not enacted on puppet run - one must reboot to update routes :(

Overwriting behavior

Here's my scenario. I have a newly provisioned server with the loopback interface and em4 defined in /etc/network/interfaces. Puppet has never run on this server. I install puppet and it checks in with my puppet master and finds this in its catalog:

network_config { 'em4':
  ensure => present,
  method => manual,
  onboot => false,
}

Sure enough, puppet runs and finds some things about this interface that need to change:

Nov 21 18:42:54 server01 puppet-agent[2147]: (/Stage[main]/Profiles::Server::Interfaces/Network_config[em4]/method) method changed 'dhcp' to 'manual'
Nov 21 18:42:54 server01 puppet-agent[2147]: (/Stage[main]/Profiles::Server::Interfaces/Network_config[em4]/hotplug) hotplug changed '' to 'true'

But, notice, it hasn't changed the onboot status. I check /etc/network/interfaces and it's still listed in the "auto" section. I run puppet resource network_config em4 and it returns:

user@server01:~$ sudo puppet resource network_config em4
network_config { 'em4':
  ensure  => 'present',
  family  => 'inet',
  hotplug => 'true',
  method  => 'manual',
  onboot  => 'true',
}

So I run puppet again:

user@server01:~$ sudo puppet agent -tv
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/postgres_default_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/rabbitmq_erlang_cookie.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/iptables_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/iptables_persistent_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/ip6tables_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/os_maj_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/lvm_support.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Caching catalog for server01.domain.com
Info: Applying configuration version '1385058759'
Notice: Finished catalog run in 1.83 seconds

I'm at a loss on this one...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.