Skip to content

Commit

Permalink
Fall back to $ipaddress if $ipaddress_eth0 missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Cleal authored and ekohl committed Oct 7, 2013
1 parent dccd85d commit 6cc8016
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@

# Validate tftp params
validate_bool($tftp)
validate_string($tftp_servername)

# Validate dhcp params
validate_bool($dhcp, $dhcp_managed)
Expand Down
5 changes: 4 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
$tftp_syslinux_files = ['pxelinux.0','menu.c32','chain.c32','memdisk']
$tftp_root = $tftp::params::root
$tftp_dirs = ["${tftp_root}/pxelinux.cfg","${tftp_root}/boot"]
$tftp_servername = $ipaddress_eth0
$tftp_servername = $ipaddress_eth0 ? {
undef => $ipaddress,
default => $ipaddress_eth0,
}

# DHCP settings - requires optional DHCP puppet module
$dhcp = false
Expand Down
25 changes: 25 additions & 0 deletions spec/classes/foreman_proxy__config__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,29 @@
with({})
end
end

context 'with TFTP and no $ipaddress_eth0 fact' do
let :facts do
{
:fqdn => 'host.example.org',
:ipaddress => '127.0.1.2',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6',
:osfamily => 'RedHat',
}
end

let :pre_condition do
'class {"foreman_proxy":
tftp => true,
}'
end

it 'should set tftp_servername to $ipaddress' do
should contain_file('/etc/foreman-proxy/settings.yml').
with_content(%r{^:tftp: true$}).
with_content(%r{^:tftp_servername: 127.0.1.2$}).
with({})
end
end
end

0 comments on commit 6cc8016

Please sign in to comment.