Puppet Class: pxe_install::syslinux

Defined in:
manifests/syslinux.pp

Summary

Download syslinux archive

Overview

Download syslinux archive and distribute files into tftpboot

Examples:

class { 'pxe_install::syslinux':
    tftpboot_dir => '/var/lib/tftpboot',
}

Parameters:

  • tftpboot_dir (Stdlib::Absolutepath)

    Directory serving tftp requests

  • create_tftpboot_dir (Boolean) (defaults to: false)

    Create needed sub directory in the tftpboot directory.

  • owner (String) (defaults to: 'root')

    The file/directory owner.

  • group (String) (defaults to: 'root')

    The file/directory group.

  • mode (String) (defaults to: '0755')

    The file/directory permissions.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
# File 'manifests/syslinux.pp', line 27

class pxe_install::syslinux (
  Stdlib::Absolutepath $tftpboot_dir,
  Boolean $create_tftpboot_dir          = false,
  String $owner                         = 'root',
  String $group                         = 'root',
  String $mode                          = '0755',
) {
  if $create_tftpboot_dir {
    ensure_resource('file', $tftpboot_dir, {
        ensure => directory,
        owner  => $owner,
        group  => $group,
        mode   => $mode,
    })
  }

  if $pxe_install::install_unzip {
    ensure_packages(['unzip'], {
        ensure => present,
    })
  }

  if $pxe_install::install_curl {
    ensure_packages(['curl'], {
        ensure => present,
    })
  }

  file { '/opt/pxe_install':
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0755',
  }

  $archive = "${pxe_install::syslinux_name}-${pxe_install::syslinux_version}"

  archive { "${archive}.tar.gz":
    path         => "/opt/pxe_install/${archive}.tar.gz",
    source       => "${pxe_install::syslinux_url}/${archive}.tar.gz",
    extract      => true,
    extract_path => '/opt/pxe_install/',
    creates      => "/opt/pxe_install/${archive}",
    cleanup      => true,
  }

  $pxe_install::params::syslinux_files.keys.each |$dir| {
    pxe_install::parent_dirs { "create tftpboot dir ${tftpboot_dir}${dir}":
      dir_path => "${tftpboot_dir}${dir}",
    }
  }

  $pxe_install::params::syslinux_files.each |$dir, $files| {
    $files.each |$dst, $src| {
      if $src =~ /^http/ {
        file { "${tftpboot_dir}${dir}/${dst}":
          ensure  => file,
          source  => $src,
          owner   => $owner,
          group   => $group,
          mode    => $mode,
          require => [Archive["${archive}.tar.gz"], File["${tftpboot_dir}${dir}"]],
        }
      } else {
        $cmd = "cp /opt/pxe_install/${archive}${src} ${tftpboot_dir}${dir}/${dst}"
        exec { "copying file ${dst}-${dir}":
          command => $cmd,                                        #lint:ignore:security_class_or_define_parameter_in_exec
          path    => ['/bin/', '/usr/bin'],
          unless  => "test -f ${tftpboot_dir}${dir}/${dst}",
          require => [Archive["${archive}.tar.gz"], File["${tftpboot_dir}${dir}"]],
        }
      }
    }
  }
}