Skip to content

Commit

Permalink
Add check for params dhcp_subnets
Browse files Browse the repository at this point in the history
Add new variable in params dhcp_subnets
Set dhcp_subnets accordingly via template dhcp.yml.erb
Fixes theforemanGH-109
  • Loading branch information
Andrei Brezan authored and andrei693 committed Apr 27, 2016
1 parent f9b886b commit 3e3548a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
#
# $dhcp_provider:: DHCP provider
#
# $dhcp_subnets:: Subnets list to restrict DHCP management to
# type:array
#
# $dhcp_option_domain:: DHCP use the dhcpd config option domain-name
# type:array
#
Expand Down Expand Up @@ -338,6 +341,7 @@
$dhcp_listen_on = $foreman_proxy::params::dhcp_listen_on,
$dhcp_managed = $foreman_proxy::params::dhcp_managed,
$dhcp_provider = $foreman_proxy::params::dhcp_provider,
$dhcp_subnets = $foreman_proxy::params::dhcp_subnets,
$dhcp_option_domain = $foreman_proxy::params::dhcp_option_domain,
$dhcp_search_domains = $foreman_proxy::params::dhcp_search_domains,
$dhcp_interface = $foreman_proxy::params::dhcp_interface,
Expand Down Expand Up @@ -420,6 +424,9 @@
validate_array($dhcp_option_domain)
validate_integer($dhcp_omapi_port)
validate_string($dhcp_provider, $dhcp_server)
if $dhcp_subnets {
validate_array($dhcp_subnets)
}

# Validate dns params
validate_bool($dns)
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
$dhcp_listen_on = 'https'
$dhcp_managed = true
$dhcp_provider = 'isc'
$dhcp_subnets = []
$dhcp_interface = 'eth0'
$dhcp_gateway = '192.168.100.1'
$dhcp_range = false
Expand Down
11 changes: 10 additions & 1 deletion templates/dhcp.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@
:use_provider: dhcp_<%= scope.lookupvar("foreman_proxy::dhcp_provider") %>
:server: <%= scope.lookupvar("foreman_proxy::dhcp_server") %>
# subnets restricts the subnets queried to a subset, to reduce the query time.
#:subnets: [192.168.205.0/255.255.255.128, 192.168.205.128/255.255.255.128]
<% if subnets = scope.lookupvar("foreman_proxy::dhcp_subnets") and subnets.any? -%>
:subnets:
<% subnets.each do |c| -%>
<%= " - #{c}" %>
<% end -%>
<% else -%>
#:subnets:
# - 192.168.205.0/255.255.255.128
# - 192.168.205.128/255.255.255.128
<% end -%>

0 comments on commit 3e3548a

Please sign in to comment.