-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
634 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
fixtures: | ||
repositories: | ||
kmod: 'https://github.com/camptocamp/puppet-kmod' | ||
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib' | ||
boolean: 'https://github.com/adrienthebo/puppet-boolean' | ||
filemapper: 'https://github.com/adrienthebo/puppet-filemapper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'rake' | ||
require 'yaml' | ||
require 'rspec/core/rake_task' | ||
|
||
def fixtures(category) | ||
root = File.dirname(__FILE__) | ||
yaml = YAML.load_file(File.expand_path('.fixtures.yml', root)) | ||
|
||
fixtures = yaml["fixtures"] | ||
|
||
if fixtures.nil? | ||
raise ".fixtures.yml contained no top level 'fixtures' key" | ||
end | ||
|
||
fixtures[category] || {} | ||
rescue => e | ||
raise e, "Could not load fixture data: #{e}" | ||
end | ||
|
||
namespace :fixture do | ||
|
||
desc "Prepare all fixture repositories" | ||
task :prepare do | ||
fixtures("repositories").each_pair do |name, remote| | ||
fixture_target = "spec/fixtures/modules/#{name}" | ||
sh "git clone '#{remote}' '#{fixture_target}'" unless File.exist? fixture_target | ||
end | ||
end | ||
|
||
desc "Remove all fixture repositories" | ||
task :remove do | ||
fixtures["repositories"].each_pair do |name, remote| | ||
fixture_target = "spec/fixtures/modules/#{name}" | ||
FileUtils.rm_rf fixture_target if File.exist? fixture_target | ||
end | ||
end | ||
end | ||
|
||
desc "Run spec tests on an existing fixtures directory" | ||
RSpec::Core::RakeTask.new(:spec) do |t| | ||
t.rspec_opts = ['--color'] | ||
t.pattern = 'spec/{classes,defines,unit,functions,hosts}/**/*_spec.rb' | ||
end | ||
|
||
desc "Display the list of available rake tasks" | ||
task :help do | ||
system("rake -T") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Puppet::Parser::Functions.newfunction(:compact_hash, | ||
:type => :rvalue, | ||
:arity => 1, | ||
:doc => <<-EOD) do |args| | ||
compact_hash | ||
============ | ||
Compresses a hash to remove all elements whose values are nil or undef. | ||
Examples | ||
-------- | ||
$example = { | ||
'one' => 'two', | ||
'red' => undef, | ||
'blue' => nil, | ||
} | ||
compact_hash($example) | ||
# => { 'one => 'two' } | ||
EOD | ||
|
||
hash = args[0] | ||
|
||
hash.reject { |_, val| val.nil? or val == :undef } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# = 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, | ||
|
||
$mode = "active-backup", | ||
$miimon = "100", | ||
$downdelay = "200", | ||
$updelay = "200", | ||
$lacp_rate = "slow", | ||
$primary = $slaves[0], | ||
$primary_reselect = "always", | ||
$xmit_hash_policy = "layer2", | ||
) { | ||
|
||
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, | ||
method => $method, | ||
family => $family, | ||
onboot => $onboot, | ||
|
||
mode => $mode, | ||
miimon => $miimon, | ||
downdelay => $downdelay, | ||
updelay => $updelay, | ||
lacp_rate => $lacp_rate, | ||
primary => $primary, | ||
primary_reselect => $primary_reselect, | ||
xmit_hash_policy => $xmit_hash_policy, | ||
|
||
require => Kmod::Alias[$name], | ||
} | ||
} | ||
RedHat: { | ||
network::bond::redhat { $name: | ||
slaves => $slaves, | ||
ensure => $ensure, | ||
ipaddress => $ipaddress, | ||
netmask => $netmask, | ||
family => $family, | ||
method => $method, | ||
onboot => $onboot, | ||
|
||
mode => $mode, | ||
miimon => $miimon, | ||
downdelay => $downdelay, | ||
updelay => $updelay, | ||
lacp_rate => $lacp_rate, | ||
primary => $primary, | ||
primary_reselect => $primary_reselect, | ||
xmit_hash_policy => $xmit_hash_policy, | ||
|
||
require => Kmod::Alias[$name], | ||
} | ||
} | ||
default: { | ||
fail("network::bond does not support osfamily '${osfamily}'") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# = Define: network::bond::debian | ||
# | ||
# Instantiate bonded interfaces on Debian based systems. | ||
# | ||
# == See also | ||
# | ||
# * Debian Network Bonding http://wiki.debian.org/Bonding | ||
define network::bond::debian( | ||
$slaves, | ||
$ensure = present, | ||
$ipaddress = undef, | ||
$netmask = undef, | ||
$method = undef, | ||
$family = undef, | ||
$onboot = undef, | ||
|
||
$mode = undef, | ||
$miimon = undef, | ||
$downdelay = undef, | ||
$updelay = undef, | ||
$lacp_rate = undef, | ||
$primary = undef, | ||
$primary_reselect = undef, | ||
$xmit_hash_policy = undef, | ||
) { | ||
|
||
$raw = { | ||
'bond-slaves' => join($slaves, ' '), | ||
'bond-mode' => $mode, | ||
'bond-miimon' => $miimon, | ||
'bond-downdelay' => $downdelay, | ||
'bond-updelay' => $updelay, | ||
'bond-lacp-rate' => $lacp_rate, | ||
'bond-primary' => $primary, | ||
'bond-primary-reselect' => $primary_reselect, | ||
'bond-xmit-hash-policy' => $xmit_hash_policy, | ||
} | ||
|
||
$opts = compact_hash($raw) | ||
|
||
network_config { $name: | ||
ensure => $ensure, | ||
ipaddress => $ipaddress, | ||
netmask => $netmask, | ||
family => $family, | ||
method => $method, | ||
onboot => $onboot, | ||
options => $opts, | ||
} | ||
|
||
network_config { $slaves: | ||
ensure => absent, | ||
reconfigure => true, | ||
before => Network_config[$name], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# = Define: network::bond::redhat | ||
# | ||
# Instantiate bonded interfaces on Redhat based systems. | ||
# | ||
# == See also | ||
# | ||
# * Red Hat Deployment Guide 25.7.2 "Using Channel Bonding" https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Using_Channel_Bonding.html | ||
# | ||
define network::bond::redhat( | ||
$slaves, | ||
$ensure = present, | ||
$ipaddress = undef, | ||
$netmask = undef, | ||
$method = undef, | ||
$family = undef, | ||
$onboot = undef, | ||
|
||
$mode = undef, | ||
$miimon = undef, | ||
$downdelay = undef, | ||
$updelay = undef, | ||
$lacp_rate = undef, | ||
$primary = undef, | ||
$primary_reselect = undef, | ||
$xmit_hash_policy = undef, | ||
) { | ||
|
||
$bonding_opts = template("network/bond/opts-redhat.erb") | ||
|
||
network_config { $name: | ||
ensure => $ensure, | ||
method => $method, | ||
ipaddress => $ipaddress, | ||
netmask => $netmask, | ||
family => $family, | ||
onboot => $onboot, | ||
options => { | ||
'BONDING_OPTS' => $bonding_opts, | ||
} | ||
} | ||
|
||
network_config { $slaves: | ||
ensure => $ensure, | ||
method => static, | ||
onboot => true, | ||
options => { | ||
'MASTER' => $name, | ||
'SLAVE' => 'yes', | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class network::bond::setup { | ||
|
||
case $osfamily { | ||
RedHat: { | ||
# Redhat installs the ifenslave command with the iputils package which | ||
# is available by default | ||
} | ||
Debian: { | ||
package { 'ifenslave': | ||
ensure => present, | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
describe 'network::bond::setup', :type => :class do | ||
describe 'on Debian' do | ||
let(:facts) {{:osfamily => 'Debian'}} | ||
|
||
it { should contain_package('ifenslave') } | ||
end | ||
end |
Oops, something went wrong.