diff --git a/manifests/tftp.pp b/manifests/tftp.pp index 740537d2..48437077 100644 --- a/manifests/tftp.pp +++ b/manifests/tftp.pp @@ -32,8 +32,8 @@ } 'Debian': { $grub_type = 'debian' - # taken from https://anonscm.debian.org/cgit/pkg-grub/grub.git/tree/debian/build-efi-images - $grub_modules = 'all_video boot btrfs cat chain configfile echo efifwsetup efinet ext2 fat font gettext gfxmenu gfxterm gfxterm_background gzio halt hfsplus iso9660 jpeg keystatus loadenv linux lsefi lsefimmap lsefisystab lssal memdisk minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test true video zfs zfscrypt zfsinfo linuxefi lvm mdraid09 mdraid1x raid5rec raid6rec tftp' + # taken from https://anonscm.debian.org/cgit/pkg-grub/grub.git/tree/debian/build-efi-images + regexp + $grub_modules = 'all_video boot btrfs cat chain configfile echo efifwsetup efinet ext2 fat font gettext gfxmenu gfxterm gfxterm_background gzio halt hfsplus iso9660 jpeg keystatus loadenv linux lsefi lsefimmap lsefisystab lssal memdisk minicmd normal part_apple part_msdos part_gpt password_pbkdf2 png reboot search search_fs_uuid search_fs_file search_label sleep test true video zfs zfscrypt zfsinfo linuxefi lvm mdraid09 mdraid1x raid5rec raid6rec tftp regexp' } default: { warning("Unable to detect EFI loader for OS family '${::osfamily}'") @@ -97,7 +97,7 @@ exec {'build-grub2-efi-image': command => "/usr/bin/grub-mkimage -O x86_64-efi -d ${efi_dir} -o ${foreman_proxy::tftp_root}/grub2/grubx64.efi -p '' ${grub_modules}", - creates => "${foreman_proxy::tftp_root}/grub2/grubx64.efi", + unless => "/bin/grep -q regexp '${foreman_proxy::tftp_root}/grub2/grubx64.efi'", require => [File[$foreman_proxy::tftp_dirs], Package['grub-common','grub-efi-amd64-bin']], } -> file {"${foreman_proxy::tftp_root}/grub2/grubx64.efi": diff --git a/spec/classes/foreman_proxy__config__spec.rb b/spec/classes/foreman_proxy__config__spec.rb index 44ded20b..8cce6b75 100644 --- a/spec/classes/foreman_proxy__config__spec.rb +++ b/spec/classes/foreman_proxy__config__spec.rb @@ -301,7 +301,7 @@ it 'should generate efi image from grub2 modules for Debian' do should contain_exec('build-grub2-efi-image'). - with_creates("#{tftp_root}/grub2/grubx64.efi") + with_unless("/bin/grep -q regexp '#{tftp_root}/grub2/grubx64.efi'") should contain_file("#{tftp_root}/grub2/grubx64.efi"). with_mode('0644'). with_owner('root'). diff --git a/templates/grub.cfg.erb b/templates/grub.cfg.erb new file mode 100644 index 00000000..3686779a --- /dev/null +++ b/templates/grub.cfg.erb @@ -0,0 +1,8 @@ +insmod regexp + +set net_pxe_mac=$net_default_mac +regexp --set=1:m1 --set=2:m2 --set=3:m3 --set=4:m4 --set=5:m5 --set=6:m6 '^([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})\:([0-9a-f]{1,2})' "$net_default_mac" +mac_dashed=${m1}-${m2}-${m3}-${m4}-${m5}-${m6} + +mac_configfile=$prefix/grub.cfg-01-$mac_dashed +source "$mac_configfile"