From 3044c0984daef7be9cb4451785a51c79b20fd4ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20Jens=C3=A5s?= <hjensas@redhat.com>
Date: Fri, 27 Sep 2019 01:06:20 +0200
Subject: [PATCH] Wrap ipv6 addresses in inspector-ipxe template

Closes-Bug: #1845566
Change-Id: Ic5cf47b03a13fccc16ad9410cb4939848e254bd1
---
 spec/classes/ironic_inspector_spec.rb | 14 ++++++++++++++
 templates/inspector_ipxe.erb          |  4 ++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/spec/classes/ironic_inspector_spec.rb b/spec/classes/ironic_inspector_spec.rb
index bb5d824d..4856dde7 100644
--- a/spec/classes/ironic_inspector_spec.rb
+++ b/spec/classes/ironic_inspector_spec.rb
@@ -287,6 +287,20 @@ describe 'ironic::inspector' do
               /kernel --timeout 30000/)
         end
       end
+
+      context 'when using ipv6' do
+        before :each do
+          params.merge!(
+            :listen_address     => 'fd00::1',
+          )
+        end
+
+        it 'should contain file /var/www/httpboot/inspector.ipxe' do
+          is_expected.to contain_file('/var/www/httpboot/inspector.ipxe').with_content(
+            /kernel http:\/\/\[fd00::1\]:3816\/agent.kernel ipa-inspection-callback-url=http:\/\/\[fd00::1\]:5050\/v1\/continue ipa-inspection-collectors=default.* foo=bar || goto retry_boot/
+          )
+        end
+      end
     end
 
     context 'when enabling ppc64le support' do
diff --git a/templates/inspector_ipxe.erb b/templates/inspector_ipxe.erb
index c80e299a..821ab2d7 100644
--- a/templates/inspector_ipxe.erb
+++ b/templates/inspector_ipxe.erb
@@ -2,6 +2,6 @@
 
 :retry_boot
 imgfree
-kernel <% if @ipxe_timeout_real != "0" %>--timeout <%= Integer(@ipxe_timeout_real) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip %>:<%= @http_port_real %>/<%= @kernel_filename %> ipa-inspection-callback-url=http://<%= @dnsmasq_local_ip %>:5050/v1/continue ipa-inspection-collectors=<%= @ramdisk_collectors %> systemd.journald.forward_to_console=yes BOOTIF=${mac} <%= @ramdisk_kernel_args %> initrd=<%= @ramdisk_filename %> || goto retry_boot
-initrd <% if @ipxe_timeout_real != "0" %>--timeout <%= Integer(@ipxe_timeout_real) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip %>:<%= @http_port_real %>/<%= @ramdisk_filename %> || goto retry_boot
+kernel <% if @ipxe_timeout_real != "0" %>--timeout <%= Integer(@ipxe_timeout_real) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip_real %>:<%= @http_port_real %>/<%= @kernel_filename %> ipa-inspection-callback-url=http://<%= @dnsmasq_local_ip_real %>:5050/v1/continue ipa-inspection-collectors=<%= @ramdisk_collectors %> systemd.journald.forward_to_console=yes BOOTIF=${mac} <%= @ramdisk_kernel_args %> initrd=<%= @ramdisk_filename %> || goto retry_boot
+initrd <% if @ipxe_timeout_real != "0" %>--timeout <%= Integer(@ipxe_timeout_real) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip_real %>:<%= @http_port_real %>/<%= @ramdisk_filename %> || goto retry_boot
 boot