Skip to content

Commit

Permalink
Merge "Introduce ironic::pxe class"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 2, 2016
2 parents 7b74836 + 0376a5f commit 3e970e4
Show file tree
Hide file tree
Showing 13 changed files with 481 additions and 75 deletions.
8 changes: 6 additions & 2 deletions manifests/drivers/pxe.pp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
$pxe_deploy_timeout = undef,
) {

include ::ironic::pxe::common
$tftp_root_real = pick($::ironic::pxe::common::tftp_root, $tftp_root)
$ipxe_timeout_real = pick($::ironic::pxe::common::ipxe_timeout, $ipxe_timeout)

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')
Expand All @@ -128,13 +132,13 @@
'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/tftp_root': value => $tftp_root_real;
'pxe/images_path': value => $images_path;
'pxe/tftp_master_path': value => $tftp_master_path;
'pxe/instance_master_path': value => $instance_master_path;
'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_timeout': value => $ipxe_timeout_real;
}

if $deploy_kernel {
Expand Down
56 changes: 25 additions & 31 deletions manifests/inspector.pp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@
#
# [*ipxe_timeout*]
# (optional) ipxe timeout in second. Should be an integer.
# Defaults to '0' for unlimited.
# Defaults to $::os_service_default
#
# [*http_port*]
# (optional) port used by the HTTP service serving introspection images.
# Defaults to 8088.
#
# [*tftp_root*]
# (optional) Folder location to deploy PXE boot files
# Defaults to '/tftpboot'
#
# [*http_root*]
# (optional) Folder location to deploy HTTP PXE boot
# Defaults to '/httpboot'
#
# DEPRECATED PARAMETERS
#
# [*identity_uri*]
Expand Down Expand Up @@ -205,8 +213,10 @@
$ramdisk_collectors = 'default',
$additional_processing_hooks = undef,
$ramdisk_kernel_args = undef,
$ipxe_timeout = 0,
$http_port = 8088,
$ipxe_timeout = $::os_service_default,
$http_port = '8088',
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
# DEPRECATED PARAMETERS
$identity_uri = undef,
$admin_tenant_name = undef,
Expand All @@ -216,6 +226,7 @@
) {

include ::ironic::params
include ::ironic::pxe::common
include ::ironic::inspector::logging

if $admin_tenant_name {
Expand All @@ -242,27 +253,31 @@
include ::ironic::inspector::authtoken
}

warning("After Newton cycle ::ironic::inspector won't provide tftpboot and httpboot setup, please include ::ironic::pxe")
include ::ironic::pxe

$tftp_root_real = pick($::ironic::pxe::common::tftp_root, $tftp_root)
$http_root_real = pick($::ironic::pxe::common::http_root, $http_root)
$http_port_real = pick($::ironic::pxe::common::http_port, $http_port)
$ipxe_timeout_real = pick($::ironic::pxe::common::ipxe_timeout, $ipxe_timeout)

Ironic_inspector_config<||> ~> Service['ironic-inspector']

file { '/etc/ironic-inspector/inspector.conf':
ensure => 'present',
require => Package['ironic-inspector'],
}
file { '/tftpboot':
ensure => 'directory',
seltype => 'tftpdir_t',
}

if $pxe_transfer_protocol == 'tftp' {
file { '/etc/ironic-inspector/dnsmasq.conf':
ensure => 'present',
content => template('ironic/inspector_dnsmasq_tftp.erb'),
require => Package['ironic-inspector'],
}
file { '/tftpboot/pxelinux.cfg':
file { "${tftp_root_real}/pxelinux.cfg":
ensure => 'directory',
}
file { '/tftpboot/pxelinux.cfg/default':
file { "${tftp_root_real}/pxelinux.cfg/default":
ensure => 'present',
content => template('ironic/inspector_pxelinux_cfg.erb'),
require => Package['ironic-inspector'],
Expand All @@ -275,32 +290,11 @@
content => template('ironic/inspector_dnsmasq_http.erb'),
require => Package['ironic-inspector'],
}
file { '/httpboot':
ensure => 'directory',
}
file { '/httpboot/inspector.ipxe':
file { "${http_root_real}/inspector.ipxe":
ensure => 'present',
content => template('ironic/inspector_ipxe.erb'),
require => Package['ironic-inspector'],
}
if $::ironic::params::ipxe_rom_dir {
file { '/tftpboot/undionly.kpxe':
ensure => 'present',
source => "${::ironic::params::ipxe_rom_dir}/undionly.kpxe",
backup => false,
seltype => 'tftpdir_t',
}
if $enable_uefi {
file { '/tftpboot/ipxe.efi':
ensure => 'present',
source => "${::ironic::params::ipxe_rom_dir}/ipxe.efi",
backup => false,
seltype => 'tftpdir_t',
}
}
} else {
warning('iPXE ROM source location not set, ensure ROMs are copied into /tftpboot')
}
}

# Configure inspector.conf
Expand Down
10 changes: 10 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
$ipxe_rom_dir = '/usr/share/ipxe'
$ironic_wsgi_script_path = '/var/www/cgi-bin/ironic'
$ironic_wsgi_script_source = '/usr/lib/python2.7/site-packages/ironic/api/app.wsgi'
$tftpd_package = 'tftp-server'
$ipxe_package = 'ipxe-bootimgs'
$syslinux_package = 'syslinux-extlinux'
$syslinux_path = '/usr/share/syslinux'
$syslinux_files = ['pxelinux.0', 'chain.c32']
}
'Debian': {
$common_package_name = 'ironic-common'
Expand All @@ -60,6 +65,11 @@
$ipxe_rom_dir = '/usr/lib/ipxe'
$ironic_wsgi_script_path = '/usr/lib/cgi-bin/ironic'
$ironic_wsgi_script_source = '/usr/lib/python2.7/dist-packages/ironic/api/app.wsgi'
$tftpd_package = 'tftpd'
$ipxe_package = 'ipxe'
$syslinux_package = 'syslinux-common'
$syslinux_path = '/usr/lib/syslinux'
$syslinux_files = ['pxelinux.0', 'chain.c32', 'libcom32.c32', 'libutil.c32']
}
default: {
fail("Unsupported osfamily ${::osfamily}")
Expand Down
164 changes: 164 additions & 0 deletions manifests/pxe.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#
# Copyright (C) 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# Set up PXE boot for Ironic
#
# === Parameters
#
# [*package_ensure*]
# (optional) Control the ensure parameter for the package resource
# Defaults to 'present'
#
# [*tftp_root*]
# (optional) Folder location to deploy PXE boot files
# Defaults to '/tftpboot'
#
# [*http_root*]
# (optional) Folder location to deploy HTTP PXE boot
# Defaults to '/httpboot'
#
# [*http_port*]
# (optional) port used by the HTTP service serving introspection and
# deployment images.
# Defaults to '8088'
#
# [*syslinux_path*]
# (optional) Path to directory containing syslinux files.
# Defaults to '$::ironic::params::syslinux_path'
#
# [*syslinux_files*]
# (optional) Array of PXE boot files to copy from $syslinux_path to $tftp_root.
# Defaults to '$::ironic::params::syslinux_files'
#
class ironic::pxe (
$package_ensure = 'present',
$tftp_root = '/tftpboot',
$http_root = '/httpboot',
$http_port = '8088',
$syslinux_path = $::ironic::params::syslinux_path,
$syslinux_files = $::ironic::params::syslinux_files,
) inherits ::ironic::params {

include ::ironic::pxe::common

$tftp_root_real = pick($::ironic::pxe::common::tftp_root, $tftp_root)
$http_root_real = pick($::ironic::pxe::common::http_root, $http_root)
$http_port_real = pick($::ironic::pxe::common::http_port, $http_port)

file { $tftp_root_real:
ensure => 'directory',
seltype => 'tftpdir_t',
owner => 'ironic',
group => 'ironic',
require => Package['ironic-common'],
}

file { $http_root_real:
ensure => 'directory',
seltype => 'httpd_sys_content_t',
owner => 'ironic',
group => 'ironic',
require => Package['ironic-common'],
}

ensure_resource( 'package', 'tftp-server', {
'ensure' => $package_ensure,
'name' => $::ironic::params::tftpd_package,
'tag' => ['openstack', 'ironic-ipxe'],
})

$options = "--map-file ${tftp_root_real}/map-file"
include ::xinetd

xinetd::service { 'tftp':
port => '69',
protocol => 'udp',
server_args => "${options} ${tftp_root_real}",
server => '/usr/sbin/in.tftpd',
socket_type => 'dgram',
cps => '100 2',
flags => 'IPv4',
per_source => '11',
wait => 'yes',
require => Package['tftp-server'],
}

service { 'tftpd-hpa':
ensure => 'stopped',
enable => false,
}

file { "${tftp_root_real}/map-file":
ensure => 'present',
content => "r ^([^/]) ${tftp_root_real}/\\1",
}

ensure_resource( 'package', 'syslinux', {
ensure => $package_ensure,
name => $::ironic::params::syslinux_package,
tag => ['openstack', 'ironic-ipxe'],
})

ironic::pxe::tftpboot_file { $syslinux_files:
source_directory => $syslinux_path,
destination_directory => $tftp_root_real,
require => Package['syslinux'],
}

ensure_resource( 'package', 'ipxe', {
ensure => $package_ensure,
name => $::ironic::params::ipxe_package,
tag => ['openstack', 'ironic-ipxe'],
})

file { "${tftp_root_real}/undionly.kpxe":
ensure => 'present',
seltype => 'tftpdir_t',
owner => 'ironic',
group => 'ironic',
mode => '0744',
source => "${::ironic::params::ipxe_rom_dir}/undionly.kpxe",
backup => false,
require => Package['ipxe'],
}

file { "${tftp_root_real}/ipxe.efi":
ensure => 'present',
seltype => 'tftpdir_t',
owner => 'ironic',
group => 'ironic',
mode => '0744',
source => "${::ironic::params::ipxe_rom_dir}/ipxe.efi",
backup => false,
require => Package['ipxe'],
}

include ::apache

apache::vhost { 'ipxe_vhost':
priority => '10',
options => ['Indexes','FollowSymLinks'],
docroot => $http_root_real,
port => $http_port_real,
# FIXME: for backwards compatibility we have to add listen to the ipxe vhost
add_listen => false,
}
# FIXME: this can be removed after ipxe element is removed from instack-undercloud
concat::fragment { 'ipxe_vhost-listen':
target => '10-ipxe_vhost.conf',
order => 1337,
content => "Listen ${http_port_real}",
}
}
46 changes: 46 additions & 0 deletions manifests/pxe/common.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Copyright (C) 2016 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


# Common setup for Ironic PXE boot
#
# This class allows to globally override configuration for PXE
# configuration of Ironic.
#
# === Parameters
#
# [*http_port*]
# (optional) port used by the HTTP service serving introspection images.
# Defaults to undef.
#
# [*tftp_root*]
# (optional) Folder location to deploy PXE boot files
# Defaults to undef.
#
# [*http_root*]
# (optional) Folder location to deploy HTTP PXE boot
# Defaults to undef.
#
# [*ipxe_timeout*]
# (optional) ipxe timeout in second. Should be an integer.
# Defaults to undef.
#
class ironic::pxe::common (
$tftp_root = undef,
$http_root = undef,
$http_port = undef,
$ipxe_timeout = undef,
) {
}

0 comments on commit 3e970e4

Please sign in to comment.