aboutsummaryrefslogtreecommitdiff
path: root/templates/subnet.conf.erb
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-14 23:50:03 -0700
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-14 23:50:03 -0700
commit93895f1f039956ec9d02df511aaeaed885ae34bf (patch)
tree704909c98dc11bb9206b2c67f3f8557418507a21 /templates/subnet.conf.erb
parent87162a8cc3e47996160f85e1807f75b9ad741bc8 (diff)
parentc0f46562b70777b9a4a39429d94c49e869150c64 (diff)
downloadpuppet-dhcp-93895f1f039956ec9d02df511aaeaed885ae34bf.tar.gz
puppet-dhcp-93895f1f039956ec9d02df511aaeaed885ae34bf.tar.bz2
Merge pull request #5 from raphink/dev/cleanup
Cleanup, refactor…
Diffstat (limited to 'templates/subnet.conf.erb')
-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 -%>
}