From fe260aac4342ea0206d284d26b476b56f5983e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Wed, 12 Aug 2015 17:36:35 +0200 Subject: [PATCH 1/3] travis: introduce augeasversion fact, fix quoting (also fix a couple of linting errors) --- manifests/bond.pp | 12 ++++++------ manifests/bond/redhat.pp | 6 ++++-- manifests/bond/setup.pp | 11 ++++++----- spec/defines/bond_spec.rb | 21 ++++++++++++++++++--- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/manifests/bond.pp b/manifests/bond.pp index 717ed84a..fc9f737a 100644 --- a/manifests/bond.pp +++ b/manifests/bond.pp @@ -146,13 +146,13 @@ $options = undef, $slave_options = undef, - $mode = "active-backup", - $miimon = "100", - $downdelay = "200", - $updelay = "200", + $mode = 'active-backup', + $miimon = '100', + $downdelay = '200', + $updelay = '200', $primary = $slaves[0], - $primary_reselect = "always", - $xmit_hash_policy = "layer2", + $primary_reselect = 'always', + $xmit_hash_policy = 'layer2', ) { require network::bond::setup diff --git a/manifests/bond/redhat.pp b/manifests/bond/redhat.pp index 8c5accfc..21de9bd9 100644 --- a/manifests/bond/redhat.pp +++ b/manifests/bond/redhat.pp @@ -46,8 +46,10 @@ $opts_slave = merge( - { 'MASTER' => $name, - 'SLAVE' =>'yes' }, + { + 'MASTER' => $name, + 'SLAVE' => 'yes' + }, $slave_options ) diff --git a/manifests/bond/setup.pp b/manifests/bond/setup.pp index abe12521..c85934e6 100644 --- a/manifests/bond/setup.pp +++ b/manifests/bond/setup.pp @@ -1,14 +1,15 @@ +# make it work on debian.. class network::bond::setup { case $::osfamily { - RedHat: { - # Redhat installs the ifenslave command with the iputils package which - # is available by default - } - Debian: { + 'Debian': { package { 'ifenslave-2.6': ensure => present, } } + 'RedHat', default: { + # Redhat installs the ifenslave command with the iputils package which + # is available by default + } } } diff --git a/spec/defines/bond_spec.rb b/spec/defines/bond_spec.rb index 4901c27f..8d268619 100644 --- a/spec/defines/bond_spec.rb +++ b/spec/defines/bond_spec.rb @@ -26,7 +26,12 @@ describe 'on platform' do describe 'RedHat' do - let(:facts) {{:osfamily => 'RedHat'}} + let(:facts) do + { + :osfamily => 'RedHat', + :augeasversion => '1.4.0', + } + end it "should create 'network::bond::redhat'" do should contain_network__bond__redhat('bond0') @@ -38,7 +43,12 @@ end describe 'Debian' do - let(:facts) {{:osfamily => 'Debian'}} + let(:facts) do + { + :osfamily => 'Debian', + :augeasversion => '1.4.0', + } + end it "should create 'network::bond::debian'" do should contain_network__bond__debian('bond0') @@ -59,7 +69,12 @@ end describe 'configuring the kernel bonding device' do - let(:facts) {{:osfamily => 'Debian'}} + let(:facts) do + { + :osfamily => 'Debian', + :augeasversion => '1.4.0', + } + end it { should contain_class('network::bond::setup') } From 61628bf30adb288f45f2e9d2a17e5137f2390030 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 12 Aug 2015 18:08:56 +0100 Subject: [PATCH 2/3] Update spec_helper to work with puppet 4 --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e9f15aa5..3734b796 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,6 +16,7 @@ config.module_path = File.join(fixture_path, 'modules') config.manifest_dir = File.join(fixture_path, 'manifests') + config.environmentpath = File.expand_path(File.join(Dir.pwd, 'spec')) end # --- From 7ab3038fb9f0de9a5edd5af444e22ced4a240a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Thu, 13 Aug 2015 01:03:07 +0200 Subject: [PATCH 3/3] bond tests: for puppet 4, reject /all/ (potentially) empty fields --- templates/bond/opts-redhat.erb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/bond/opts-redhat.erb b/templates/bond/opts-redhat.erb index cd201039..37fd1f8a 100644 --- a/templates/bond/opts-redhat.erb +++ b/templates/bond/opts-redhat.erb @@ -1 +1,4 @@ -<%= %w[mode miimon downdelay updelay lacp_rate primary primary_reselect xmit_hash_policy].reject { |thing| scope.lookupvar(thing) == :undef }.map {|thing| "#{thing}=#{scope.lookupvar(thing)}"}.join(' ') -%> +<%= %w[mode miimon downdelay updelay lacp_rate primary primary_reselect xmit_hash_policy].reject { + |option| scope.lookupvar(option).nil? || scope.lookupvar(option) == :undef || scope.lookupvar(option) == :absent || scope.lookupvar(option).empty? }.map { + |key| "#{key}=#{scope.lookupvar(key)}" + }.join(' ') -%>