From 0580c3f15745e927a7691e834f48f93ec61021e5 Mon Sep 17 00:00:00 2001 From: Elyse Salberg Date: Mon, 9 Oct 2017 13:15:38 -0400 Subject: [PATCH] fixup --- defines/network_bond_spec.rb | 182 --------------------- defines/network_bridge_dynamic_spec.rb | 139 ---------------- defines/network_bridge_spec.rb | 138 ---------------- defines/network_bridge_static_spec.rb | 211 ------------------------- defines/network_if_bridge_spec.rb | 94 ----------- defines/network_if_dynamic_spec.rb | 168 -------------------- defines/network_if_promisc_spec.rb | 163 ------------------- defines/network_route_spec.rb | 99 ------------ 8 files changed, 1194 deletions(-) delete mode 100644 defines/network_bond_spec.rb delete mode 100644 defines/network_bridge_dynamic_spec.rb delete mode 100644 defines/network_bridge_spec.rb delete mode 100644 defines/network_bridge_static_spec.rb delete mode 100644 defines/network_if_bridge_spec.rb delete mode 100644 defines/network_if_dynamic_spec.rb delete mode 100644 defines/network_if_promisc_spec.rb delete mode 100644 defines/network_route_spec.rb diff --git a/defines/network_bond_spec.rb b/defines/network_bond_spec.rb deleted file mode 100644 index c59c277a..00000000 --- a/defines/network_bond_spec.rb +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::bond', :type => 'define' do - - context 'incorrect value: ensure' do - let(:title) { 'bond1' } - let :params do { - :ensure => 'blah', - :restart => true, - :sched => nil, - } - end - it 'should fail' do - expect {should contain_file('ifcfg-bond1')}.to raise_error(Puppet::Error, /\$ensure must be either "up" or "down"./) - end - end - - context 'required parameters' do - let(:title) { 'bond0' } - let :params do { - :ensure => 'up', - :restart => true, - :sched => nil, - } - end - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.0', - :macaddress_bond0 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-bond0').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-bond0', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-bond0] with required contents' do - verify_contents(catalogue, 'ifcfg-bond0', [ - 'DEVICE=bond0', - 'BOOTPROTO=none', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'BONDING_OPTS="miimon=100"', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should_not contain_augeas('modprobe.conf_bond0') } - - context 'on an older operatingsystem with /etc/modprobe.conf' do - (['RedHat', 'CentOS', 'OEL', 'OracleLinux', 'SLC', 'Scientific']).each do |os| - context "for operatingsystem #{os}" do - (['4.8', '5.9']).each do |osv| - context "for operatingsystemrelease #{osv}" do - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => os, - :operatingsystemrelease => osv, - } - end - it { should contain_augeas('modprobe.conf_bond0').with( - :context => '/files/etc/modprobe.conf', - :changes => ['set alias[last()+1] bond0', 'set alias[last()]/modulename bonding'], - :onlyif => "match alias[*][. = 'bond0'] size == 0" - )} - end - end - end - end - - (['Fedora']).each do |os| - context "for operatingsystem #{os}" do - (['6', '9', '11']).each do |osv| - context "for operatingsystemrelease #{osv}" do - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => os, - :operatingsystemrelease => osv, - } - end - it { should contain_augeas('modprobe.conf_bond0').with( - :context => '/files/etc/modprobe.conf', - :changes => ['set alias[last()+1] bond0', 'set alias[last()]/modulename bonding'], - :onlyif => "match alias[*][. = 'bond0'] size == 0" - )} - end - end - end - end - end - end - - context 'required parameters: restart => false' do - let(:title) { 'bond0' } - let :params do { - :ensure => 'up', - :restart => false, - :sched => nil, - } - end - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.0', - :macaddress_bond0 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-bond0').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-bond0', - )} - it 'should contain File[ifcfg-bond0] with required contents' do - verify_contents(catalogue, 'ifcfg-bond0', [ - 'DEVICE=bond0', - 'BOOTPROTO=none', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'BONDING_OPTS="miimon=100"', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should_not contain_augeas('modprobe.conf_bond0') } - it { is_expected.to_not contain_file('ifcfg-bond0').that_notifies('Service[network]') } - end - - context 'optional parameters' do - let(:title) { 'bond0' } - let :params do { - :ensure => 'down', - :mtu => '9000', - :ethtool_opts => 'speed 1000 duplex full autoneg off', - :bonding_opts => 'mode=active-backup miimon=100', - :zone => 'trusted', - :restart => true, - :sched => nil, - } - end - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.0' - } - end - it { should contain_file('ifcfg-bond0').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-bond0', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-bond0] with required contents' do - verify_contents(catalogue, 'ifcfg-bond0', [ - 'DEVICE=bond0', - 'BOOTPROTO=none', - 'ONBOOT=no', - 'HOTPLUG=no', - 'TYPE=Ethernet', - 'MTU=9000', - 'BONDING_OPTS="mode=active-backup miimon=100"', - 'ETHTOOL_OPTS="speed 1000 duplex full autoneg off"', - 'ZONE=trusted', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should_not contain_augeas('modprobe.conf_bond0') } - end - -end diff --git a/defines/network_bridge_dynamic_spec.rb b/defines/network_bridge_dynamic_spec.rb deleted file mode 100644 index 77eeec3b..00000000 --- a/defines/network_bridge_dynamic_spec.rb +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::bridge::dynamic', :type => 'define' do - - context 'incorrect value: ensure' do - let(:title) { 'br77' } - let :params do { - :ensure => 'blah', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /\$ensure must be either "up" or "down"./) - end - end - - context 'incorrect value: stp' do - let(:title) { 'br77' } - let :params do { - :ensure => 'up', - :stp => 'notABool', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /"notABool" is not a boolean./) - end - end - - context 'required parameters' do - let(:title) { 'br1' } - let :params do { - :ensure => 'up', - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=dhcp', - 'ONBOOT=yes', - 'TYPE=Bridge', - 'PEERDNS=no', - 'DELAY=30', - 'STP=no', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { is_expected.to contain_file('ifcfg-br1').that_notifies('Service[network]') } - it { should contain_package('bridge-utils') } - end - - context 'required parameters, restart => false' do - let(:title) { 'br1' } - let :params do { - :ensure => 'up', - :restart => false, - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=dhcp', - 'ONBOOT=yes', - 'TYPE=Bridge', - 'PEERDNS=no', - 'DELAY=30', - 'STP=no', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { is_expected.to_not contain_file('ifcfg-br1').that_notifies('Service[network]') } - it { should contain_package('bridge-utils') } - end - - context 'optional parameters' do - let(:title) { 'br1' } - let :params do { - :ensure => 'down', - :bootproto => 'bootp', - :userctl => true, - :stp => true, - :delay => '1000', - :bridging_opts => 'hello_time=200 priority=65535', - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=bootp', - 'ONBOOT=no', - 'TYPE=Bridge', - 'DELAY=1000', - 'STP=yes', - 'BRIDGING_OPTS="hello_time=200 priority=65535"', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should contain_package('bridge-utils') } - end - -end diff --git a/defines/network_bridge_spec.rb b/defines/network_bridge_spec.rb deleted file mode 100644 index 787be1b9..00000000 --- a/defines/network_bridge_spec.rb +++ /dev/null @@ -1,138 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::bridge', :type => 'define' do - - context 'incorrect value: ensure' do - let(:title) { 'br77' } - let :params do { - :ensure => 'blah', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /\$ensure must be either "up" or "down"./) - end - end - - context 'incorrect value: stp' do - let(:title) { 'br77' } - let :params do { - :ensure => 'up', - :stp => 'notABool', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /"notABool" is not a boolean./) - end - end - - context 'required parameters' do - let(:title) { 'br1' } - let :params do { - :ensure => 'up', - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=none', - 'ONBOOT=yes', - 'TYPE=Bridge', - 'PEERDNS=no', - 'DELAY=30', - 'STP=no', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { is_expected.to contain_file('ifcfg-br1').that_notifies('Service[network]') } - it { should contain_package('bridge-utils') } - end - - context 'required parameters, restart => false' do - let(:title) { 'br1' } - let :params do { - :ensure => 'up', - :restart => false, - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=none', - 'ONBOOT=yes', - 'TYPE=Bridge', - 'PEERDNS=no', - 'DELAY=30', - 'STP=no', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { is_expected.to_not contain_file('ifcfg-br1').that_notifies('Service[network]') } - it { should contain_package('bridge-utils') } - end - - context 'optional parameters' do - let(:title) { 'br1' } - let :params do { - :ensure => 'down', - :userctl => true, - :stp => true, - :delay => '1000', - :bridging_opts => 'hello_time=200 priority=65535', - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=none', - 'ONBOOT=no', - 'TYPE=Bridge', - 'DELAY=1000', - 'STP=yes', - 'BRIDGING_OPTS="hello_time=200 priority=65535"', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should contain_package('bridge-utils') } - end - -end diff --git a/defines/network_bridge_static_spec.rb b/defines/network_bridge_static_spec.rb deleted file mode 100644 index a8dde126..00000000 --- a/defines/network_bridge_static_spec.rb +++ /dev/null @@ -1,211 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::bridge::static', :type => 'define' do - - context 'incorrect value: ensure' do - let(:title) { 'br77' } - let :params do { - :ensure => 'blah', - :ipaddress => '1.2.3.4', - :netmask => '255.255.255.0', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /\$ensure must be either "up" or "down"./) - end - end - - context 'incorrect value: ipaddress' do - let(:title) { 'br77' } - let :params do { - :ensure => 'up', - :ipaddress => 'notAnIP', - :netmask => '255.255.255.0', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /notAnIP is not an IP address./) - end - end - - context 'incorrect value: ipv6address' do - let(:title) { 'br77' } - let :params do { - :ensure => 'up', - :ipaddress => '1.2.3.4', - :netmask => '255.255.255.0', - :ipv6address => 'notAnIP', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /notAnIP is not an IPv6 address./) - end - end - - context 'incorrect value: stp' do - let(:title) { 'br77' } - let :params do { - :ensure => 'up', - :ipaddress => '1.2.3.4', - :netmask => '255.255.255.0', - :stp => 'notABool', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /"notABool" is not a boolean./) - end - end - - context 'incorrect value: ipv6init' do - let(:title) { 'br77' } - let :params do { - :ensure => 'up', - :ipaddress => '1.2.3.4', - :netmask => '255.255.255.0', - :ipv6init => 'notABool', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-br77')}.to raise_error(Puppet::Error, /"notABool" is not a boolean./) - end - end - - context 'required parameters' do - let(:title) { 'br1' } - let :params do { - :ensure => 'up', -# :ipaddress => '1.2.3.4', -# :netmask => '255.255.255.0', - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=static', - 'ONBOOT=yes', - 'TYPE=Bridge', - 'PEERDNS=no', - 'DELAY=30', - 'STP=no', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { is_expected.to contain_file('ifcfg-br1').that_notifies('Service[network]') } - it { should contain_package('bridge-utils') } - end - - context 'required parameters, restart => false' do - let(:title) { 'br1' } - let :params do { - :ensure => 'up', - :ipaddress => '1.2.3.4', - :netmask => '255.255.255.0', - :restart => false, - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=static', - 'ONBOOT=yes', - 'TYPE=Bridge', - 'PEERDNS=no', - 'DELAY=30', - 'STP=no', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { is_expected.to_not contain_file('ifcfg-br1').that_notifies('Service[network]') } - it { should contain_package('bridge-utils') } - end - - context 'optional parameters' do - let(:title) { 'br1' } - let :params do { - :ensure => 'down', - :ipaddress => '1.2.3.4', - :netmask => '255.255.255.0', - :gateway => '1.2.3.1', - :ipv6init => true, - :ipv6address => '123:4567:89ab:cdef:123:4567:89ab:cdef/64', - :ipv6gateway => '123:4567:89ab:cdef:123:4567:89ab:1', - :ipv6peerdns => true, - :userctl => true, - :peerdns => true, - :dns1 => '3.4.5.6', - :dns2 => '5.6.7.8', - :domain => 'somedomain.com', - :stp => true, - :delay => '1000', - :bridging_opts => 'hello_time=200 priority=65535', - :scope => 'peer 1.2.3.1', - } - end - let :facts do { - :osfamily => 'RedHat', - } - end - it { should contain_file('ifcfg-br1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-br1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-br1] with required contents' do - verify_contents(catalogue, 'ifcfg-br1', [ - 'DEVICE=br1', - 'BOOTPROTO=static', - 'ONBOOT=no', - 'TYPE=Bridge', - 'IPADDR=1.2.3.4', - 'NETMASK=255.255.255.0', - 'GATEWAY=1.2.3.1', - 'IPV6INIT=yes', - 'IPV6ADDR=123:4567:89ab:cdef:123:4567:89ab:cdef/64', - 'IPV6_DEFAULTGW=123:4567:89ab:cdef:123:4567:89ab:1', - 'IPV6_PEERDNS=yes', - 'PEERDNS=yes', - 'DNS1=3.4.5.6', - 'DNS2=5.6.7.8', - 'DOMAIN="somedomain.com"', - 'DELAY=1000', - 'STP=yes', - 'BRIDGING_OPTS="hello_time=200 priority=65535"', - 'SCOPE="peer 1.2.3.1"', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should contain_package('bridge-utils') } - end - -end diff --git a/defines/network_if_bridge_spec.rb b/defines/network_if_bridge_spec.rb deleted file mode 100644 index 1eaa6cb0..00000000 --- a/defines/network_if_bridge_spec.rb +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::if::bridge', :type => 'define' do - - context 'incorrect value: ensure' do - let(:title) { 'eth77' } - let :params do { - :ensure => 'blah', - :bridge => 'br0', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-eth77')}.to raise_error(Puppet::Error, /\$ensure must be either "up" or "down"./) - end - end - - context 'required parameters' do - let(:title) { 'eth1' } - let :params do { - :ensure => 'up', - :bridge => 'br0', - } - end - let :facts do { - :osfamily => 'RedHat', - :macaddress_eth1 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-eth1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth1] with required contents' do - verify_contents(catalogue, 'ifcfg-eth1', [ - 'DEVICE=eth1', - 'BOOTPROTO=none', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'PEERDNS=no', - 'BRIDGE=br0', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - - context 'optional parameters' do - let(:title) { 'eth1' } - let :params do { - :ensure => 'down', - :bridge => 'br55', - :mtu => '9000', - :ethtool_opts => 'speed 1000 duplex full autoneg off', - :macaddress => '00:00:00:00:00:00', - } - end - let :facts do { - :osfamily => 'RedHat', - :macaddress_eth1 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-eth1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth1] with required contents' do - verify_contents(catalogue, 'ifcfg-eth1', [ - 'DEVICE=eth1', - 'BOOTPROTO=none', - 'HWADDR=00:00:00:00:00:00', - 'ONBOOT=no', - 'HOTPLUG=no', - 'TYPE=Ethernet', - 'MTU=9000', - 'ETHTOOL_OPTS="speed 1000 duplex full autoneg off"', - 'BRIDGE=br55', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - -end diff --git a/defines/network_if_dynamic_spec.rb b/defines/network_if_dynamic_spec.rb deleted file mode 100644 index 7ff23364..00000000 --- a/defines/network_if_dynamic_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::if::dynamic', :type => 'define' do - - context 'incorrect value: ensure' do - let(:title) { 'eth77' } - let :params do { - :ensure => 'blah', - } - end - it 'should fail' do - expect {should contain_file('ifcfg-eth77')}.to raise_error(Puppet::Error, /\$ensure must be either "up" or "down"./) - end - end - - context 'required parameters' do - let(:title) { 'eth99' } - let :params do { - :ensure => 'up', - } - end - let :facts do { - :osfamily => 'RedHat', - :macaddress_eth99 => 'ff:aa:ff:aa:ff:aa', - } - end - it { should contain_file('ifcfg-eth99').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth99', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth99] with required contents' do - verify_contents(catalogue, 'ifcfg-eth99', [ - 'DEVICE=eth99', - 'BOOTPROTO=dhcp', - 'HWADDR=ff:aa:ff:aa:ff:aa', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - - context 'optional parameters' do - let(:title) { 'eth99' } - let :params do { - :ensure => 'down', - :macaddress => 'ef:ef:ef:ef:ef:ef', - :bootproto => 'bootp', - :userctl => true, - :mtu => '1500', - :dhcp_hostname => 'hostname', - :ethtool_opts => 'speed 100 duplex full autoneg off', - :peerdns => true, - :linkdelay => '5', - :check_link_down => true, - :defroute => 'yes', - :metric => '10', - :zone => 'trusted', - } - end - let :facts do { - :osfamily => 'RedHat', - :macaddress_eth99 => 'ff:aa:ff:aa:ff:aa', - } - end - it { should contain_file('ifcfg-eth99').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth99', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth99] with required contents' do - verify_contents(catalogue, 'ifcfg-eth99', [ - 'DEVICE=eth99', - 'BOOTPROTO=bootp', - 'HWADDR=ef:ef:ef:ef:ef:ef', - 'ONBOOT=no', - 'HOTPLUG=no', - 'TYPE=Ethernet', - 'MTU=1500', - 'DHCP_HOSTNAME="hostname"', - 'ETHTOOL_OPTS="speed 100 duplex full autoneg off"', - 'USERCTL=yes', - 'LINKDELAY=5', - 'DEFROUTE=yes', - 'ZONE=trusted', - 'METRIC=10', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - - context 'optional parameters - vlan' do - let(:title) { 'eth45.302' } - let(:params) {{ :ensure => 'up' }} - let :facts do { - :osfamily => 'RedHat', - :macaddress_eth45 => 'bb:cc:bb:cc:bb:cc', - } - end - it { should contain_file('ifcfg-eth45.302').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth45.302', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth45.302] with required contents' do - verify_contents(catalogue, 'ifcfg-eth45.302', [ - 'DEVICE=eth45.302', - 'BOOTPROTO=dhcp', - 'HWADDR=bb:cc:bb:cc:bb:cc', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - - context 'optional parameters - manage_hwaddr' do - let(:title) { 'eth0' } - let :params do { - :ensure => 'up', - :manage_hwaddr => false, - } - end - let :facts do { - :osfamily => 'RedHat', - :macaddress_eth0 => 'bb:cc:bb:cc:bb:cc', - } - end - it { should contain_file('ifcfg-eth0').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth0', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth0] with required contents' do - verify_contents(catalogue, 'ifcfg-eth0', [ - 'DEVICE=eth0', - 'BOOTPROTO=dhcp', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - - -end diff --git a/defines/network_if_promisc_spec.rb b/defines/network_if_promisc_spec.rb deleted file mode 100644 index 466a31d7..00000000 --- a/defines/network_if_promisc_spec.rb +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::if::promisc', :type => 'define' do - - context 'required parameters' do - let(:title) { 'eth1' } - let :params do { - :ensure => 'up', - :restart => true, - :sched => nil, - } - end - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.0', - :operatingsystemmajrelease => '6', - :macaddress_eth1 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-eth1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth1', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth1] with required contents' do - verify_contents(catalogue, 'ifcfg-eth1', [ - 'DEVICE=eth1', - 'BOOTPROTO=none', - 'HWADDR=fe:fe:fe:aa:aa:aa', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'PEERDNS=no', - 'PROMISC=yes', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should contain_file('/sbin/ifup-local') } - it { should contain_file('/sbin/ifdown-local') } - it { should contain_file('ifup-local-promisc').with( - :ensure => 'file', - :mode => '0755', - :owner => 'root', - :group => 'root', - :path => '/sbin/ifup-local-promisc', - :source => 'puppet:///modules/network/promisc/ifup-local-promisc_6' - )} - it { should contain_file('ifdown-local-promisc').with( - :ensure => 'file', - :mode => '0755', - :owner => 'root', - :group => 'root', - :path => '/sbin/ifdown-local-promisc', - :source => 'puppet:///modules/network/promisc/ifdown-local-promisc_6' - )} - end - - context 'required parameters: restart => false' do - let(:title) { 'eth1' } - let :params do { - :ensure => 'up', - :restart => false, - :sched => nil, - } - end - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.0', - :operatingsystemmajrelease => '6', - :macaddress_eth1 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-eth1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth1', - )} - it 'should contain File[ifcfg-eth1] with required contents' do - verify_contents(catalogue, 'ifcfg-eth1', [ - 'DEVICE=eth1', - 'BOOTPROTO=none', - 'HWADDR=fe:fe:fe:aa:aa:aa', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'PEERDNS=no', - 'PROMISC=yes', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - it { should contain_file('/sbin/ifup-local') } - it { should contain_file('/sbin/ifdown-local') } - it { should contain_file('ifup-local-promisc').with( - :ensure => 'file', - :mode => '0755', - :owner => 'root', - :group => 'root', - :path => '/sbin/ifup-local-promisc', - :source => 'puppet:///modules/network/promisc/ifup-local-promisc_6' - )} - it { should contain_file('ifdown-local-promisc').with( - :ensure => 'file', - :mode => '0755', - :owner => 'root', - :group => 'root', - :path => '/sbin/ifdown-local-promisc', - :source => 'puppet:///modules/network/promisc/ifdown-local-promisc_6' - )} - it { is_expected.to_not contain_file('ifcfg-eth1').that_notifies('Service[network]') } - end - - context 'optional parameters' do - let(:title) { 'eth3' } - let :params do { - :ensure => 'up', - :macaddress => 'ef:ef:ef:ef:ef:ef', - :restart => true, - :sched => nil, - } - end - let :facts do { - :osfamily => 'RedHat', - :operatingsystem => 'RedHat', - :operatingsystemrelease => '6.0', - :operatingsystemmajrelease => '6', - :macaddress_eth3 => 'fe:fe:fe:aa:aa:aa', - } - end - it { should contain_file('ifcfg-eth3').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/ifcfg-eth3', - :notify => 'Service[network]' - )} - it 'should contain File[ifcfg-eth3] with required contents' do - verify_contents(catalogue, 'ifcfg-eth3', [ - 'DEVICE=eth3', - 'HWADDR=ef:ef:ef:ef:ef:ef', - 'ONBOOT=yes', - 'HOTPLUG=yes', - 'TYPE=Ethernet', - 'PEERDNS=no', - 'PROMISC=yes', - 'NM_CONTROLLED=no', - ]) - end - it { should contain_service('network') } - end - -end diff --git a/defines/network_route_spec.rb b/defines/network_route_spec.rb deleted file mode 100644 index 2e47be55..00000000 --- a/defines/network_route_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env rspec - -require 'spec_helper' - -describe 'network::route', :type => 'define' do - - context 'singular parameters' do - let(:pre_condition) { "file { 'ifcfg-eth1': }" } - let(:title) { 'eth1' } - let :params do { - :ipaddress => [ '192.168.2.1', ], - :netmask => [ '255.255.255.1', ], - :gateway => [ '192.168.1.2', ], - :restart => true, - :sched => nil, - } - end - let(:facts) {{ :osfamily => 'RedHat' }} - it { should contain_file('route-eth1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/route-eth1' - )} - it 'should contain File[route-eth1] with contents "ADDRESS0=192.168.2.1\nNETMASK0=255.255.255.1\nGATEWAY0=192.168.1.2"' do - verify_contents(catalogue, 'route-eth1', [ - 'ADDRESS0=192.168.2.1', - 'NETMASK0=255.255.255.1', - 'GATEWAY0=192.168.1.2', - ]) - end - it { should contain_service('network') } - it { is_expected.to contain_file('route-eth1').that_notifies('Service[network]') } - end - - context 'singular parameters, restart => false' do - let(:pre_condition) { "file { 'ifcfg-eth1': }" } - let(:title) { 'eth1' } - let :params do { - :ipaddress => [ '192.168.2.1', ], - :netmask => [ '255.255.255.1', ], - :gateway => [ '192.168.1.2', ], - :restart => false, - :sched => nil, - } - end - let(:facts) {{ :osfamily => 'RedHat' }} - it { should contain_file('route-eth1').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/route-eth1' - )} - it 'should contain File[route-eth1] with contents "ADDRESS0=192.168.2.1\nNETMASK0=255.255.255.1\nGATEWAY0=192.168.1.2"' do - verify_contents(catalogue, 'route-eth1', [ - 'ADDRESS0=192.168.2.1', - 'NETMASK0=255.255.255.1', - 'GATEWAY0=192.168.1.2', - ]) - end - it { should contain_service('network') } - it { is_expected.to_not contain_file('route-eth1').that_notifies('Service[network]') } - end - - context 'array parameters' do - let(:pre_condition) { "file { 'ifcfg-eth2': }" } - let(:title) { 'eth2' } - let :params do { - :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', ], - :restart => true, - :sched => nil, - } - end - let(:facts) {{ :osfamily => 'RedHat' }} - it { should contain_file('route-eth2').with( - :ensure => 'present', - :mode => '0644', - :owner => 'root', - :group => 'root', - :path => '/etc/sysconfig/network-scripts/route-eth2' - )} - it 'should contain File[route-eth2] with contents "ADDRESS0=192.168.2.0\nADDRESS1=10.0.0.0\nNETMASK0=255.255.255.0\nNETMASK1=255.0.0.0\nGATEWAY0=192.168.1.1\nGATEWAY1=10.0.0.1"' do - verify_contents(catalogue, 'route-eth2', [ - 'ADDRESS0=192.168.2.0', - 'ADDRESS1=10.0.0.0', - 'NETMASK0=255.255.255.0', - 'NETMASK1=255.0.0.0', - 'GATEWAY0=192.168.1.1', - 'GATEWAY1=10.0.0.1', - ]) - end - it { should contain_service('network') } - end - -end