aboutsummaryrefslogtreecommitdiff
path: root/templates/host.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/host.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/host.conf.erb')
-rw-r--r--templates/host.conf.erb31
1 files changed, 20 insertions, 11 deletions
diff --git a/templates/host.conf.erb b/templates/host.conf.erb
index e6a7073..c483d62 100644
--- a/templates/host.conf.erb
+++ b/templates/host.conf.erb
@@ -1,16 +1,25 @@
-<%- @hash_data.sort.each do |host, datas| -%>
-<%- datas.fetch('interfaces').sort.each do |if_name, if_mac| -%>
+<%- @hash_data.sort.each do |host, data|
+ scope.function_validate_hash([data])
+ raise Puppet::ParseError, "Missing interfaces hash for host '#{host}'" unless data.has_key? 'interfaces'
+ data.fetch('interfaces').sort.each do |if_name, if_mac|
+ scope.function_validate_re([if_name, '^\S+$'])
+ scope.function_validate_string([if_mac])
+ scope.function_validate_re([if_mac, '^[A-Fa-f0-9:.]+$'])
+ -%>
host <%= host %>-<%= if_name %> {
hardware ethernet <%= if_mac %>;
-<% if datas.fetch('fixed_address', false) -%>
- fixed-address <%= datas.fetch('fixed_address') %>;
-<% else -%>
- fixed-address <%= host %>;
-<% end -%>
-<% if datas.fetch('option', false) -%>
- <%= datas.fetch('option') %>
-<% elsif @global_options -%>
- <%= @global_options %>
+<%
+ fixed_address = data.fetch('fixed_address', nil) || host
+ scope.function_validate_string([fixed_address])
+ scope.function_validate_re([fixed_address, '^\S+$'])
+ -%>
+ fixed-address <%= fixed_address %>;
+<%
+ options = data.fetch('options', nil) || @global_options
+ scope.function_validate_array([options])
+ unless options.empty?
+ -%>
+ <%= options.join(";\n") %>;
<% end -%>
}
<% end -%>