Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PXEGrub2 with vanilia GRUB2 #324

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions manifests/tftp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/foreman_proxy__config__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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').
Expand Down
8 changes: 8 additions & 0 deletions templates/grub.cfg.erb
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, a user reports that grub2 from Ubuntu 16.04 does not work with this, $net_default_mac is unset for him. Any idea? Maybe to insmod efinet or somethingg? It looks like this variable did not carry over from Grub to Grub2 according official docs.

Copy link

@ZuZuD ZuZuD Apr 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grub2 Ubuntu 16.04 only lookup into grub directory whereas foreman create the associate host file in grub2.
Quick workaround for both issues is to use Fedora grub2x64.efi instead, thanks to lzap!
EDIT : No more outcome with insmod efinet