diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb4abc..ab7ec07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ##### Changes * Correct some warnings from Puppet-lint. +* Add the possibility to choose between static, dhcp, bios or none for the channel network configuration. ##### Bugfixes * #2 Add a test for ipmi::ressource::user diff --git a/manifests/ressource/channel.pp b/manifests/ressource/channel.pp index a9bc32a..5eb4da0 100644 --- a/manifests/ressource/channel.pp +++ b/manifests/ressource/channel.pp @@ -24,23 +24,45 @@ # # Allow remote access from lan (+on+) or disable it (+off+). # -define ipmi::ressource::channel ( $channel_id = $title, $ipaddr = '0.0.0.0', $netmask = '0.0.0.0', $remote_access = 'on' ) { +define ipmi::ressource::channel ( $channel_id = $title, $ipsrc = 'static', $ipaddr = '0.0.0.0', $netmask = '0.0.0.0', $remote_access = 'on' ) { Exec { path => ['/bin','/sbin','/usr/bin','/usr/sbin'], logoutput => 'on_failure', } - # Set IP Address - exec { "IPMI set IP ${ipaddr}": - command => "ipmitool -I open lan set ${channel_id} ipaddr ${ipaddr}", - unless => "ipmitool -I open lan print ${channel_id} | grep '^IP .* ${ipaddr}'", + case $ipsrc { + 'static': { + # Set IP Address + exec { "IPMI set IP ${ipaddr}": + command => "ipmitool -I open lan set ${channel_id} ipaddr ${ipaddr}", + unless => "ipmitool -I open lan print ${channel_id} | grep '^IP .* ${ipaddr}'", + } + -> + # Set Netmask + exec { "IPMI set MASK ${netmask}": + command => "ipmitool -I open lan set ${channel_id} netmask ${netmask}", + unless => "ipmitool -I open lan print ${channel_id} | grep 'Mask .* ${netmask}'", + } + + } + + default: { + # Nothing to do + + } + } - -> - # Set Netmask - exec { "IPMI set MASK ${netmask}": - command => "ipmitool -I open lan set ${channel_id} netmask ${netmask}", - unless => "ipmitool -I open lan print ${channel_id} | grep 'Mask .* ${netmask}'", + + # Set the IP Address source for the channel + exec { "Set ${ipsrc} IP for channel ${channel_id}": + command => "ipmitool -I open lan set ${channel_id} ipsrc ${ipsrc}", + unless => $ipsrc ? { + 'static' => "ipmitool lan print ${channel_id} | grep -i '^IP Address Source.* Static'", + 'dhcp' => "ipmitool lan print ${channel_id} | grep -i '^IP Address Source.* DHCP'", + 'bios' => "ipmitool lan print ${channel_id} | grep -i '^IP Address Source.* BIOS'", + 'none' => "ipmitool lan print ${channel_id} | grep -i '^IP Address Source.* Unspecified'", + } } -> # Enable remote access