Clean up ironic::drivers::pxe
Detect boot file name and boot templates based on ipxe_enabled (unfortunately, that required an explicit default for ipxe_enabled instead of os_service_default). Switch quite a few parameters to os_service_default, where our defaults don't differ from upstream defaults. TFTP root path is left alone, as it will be refactored soon. Deprecate three parameters that do not exist in ironic (at least now). Change-Id: Ic6844bf313a08b8481d3474185d08d878ff52b5a
This commit is contained in:
parent
04dbd09b5e
commit
b5d2769041
@ -19,6 +19,66 @@
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*ipxe_enabled*]
|
||||
# (optional) Enable ipxe support
|
||||
# Defaults to false.
|
||||
#
|
||||
# [*pxe_append_params*]
|
||||
# (optional) Additional append parameters for baremetal PXE boot.
|
||||
# Should be valid pxe parameters
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*pxe_bootfile_name*]
|
||||
# (optional) Bootfile DHCP parameter.
|
||||
# If not set, its value is detected based on ipxe_enabled.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration.
|
||||
# If set, should be an valid template file. Otherwise, its value is detected
|
||||
# based on ipxe_enabled.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*tftp_server*]
|
||||
# (optional) IP address of Ironic compute node's tftp server.
|
||||
# Should be an valid IP address
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*tftp_root*]
|
||||
# (optional) Ironic compute node's tftp root path.
|
||||
# Should be an valid path
|
||||
# Defaults to '/tftpboot'.
|
||||
#
|
||||
# [*images_path*]
|
||||
# (optional) Directory where images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*tftp_master_path*]
|
||||
# (optional) Directory where master tftp images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/tftpboot/master_images'.
|
||||
#
|
||||
# [*instance_master_path*]
|
||||
# (optional) Directory where master tftp images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*uefi_pxe_bootfile_name*]
|
||||
# (optional) Bootfile DHCP parameter for UEFI boot mode.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*uefi_pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration for UEFI boot loader.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*ipxe_timeout*]
|
||||
# (optional) ipxe timeout in second.
|
||||
# Should be an valid integer
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# DEPRECATED
|
||||
#
|
||||
# [*deploy_kernel*]
|
||||
# (optional) Default kernel image ID used in deployment phase.
|
||||
# Should be an valid id
|
||||
@ -29,90 +89,44 @@
|
||||
# Should be an valid id
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*pxe_append_params*]
|
||||
# (optional) Additional append parameters for baremetal PXE boot.
|
||||
# Should be valid pxe parameters
|
||||
# Defaults to 'nofb nomodeset vga=normal'.
|
||||
#
|
||||
# [*pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration.
|
||||
# Should be an valid template file
|
||||
# Defaults to '$pybasedir/drivers/modules/pxe_config.template'.
|
||||
#
|
||||
# [*pxe_deploy_timeout*]
|
||||
# (optional) Timeout for PXE deployments.
|
||||
# Should be an valid integer
|
||||
# Defaults to '0' for unlimited.
|
||||
#
|
||||
# [*tftp_server*]
|
||||
# (optional) IP address of Ironic compute node's tftp server.
|
||||
# Should be an valid IP address
|
||||
# Defaults to '$my_ip'.
|
||||
#
|
||||
# [*tftp_root*]
|
||||
# (optional) Ironic compute node's tftp root path.
|
||||
# Should be an valid path
|
||||
# Defaults to '/tftpboot'.
|
||||
#
|
||||
# [*images_path*]
|
||||
# (optional) Directory where images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/tftpboot'.
|
||||
#
|
||||
# [*tftp_master_path*]
|
||||
# (optional) Directory where master tftp images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/tftpboot/master_images'.
|
||||
#
|
||||
# [*instance_master_path*]
|
||||
# (optional) Directory where master tftp images are stored on disk.
|
||||
# Should be an valid directory
|
||||
# Defaults to '/var/lib/ironic/master_images'.
|
||||
#
|
||||
# [*uefi_pxe_bootfile_name*]
|
||||
# (optional) Bootfile DHCP parameter for UEFI boot mode.
|
||||
# Defaults to 'elilo.efi'.
|
||||
#
|
||||
# [*uefi_pxe_config_template*]
|
||||
# (optional) Template file for PXE configuration for UEFI boot loader.
|
||||
# Defaults to '$pybasedir/drivers/modules/elilo_efi_pxe_config.template'.
|
||||
#
|
||||
# [*ipxe_timeout*]
|
||||
# (optional) ipxe timeout in second.
|
||||
# Should be an valid integer
|
||||
# Defaults to '0' for unlimited.
|
||||
#
|
||||
# [*ipxe_enabled*]
|
||||
# (optional) Enable ipxe support
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*pxe_bootfile_name*]
|
||||
# (optional) Bootfile DHCP parameter
|
||||
# Defaults to $::os_service_default.
|
||||
# Defaults to undef
|
||||
|
||||
class ironic::drivers::pxe (
|
||||
$ipxe_enabled = false,
|
||||
$pxe_append_params = $::os_service_default,
|
||||
$pxe_bootfile_name = undef,
|
||||
$pxe_config_template = undef,
|
||||
$tftp_server = $::os_service_default,
|
||||
$tftp_root = '/tftpboot',
|
||||
$images_path = $::os_service_default,
|
||||
$tftp_master_path = '/tftpboot/master_images',
|
||||
$instance_master_path = $::os_service_default,
|
||||
$uefi_pxe_bootfile_name = $::os_service_default,
|
||||
$uefi_pxe_config_template = $::os_service_default,
|
||||
$ipxe_timeout = $::os_service_default,
|
||||
# Deprecated
|
||||
$deploy_kernel = undef,
|
||||
$deploy_ramdisk = undef,
|
||||
$pxe_append_params = 'nofb nomodeset vga=normal',
|
||||
$pxe_config_template = '$pybasedir/drivers/modules/pxe_config.template',
|
||||
$pxe_deploy_timeout = '0',
|
||||
$tftp_server = '$my_ip',
|
||||
$tftp_root = '/tftpboot',
|
||||
$images_path = '/var/lib/ironic/images/',
|
||||
$tftp_master_path = '/tftpboot/master_images',
|
||||
$instance_master_path = '/var/lib/ironic/master_images',
|
||||
$uefi_pxe_bootfile_name = 'elilo.efi',
|
||||
$uefi_pxe_config_template = '$pybasedir/drivers/modules/elilo_efi_pxe_config.template',
|
||||
$ipxe_timeout = '0',
|
||||
$ipxe_enabled = $::os_service_default,
|
||||
$pxe_bootfile_name = $::os_service_default,
|
||||
$pxe_deploy_timeout = undef,
|
||||
) {
|
||||
|
||||
if $ipxe_enabled {
|
||||
$pxe_bootfile_name_real = pick($pxe_bootfile_name, 'undionly.kpxe')
|
||||
$pxe_config_template_real = pick($pxe_config_template, '$pybasedir/drivers/modules/ipxe_config.template')
|
||||
} else {
|
||||
$pxe_bootfile_name_real = pick($pxe_bootfile_name, 'pxelinux.0')
|
||||
$pxe_config_template_real = pick($pxe_config_template, '$pybasedir/drivers/modules/pxe_config.template')
|
||||
}
|
||||
|
||||
# Configure ironic.conf
|
||||
ironic_config {
|
||||
'pxe/ipxe_enabled': value => $ipxe_enabled;
|
||||
'pxe/pxe_append_params': value => $pxe_append_params;
|
||||
'pxe/pxe_config_template': value => $pxe_config_template;
|
||||
'pxe/pxe_deploy_timeout': value => $pxe_deploy_timeout;
|
||||
'pxe/pxe_bootfile_name': value => $pxe_bootfile_name_real;
|
||||
'pxe/pxe_config_template': value => $pxe_config_template_real;
|
||||
'pxe/tftp_server': value => $tftp_server;
|
||||
'pxe/tftp_root': value => $tftp_root;
|
||||
'pxe/images_path': value => $images_path;
|
||||
@ -121,20 +135,18 @@ class ironic::drivers::pxe (
|
||||
'pxe/uefi_pxe_bootfile_name': value => $uefi_pxe_bootfile_name;
|
||||
'pxe/uefi_pxe_config_template': value => $uefi_pxe_config_template;
|
||||
'pxe/ipxe_timeout': value => $ipxe_timeout;
|
||||
'pxe/ipxe_enabled': value => $ipxe_enabled;
|
||||
'pxe/pxe_bootfile_name': value => $pxe_bootfile_name;
|
||||
}
|
||||
|
||||
if $deploy_kernel {
|
||||
ironic_config {
|
||||
'pxe/deploy_kernel': value => $deploy_kernel;
|
||||
}
|
||||
warning('deploy_kernel option does nothing and will be removed soon')
|
||||
}
|
||||
|
||||
if $deploy_ramdisk {
|
||||
ironic_config {
|
||||
'pxe/deploy_ramdisk': value => $deploy_ramdisk;
|
||||
}
|
||||
warning('deploy_ramdisk option does nothing and will be removed soon')
|
||||
}
|
||||
|
||||
if $pxe_deploy_timeout {
|
||||
warning('deploy_ramdisk option does nothing and will be removed soon')
|
||||
}
|
||||
|
||||
}
|
||||
|
8
releasenotes/notes/drivers-pxe-5ced870285f654ad.yaml
Normal file
8
releasenotes/notes/drivers-pxe-5ced870285f654ad.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- The default pxe_bootfile_name and pxe_config_template are now detected
|
||||
based on ipxe_enabled instead of hardcoding TFTP values.
|
||||
deprecations:
|
||||
- |
|
||||
The following options from ``ironic::drivers::pxe`` do not do anything and
|
||||
are deprecated: "deploy_kernel", "deploy_ramdisk", "pxe_deploy_timeout".
|
@ -23,17 +23,10 @@ require 'spec_helper'
|
||||
describe 'ironic::drivers::pxe' do
|
||||
|
||||
let :default_params do
|
||||
{ :pxe_append_params => 'nofb nomodeset vga=normal',
|
||||
{ :pxe_bootfile_name => 'pxelinux.0',
|
||||
:pxe_config_template => '$pybasedir/drivers/modules/pxe_config.template',
|
||||
:pxe_deploy_timeout => '0',
|
||||
:tftp_server => '$my_ip',
|
||||
:tftp_root => '/tftpboot',
|
||||
:images_path => '/var/lib/ironic/images/',
|
||||
:tftp_master_path => '/tftpboot/master_images',
|
||||
:instance_master_path => '/var/lib/ironic/master_images',
|
||||
:uefi_pxe_bootfile_name => 'elilo.efi',
|
||||
:uefi_pxe_config_template => '$pybasedir/drivers/modules/elilo_efi_pxe_config.template',
|
||||
:ipxe_timeout => 0,
|
||||
}
|
||||
end
|
||||
|
||||
@ -47,28 +40,46 @@ describe 'ironic::drivers::pxe' do
|
||||
end
|
||||
|
||||
it 'configures ironic.conf' do
|
||||
is_expected.to contain_ironic_config('pxe/pxe_append_params').with_value(p[:pxe_append_params])
|
||||
is_expected.to contain_ironic_config('pxe/pxe_append_params').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/pxe_bootfile_name').with_value(p[:pxe_bootfile_name])
|
||||
is_expected.to contain_ironic_config('pxe/pxe_config_template').with_value(p[:pxe_config_template])
|
||||
is_expected.to contain_ironic_config('pxe/pxe_deploy_timeout').with_value(p[:pxe_deploy_timeout])
|
||||
is_expected.to contain_ironic_config('pxe/tftp_server').with_value(p[:tftp_server])
|
||||
is_expected.to contain_ironic_config('pxe/tftp_server').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/tftp_root').with_value(p[:tftp_root])
|
||||
is_expected.to contain_ironic_config('pxe/images_path').with_value(p[:images_path])
|
||||
is_expected.to contain_ironic_config('pxe/images_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/tftp_master_path').with_value(p[:tftp_master_path])
|
||||
is_expected.to contain_ironic_config('pxe/instance_master_path').with_value(p[:instance_master_path])
|
||||
is_expected.to contain_ironic_config('pxe/uefi_pxe_bootfile_name').with_value(p[:uefi_pxe_bootfile_name])
|
||||
is_expected.to contain_ironic_config('pxe/uefi_pxe_config_template').with_value(p[:uefi_pxe_config_template])
|
||||
is_expected.to contain_ironic_config('pxe/ipxe_enabled').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/pxe_bootfile_name').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/instance_master_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/uefi_pxe_bootfile_name').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/uefi_pxe_config_template').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/ipxe_enabled').with_value(false)
|
||||
end
|
||||
|
||||
context 'when overriding only ipxe_enabled' do
|
||||
before do
|
||||
params.merge!(
|
||||
:ipxe_enabled => true,
|
||||
)
|
||||
end
|
||||
|
||||
it 'detects correct boot parameters' do
|
||||
is_expected.to contain_ironic_config('pxe/pxe_append_params').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/pxe_bootfile_name').with_value('undionly.kpxe')
|
||||
is_expected.to contain_ironic_config('pxe/pxe_config_template').with_value('$pybasedir/drivers/modules/ipxe_config.template')
|
||||
is_expected.to contain_ironic_config('pxe/tftp_server').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/tftp_root').with_value(p[:tftp_root])
|
||||
is_expected.to contain_ironic_config('pxe/images_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/tftp_master_path').with_value(p[:tftp_master_path])
|
||||
is_expected.to contain_ironic_config('pxe/instance_master_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/uefi_pxe_bootfile_name').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/uefi_pxe_config_template').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_ironic_config('pxe/ipxe_enabled').with_value(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when overriding parameters' do
|
||||
before do
|
||||
params.merge!(
|
||||
:deploy_kernel => 'foo',
|
||||
:deploy_ramdisk => 'bar',
|
||||
:pxe_append_params => 'foo',
|
||||
:pxe_config_template => 'bar',
|
||||
:pxe_deploy_timeout => '40',
|
||||
:tftp_server => '192.168.0.1',
|
||||
:tftp_root => '/mnt/ftp',
|
||||
:images_path => '/mnt/images',
|
||||
@ -83,11 +94,8 @@ describe 'ironic::drivers::pxe' do
|
||||
end
|
||||
|
||||
it 'should replace default parameter with new value' do
|
||||
is_expected.to contain_ironic_config('pxe/deploy_kernel').with_value(p[:deploy_kernel])
|
||||
is_expected.to contain_ironic_config('pxe/deploy_ramdisk').with_value(p[:deploy_ramdisk])
|
||||
is_expected.to contain_ironic_config('pxe/pxe_append_params').with_value(p[:pxe_append_params])
|
||||
is_expected.to contain_ironic_config('pxe/pxe_config_template').with_value(p[:pxe_config_template])
|
||||
is_expected.to contain_ironic_config('pxe/pxe_deploy_timeout').with_value(p[:pxe_deploy_timeout])
|
||||
is_expected.to contain_ironic_config('pxe/tftp_server').with_value(p[:tftp_server])
|
||||
is_expected.to contain_ironic_config('pxe/tftp_root').with_value(p[:tftp_root])
|
||||
is_expected.to contain_ironic_config('pxe/images_path').with_value(p[:images_path])
|
||||
|
Loading…
Reference in New Issue
Block a user