From 3fbb21df04f007d76f5c816e0ba7a3bd09fade54 Mon Sep 17 00:00:00 2001 From: Cédric Jeanneret Date: Tue, 26 Feb 2013 12:52:41 +0000 Subject: updated host.conf.erb in order to use hashes --- templates/host.conf.erb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'templates/host.conf.erb') diff --git a/templates/host.conf.erb b/templates/host.conf.erb index 20ba6e6..c3514d3 100644 --- a/templates/host.conf.erb +++ b/templates/host.conf.erb @@ -1,11 +1,15 @@ -host <%=name%> { - hardware ethernet <%=mac%>; -<% if fixed_address -%> - fixed-address <%=fixed_address%>; +<%- @hash_data.sort.each do |host, datas| -%> +<%- datas.fetch('interfaces').sort.each do |if_name, if_mac| -%> +host <%= host %>-<%= if_name %> { + hardware ethernet <%= if_mac %>; +<% if datas.fetch('fixed_address', false) -%> + fixed-address <%= datas.fetch('fixed_address') %> <% else -%> - fixed-address <%=name%>; + fixed-address <%= host %> <% end -%> -<% if options -%> - <%=options%> +<% if datas.fetch('option', false) -%> + <%= datas.fetch('option') %> <% end -%> } +<% end -%> +<% end -%> -- cgit v1.2.3 From ec52b52f8227e10a3724c21dde337a424bdcfe27 Mon Sep 17 00:00:00 2001 From: Cedric Jeanneret Date: Tue, 26 Feb 2013 14:29:55 +0100 Subject: updated and corrected template and dhcp::hosts --- manifests/hosts.pp | 4 ++++ templates/host.conf.erb | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'templates/host.conf.erb') diff --git a/manifests/hosts.pp b/manifests/hosts.pp index fd99600..b159449 100644 --- a/manifests/hosts.pp +++ b/manifests/hosts.pp @@ -4,6 +4,9 @@ # # Arguments # $template: dhcp host template - default: 'dhcp/host.conf.erb' +# $global_options: global options for the whole bunch of hosts. +# you may override it per host, setting the host "options" +# directly in the hash. # $subnet: targeted subnet # $hash_data: hash containing data - default form: # { @@ -35,6 +38,7 @@ define dhcp::hosts ( $hash_data, $subnet, + $global_options = false, $template = 'dhcp/host.conf.erb', ) { diff --git a/templates/host.conf.erb b/templates/host.conf.erb index c3514d3..e6a7073 100644 --- a/templates/host.conf.erb +++ b/templates/host.conf.erb @@ -3,12 +3,14 @@ host <%= host %>-<%= if_name %> { hardware ethernet <%= if_mac %>; <% if datas.fetch('fixed_address', false) -%> - fixed-address <%= datas.fetch('fixed_address') %> + fixed-address <%= datas.fetch('fixed_address') %>; <% else -%> - fixed-address <%= host %> + fixed-address <%= host %>; <% end -%> <% if datas.fetch('option', false) -%> <%= datas.fetch('option') %> +<% elsif @global_options -%> + <%= @global_options %> <% end -%> } <% end -%> -- cgit v1.2.3