Skip to content

Commit

Permalink
More updates
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Oct 6, 2024
1 parent de25ed4 commit f7fc045
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 282 deletions.
20 changes: 10 additions & 10 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
fixtures:
repositories:
forge_modules:
yumrepo_core:
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
repo: puppetlabs/yumrepo_core
stdlib:
repo: https://github.com/puppetlabs/puppetlabs-stdlib.git
ref: v8.6.0
repo: puppetlabs/stdlib
augeasproviders_core:
repo: https://github.com/voxpupuli/puppet-augeasproviders_core.git
repo: puppet/augeasproviders_core
augeasproviders_shellvar:
repo: https://github.com/voxpupuli/puppet-augeasproviders_shellvar.git
repo: puppet/augeasproviders_shellvar
systemd:
repo: https://github.com/voxpupuli/puppet-systemd.git
repo: puppet/systemd
rsyslog:
repo: https://github.com/saz/puppet-rsyslog.git
repo: saz/rsyslog
network:
repo: https://github.com/voxpupuli/puppet-network.git
ref: v2.1.0
repo: puppet/network
filemapper:
repo: puppet/filemapper
symlinks:
mofed: "#{source_dir}"
77 changes: 34 additions & 43 deletions manifests/interface.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Optional[Stdlib::IP::Address] $netmask = undef ,
Optional[Stdlib::IP::Address] $gateway = undef,
Boolean $enable = true,
Optional[Variant[Boolean, Enum['yes','no']]] $nm_controlled = undef,
Optional[Enum['yes','no']] $nm_controlled = undef,
Enum['yes', 'no'] $connected_mode = 'yes',
Optional[Integer] $mtu = undef,
Boolean $bonding = false,
Expand All @@ -55,20 +55,10 @@

include mofed

$onboot = $enable ? {
true => 'yes',
false => 'no',
default => $enable,
}

$options_extra_redhat = {
'CONNECTED_MODE' => $connected_mode,
}

if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '8') >= 0 {
$_nm_controlled = pick($nm_controlled, false)
} else {
if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '7') == 0 {
$_nm_controlled = pick($nm_controlled, 'no')
} else {
$_nm_controlled = $nm_controlled
}

if $bonding {
Expand All @@ -79,53 +69,54 @@
# Setup interfaces for the slaves
$bonding_slaves.each |String $ifname| {
network_config { $ifname:
ensure => $ensure,
onboot => $onboot,
master => $name,
slave => 'yes',
mtu => $mtu,
method => 'static',
hotplug => 'false',
options => {
ensure => $ensure,
onboot => $enable,
mtu => $mtu,
method => 'static',
hotplug => false,
options => {
'TYPE' => 'Infiniband',
'MASTER' => $name,
'SLAVE' => 'yes',
'NM_CONTROLLED' => $_nm_controlled,
'CONNECTED_MODE' => $connected_mode,
}
}.filter |$k, $v| { $v =~ NotUndef },
}
}

# Setup the bonding interface
network_config { $name:
ensure => $ensure,
onboot => $onboot,
ipaddress => $ipaddr,
netmask => $netmask,
bonding_master => 'yes',
bonding_opts => $bonding_opts,
mtu => $mtu,
method => 'static',
hotplug => 'false',
options => {
ensure => $ensure,
onboot => $enable,
ipaddress => $ipaddr,
netmask => $netmask,
mtu => $mtu,
method => 'static',
hotplug => false,
options => {
'TYPE' => 'Infiniband',
'BONDING_MASTER' => 'yes',
'BONDING_OPTS' => $bonding_opts,
'NM_CONTROLLED' => $_nm_controlled,
'GATEWAY' => $gateway,
'CONNECTED_MODE' => $connected_mode,
}
}.filter |$k, $v| { $v =~ NotUndef },
}
} else {
network_config { $name:
ensure => $ensure,
onboot => $onboot,
ipaddress => $ipaddr,
netmask => $netmask,
mtu => $mtu,
method => 'static',
hotplug => 'false',
options => {
ensure => $ensure,
onboot => $enable,
ipaddress => $ipaddr,
netmask => $netmask,
mtu => $mtu,
method => 'static',
hotplug => false,
options => {
'TYPE' => 'Infiniband',
'GATEWAY' => $gateway,
'NM_CONTROLLED' => $_nm_controlled,
'CONNECTED_MODE' => $connected_mode,
}
}.filter |$k, $v| { $v =~ NotUndef },
}
}
}
5 changes: 4 additions & 1 deletion manifests/opensm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@
'present': {
$package_ensure = 'present'
$file_ensure = 'file'
$unit_ensure = 'present'
$service_ensure = 'running'
$service_enable = true
}
'absent': {
$package_ensure = 'absent'
$file_ensure = 'absent'
$unit_ensure = 'absent'
$service_ensure = 'stopped'
$service_enable = false
}
'disabled': {
$package_ensure = 'present'
$file_ensure = 'file'
$unit_ensure = 'present'
$service_ensure = 'stopped'
$service_enable = false
}
Expand Down Expand Up @@ -82,7 +85,7 @@
}

systemd::unit_file { '[email protected]':
ensure => $file_ensure,
ensure => $unit_ensure,
source => 'puppet:///modules/mofed/opensm/[email protected]',
}

Expand Down
8 changes: 1 addition & 7 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
class mofed::service {
assert_private()

if $mofed::openibd_service_enable in ['UNSET', 'undef'] {
$_enable = undef
} else {
$_enable = $mofed::openibd_service_enable
}

if $mofed::manage_service {
service { 'openibd':
ensure => $mofed::openibd_service_ensure,
enable => $_enable,
enable => $mofed::openibd_service_enable,
name => $mofed::openibd_service_name,
hasstatus => $mofed::openibd_service_hasstatus,
hasrestart => $mofed::openibd_service_hasrestart,
Expand Down
5 changes: 4 additions & 1 deletion manifests/srp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@
$package_ensure = 'present'
$file_ensure = 'file'
$srp_load = 'yes'
$unit_ensure = 'present'
$service_ensure = 'running'
$service_enable = true
}
'absent': {
$package_ensure = 'absent'
$file_ensure = 'absent'
$srp_load = 'no'
$unit_ensure = 'absent'
$service_ensure = 'stopped'
$service_enable = false
}
'disabled': {
$package_ensure = 'present'
$file_ensure = 'file'
$srp_load = 'yes'
$unit_ensure = 'present'
$service_ensure = 'stopped'
$service_enable = false
}
Expand Down Expand Up @@ -138,7 +141,7 @@
}

systemd::unit_file { '[email protected]':
ensure => $file_ensure,
ensure => $unit_ensure,
source => 'puppet:///modules/mofed/srp/[email protected]',
}

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/opensm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

if facts[:operatingsystemrelease].to_i >= 7.0
it do
is_expected.to contain_systemd__unit_file('[email protected]').with_ensure('file')
is_expected.to contain_systemd__unit_file('[email protected]').with_ensure('present')
end

it do
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/srp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

if facts[:operatingsystemrelease].to_i >= 7.0
it do
is_expected.to contain_systemd__unit_file('[email protected]').with_ensure('file')
is_expected.to contain_systemd__unit_file('[email protected]').with_ensure('present')
end

it do
Expand Down
40 changes: 18 additions & 22 deletions spec/defines/interface_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,58 @@
default_params
end

let :fixture_suffix do
if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i >= 8
'-no_nm_controlled'
else
''
end
end

it do
is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with('ensure' => 'present',
'owner' => 'root',
'group' => 'root',
'mode' => '0644')
end

it do
is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0') \
.with_content(my_fixture_read("ifcfg-ib0_with_connected_mode#{fixture_suffix}"))
is_expected.to contain_network_config('ib0').with(
ensure: 'present',
onboot: true,
ipaddress: '192.168.1.1',
netmask: '255.255.255.0',
mtu: nil,
method: 'static',
hotplug: false,
options: {
'TYPE' => 'Infiniband',

Check failure on line 37 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.

Check failure on line 37 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Layout/HashAlignment: Align the keys of a hash literal if they span more than one line.
'CONNECTED_MODE' => 'yes',

Check failure on line 38 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.

Check failure on line 38 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Style/TrailingCommaInHashLiteral: Avoid comma after the last item of a hash.
}

Check failure on line 39 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call. (https://rubystyle.guide#no-trailing-params-comma)

Check failure on line 39 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call. (https://rubystyle.guide#no-trailing-params-comma)
)
end

context 'when ensure => absent' do
let(:params) { { ensure: 'absent' } }

it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_ensure('absent') }
it { is_expected.to contain_network_config('ib0').with_ensure('absent') }
end

context 'when enable => false' do
let :params do
default_params.merge(enable: false)
end

it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_with_onboot_no#{fixture_suffix}")) }
it { is_expected.to contain_network_config('ib0').with_onboot(false) }
end

context 'when connected_mode => no' do
let :params do
default_params.merge(connected_mode: 'no')
end

it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_without_connected_mode#{fixture_suffix}")) }
it { is_expected.to contain_network_config('ib0').with_options({'TYPE' => 'Infiniband', 'CONNECTED_MODE' => 'no'}) }

Check failure on line 62 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Layout/SpaceInsideHashLiteralBraces: Space inside { missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 62 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Layout/SpaceInsideHashLiteralBraces: Space inside } missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 62 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Layout/SpaceInsideHashLiteralBraces: Space inside { missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 62 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Layout/SpaceInsideHashLiteralBraces: Space inside } missing. (https://rubystyle.guide#spaces-braces)
end

context 'when mtu => 65520' do
let :params do
default_params.merge(mtu: 65_520)
end

it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_with_mtu#{fixture_suffix}")) }
it { is_expected.to contain_network_config('ib0').with_mtu(65_520) }
end

context 'when gateway => 192.168.1.254' do
let :params do
default_params.merge(gateway: '192.168.1.254')
end

it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_with_gateway#{fixture_suffix}")) }
it { is_expected.to contain_network_config('ib0').with_options({'TYPE' => 'Infiniband', 'GATEWAY' => '192.168.1.254', 'CONNECTED_MODE' => 'yes'}) }

Check failure on line 78 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Layout/SpaceInsideHashLiteralBraces: Space inside { missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 78 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.7)

Layout/SpaceInsideHashLiteralBraces: Space inside } missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 78 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Layout/SpaceInsideHashLiteralBraces: Space inside { missing. (https://rubystyle.guide#spaces-braces)

Check failure on line 78 in spec/defines/interface_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2)

Layout/SpaceInsideHashLiteralBraces: Space inside } missing. (https://rubystyle.guide#spaces-braces)
end

context 'when bonding => true' do
Expand Down
14 changes: 0 additions & 14 deletions spec/fixtures/defines/interface/ifcfg-bond-master-ibbond0

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions spec/fixtures/defines/interface/ifcfg-bond-slave-ib0

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions spec/fixtures/defines/interface/ifcfg-bond-slave-ib1

This file was deleted.

Loading

0 comments on commit f7fc045

Please sign in to comment.