Puppet Class: ironic::pxe

Inherits:
ironic::params
Defined in:
manifests/pxe.pp

Overview

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. Setting this to False will skip syslinux related resources. 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’

tftp_bind_host

(optional) The IP address TFTP server will listen on for TFTP. Defaults to undef (listen on all ip addresses).

enable_ppc64le

(optional) Boolean value to dtermine if ppc64le support should be enabled Defaults to false (no ppc64le support)

ipxe_name_base

(optional) Beginning of the source file name which is copied to $tftproot/ipxe.efi. Setting this to ‘ipxe-snponly’ on CentOS8 would result in the source file being /usr/share/ipxe/ipxe-snponly-x86_64.efi Defaults to ‘ipxe-snponly’

uefi_ipxe_bootfile_name

(optional) Name of efi file used to boot servers with iPXE + UEFI. This should be consistent with the uefi_ipxe_bootfile_name parameter in pxe driver. Defaults to ‘snponly.efi’

tftp_use_xinetd

(optional) Override wheter to use xinetd instead of dnsmasq as the tftp service facilitator. Defaults to ironic::params::xinetd_available

Parameters:

  • package_ensure (Any) (defaults to: 'present')
  • tftp_root (Any) (defaults to: '/tftpboot')
  • http_root (Any) (defaults to: '/httpboot')
  • http_port (Any) (defaults to: '8088')
  • syslinux_path (Any) (defaults to: $::ironic::params::syslinux_path)
  • syslinux_files (Any) (defaults to: $::ironic::params::syslinux_files)
  • tftp_bind_host (Any) (defaults to: undef)
  • enable_ppc64le (Any) (defaults to: false)
  • ipxe_name_base (Any) (defaults to: 'ipxe-snponly')
  • uefi_ipxe_bootfile_name (Any) (defaults to: 'snponly.efi')
  • tftp_use_xinetd (Any) (defaults to: $::ironic::params::xinetd_available)


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'manifests/pxe.pp', line 71

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,
  $tftp_bind_host          = undef,
  $enable_ppc64le          = false,
  $ipxe_name_base          = 'ipxe-snponly',
  $uefi_ipxe_bootfile_name = 'snponly.efi',
  $tftp_use_xinetd         = $::ironic::params::xinetd_available
) inherits ironic::params {

  include ironic::deps
  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)

  if $::os['family'] == 'RedHat' {
    $arch = "-${::os['architecture']}"
  } else {
    $arch = ''
  }

  file { $tftp_root_real:
    ensure  => 'directory',
    seltype => 'tftpdir_t',
    owner   => 'ironic',
    group   => 'ironic',
    require => Anchor['ironic::config::begin'],
    before  => Anchor['ironic::config::end'],
  }

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

  file { "${tftp_root_real}/pxelinux.cfg":
    ensure  => 'directory',
    seltype => 'tftpdir_t',
    owner   => 'ironic',
    group   => 'ironic',
    require => Anchor['ironic::install::end'],
    tag     => 'ironic-tftp-file',
  }

  if $enable_ppc64le {
    file { "${tftp_root_real}/ppc64le":
      ensure  => 'directory',
      seltype => 'tftpdir_t',
      owner   => 'ironic',
      group   => 'ironic',
      require => Anchor['ironic::install::end'],
      tag     => 'ironic-tftp-file',
    }
  }

  file { $http_root_real:
    ensure  => 'directory',
    seltype => 'httpd_sys_content_t',
    owner   => 'ironic',
    group   => 'ironic',
    require => Anchor['ironic::config::begin'],
    before  => Anchor['ironic::config::end'],
  }

  if $tftp_use_xinetd {
    if ! $::ironic::params::xinetd_available {
      fail('xinetd is not available in this distro. Please use tftp_use_xinetd=false')
    }

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

    $options = "--map-file ${tftp_root_real}/map-file"

    include xinetd

    xinetd::service { 'tftp':
      port        => '69',
      bind        => $tftp_bind_host,
      protocol    => 'udp',
      server_args => "${options} ${tftp_root_real}",
      server      => '/usr/sbin/in.tftpd',
      socket_type => 'dgram',
      cps         => '100 2',
      per_source  => '11',
      wait        => 'yes',
      subscribe   => Anchor['ironic::install::end'],
    }

    file { "${tftp_root_real}/map-file":
      ensure  => 'present',
      content => "r ^([^/]) ${tftp_root_real}/\\1",
    }
  } else {
    if ! $::ironic::params::dnsmasq_tftp_package {
      fail('ironic-dnsmasq-tftp-server is not available in this distro. Please use tftp_use_xnetd=true')
    }

    # NOTE(tkajinam): We can't use puppet-xinetd for cleanup because the xinetd
    #                 class forcefully installs the xinetd package.
    warning('Any prior xinetd based tftp server should be disabled and removed from the system.')

    file { "${tftp_root_real}/map-file":
      ensure  => 'absent',
    }

    package { 'dnsmasq-tftp-server':
      ensure => $package_ensure,
      name   => $::ironic::params::dnsmasq_tftp_package,
      tag    => ['openstack', 'ironic-ipxe', 'ironic-support-package'],
    }

    file { '/etc/ironic/dnsmasq-tftp-server.conf':
      ensure  => 'present',
      mode    => '0644',
      owner   => 'root',
      group   => 'root',
      content => template('ironic/dnsmasq_tftp_server.erb'),
    }

    service { 'dnsmasq-tftp-server':
      ensure    => 'running',
      name      => $::ironic::params::dnsmasq_tftp_service,
      enable    => true,
      hasstatus => true,
      subscribe => File['/etc/ironic/dnsmasq-tftp-server.conf'],
    }

    Package['dnsmasq-tftp-server'] ~> Service['dnsmasq-tftp-server']
    File[$tftp_root_real] -> Service['dnsmasq-tftp-server']
  }

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

    ironic::pxe::tftpboot_file { $syslinux_files:
      source_directory      => $syslinux_path,
      destination_directory => $tftp_root_real,
      require               => Anchor['ironic-inspector::install::end'],
    }
  }

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

  file { "${tftp_root_real}/undionly.kpxe":
    ensure  => 'file',
    seltype => 'tftpdir_t',
    owner   => 'ironic',
    group   => 'ironic',
    mode    => '0744',
    source  => "${::ironic::params::ipxe_rom_dir}/undionly.kpxe",
    backup  => false,
    require => Anchor['ironic-inspector::install::end'],
    tag     => 'ironic-tftp-file',
  }

  file { "${tftp_root_real}/${uefi_ipxe_bootfile_name}":
    ensure  => 'file',
    seltype => 'tftpdir_t',
    owner   => 'ironic',
    group   => 'ironic',
    mode    => '0744',
    source  => "${::ironic::params::ipxe_rom_dir}/${ipxe_name_base}${arch}.efi",
    backup  => false,
    require => Anchor['ironic-inspector::install::end'],
    tag     => 'ironic-tftp-file',
  }

  File["${tftp_root_real}"] -> File<| tag == 'ironic-tftp-file' |>

  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}",
  }
}