aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-12 12:29:45 +0200
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-12 12:29:45 +0200
commiteda301b7ba8f8827d1c9973ffaba0c1c7a029d98 (patch)
tree39c12b6b18eb09be8ae63ab7d527cd1a6b8a5622 /templates
parente7cdc4e685a73d05be05ea9d6d0f854c4a3a6ab2 (diff)
downloadpuppet-dhcp-eda301b7ba8f8827d1c9973ffaba0c1c7a029d98.tar.gz
puppet-dhcp-eda301b7ba8f8827d1c9973ffaba0c1c7a029d98.tar.bz2
Add spec for dhcp::subnet and improve template and definition
Diffstat (limited to 'templates')
-rw-r--r--templates/subnet.conf.erb49
1 files changed, 22 insertions, 27 deletions
diff --git a/templates/subnet.conf.erb b/templates/subnet.conf.erb
index 89ca82f..11f9ed4 100644
--- a/templates/subnet.conf.erb
+++ b/templates/subnet.conf.erb
@@ -1,33 +1,28 @@
# File managed by puppet
-<% if netmask -%>
-subnet <%=name%> netmask <%=netmask%> {
-<% else -%>
-subnet <%=name%> netmask <%=netmask_eth0%> {
-<% end -%>
-<% if routers and not routers.empty? -%>
- option routers <%= routers.collect! {|i| "#{i}" }.join(",") %>;
-<% else -%>
- option routers <%=network_eth0%>;
-<% end -%>
-<% if subnet_mask -%>
- option subnet-mask <%=subnet_mask%>;
-<% elsif netmask -%>
- option subnet-mask <%=netmask%>;
-<% else -%>
- option subnet-mask <%=netmask_eth0%>;
-<% end -%>
- option broadcast-address <%=broadcast%>;
-<% if domain_name -%>
- option domain-name "<%=domain_name%>";
-<% else -%>
- option domain-name "<%=domain%>";
-<% end -%>
-<% if other_opts and not other_opts.empty? -%>
- <% if other_opts.is_a?(Array) -%>
-<%= other_opts.collect! {|i| " #{i};"}.join("\n") %>
+<%-
+ _netmask = @netmask || scope.lookupvar('::netmask_eth0')
+ scope.function_validate_re([_netmask, @ip_re]) -%>
+subnet <%= @name %> netmask <%= _netmask %> {
+<%-
+ _routers = @routers unless @routers.empty?
+ _routers ||= [scope.lookupvar('::netmask_eth0')]
+ scope.function_validate_array([_routers]) -%>
+ option routers <%= _routers.collect! {|i| "#{i}" }.join(',') %>;
+<%-
+ _subnet_mask = @subnet_mask || _netmask
+ scope.function_validate_re([_subnet_mask, @ip_re]) -%>
+ option subnet-mask <%= _subnet_mask %>;
+ option broadcast-address <%= @broadcast %>;
+<%-
+ _domain_name = @domain_name || scope.lookupvar('::domain')
+ scope.function_validate_re([_domain_name, '^\S+$']) -%>
+ option domain-name "<%= _domain_name %>";
+<% unless @other_opts.empty? -%>
+ <% if @other_opts.is_a?(Array) -%>
+<%= @other_opts.collect! {|i| " #{i};"}.join("\n") %>
<% else -%>
- <%=other_opts%>;
+ <%= @other_opts %>;
<% end -%>
<% end -%>
}