Sha256: 62b987f090b11b134e704267a44fccb711db67ac1ab98913e10c83bd4094e248

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

#!ipxe
# Example foreman_bootdisk host template
# This template is rendered for use inside a host-specific boot disk.
#
# Copy this template to customize it, the original is read-only.

<%
interface = @host.provision_interface
bootdisk_raise(N_('Host has no provisioning interface defined')) unless interface
bootdisk_raise(N_('Host has no IP address defined')) if interface.ip.nil? || interface.ip.empty?
bootdisk_raise(N_('Host has no subnet defined')) unless interface.subnet
bootdisk_raise(N_('Host has no domain defined')) unless interface.domain
%>

echo Foreman Bootdisk: Host image (<%= @host.name %>)

# loop over net* until the host's MAC matches
<% (0..32).each do |i| -%>
:net<%= i %>
isset ${net<%= i -%>/mac} || goto no_nic
echo net<%= i -%> is a ${net<%= i -%>/chip} with MAC ${net<%= i -%>/mac}
iseq ${net<%= i -%>/mac} <%= interface.mac -%> || goto net<%= i+1 %>
set idx:int32 <%= i %>
goto loop_success
<% end -%>

:loop_success
echo Configuring net${idx} for static IP address <%= interface.ip %>
ifopen net${idx}
set netX/ip <%= interface.ip %>
set netX/netmask <%= interface.subnet.mask %>
<% if interface.subnet.gateway.present? %>
set netX/gateway <%= interface.subnet.gateway %>
<% end %>
ifstat net${idx}
route

# Note: When multiple DNS servers are specified, only the first
# server will be used. See: http://ipxe.org/cfg/dns
<% dns = interface.subnet.dns_servers.first -%>
<% if dns.present? -%>
echo Using DNS <%= dns %>
set dns <%= dns %>
set domain <%= interface.domain.to_s %>
<% end %>

# Chainload from Foreman rather than embedding OS info here, so the behaviour
# is entirely dynamic.
chain <%= bootdisk_chain_url %>
exit 0

:no_nic
echo Cannot find interface with MAC <%= interface.mac %>, spawning shell
shell

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_bootdisk-15.0.0 app/views/foreman_bootdisk/host.erb