From e0f40f44194f0230017077ed8035f8fb98029bc0 Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@lysator.liu.se> Date: Tue, 19 Dec 2017 14:33:03 +0100 Subject: [PATCH] Add internal class for guessing what bootloader is used. This is intended as an internal helper for other definitions or classes. --- manifests/guess.pp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 manifests/guess.pp diff --git a/manifests/guess.pp b/manifests/guess.pp new file mode 100644 index 0000000..7a6a976 --- /dev/null +++ b/manifests/guess.pp @@ -0,0 +1,37 @@ +# Copyright © 2017 Thomas Bellman, Linköping, Sweden +# Licensed under the GNU LGPL v3+; see the README file for more information. + + +/* + * Try to guess what bootloader is in use, based on the OS. + * Sets the $bootloader variable to the guess. + * The heuristics used are not very good... + * This is intended as an internal helper class, not for end users. + */ +class bootloader::guess +{ + if ($::operatingsystem == 'Fedora' and + versioncmp($::operatingsystemrelease, '18') >= 0) + { + $bootloader = 'grub2' + } + elsif ($::operatingsystem == 'Fedora' and + versioncmp($::operatingsystemrelease, '15') < 0) + { + $bootloader = 'grub0' + } + elsif ($::osfamily == 'RedHat' and + versioncmp($::operatingsystemrelease, '7') >= 0) + { + $bootloader = 'grub2' + } + elsif ($::osfamily == 'RedHat' and + versioncmp($::operatingsystemrelease, '7') < 0) + { + $bootloader = 'grub0' + } + else + { + fail("Cannot guess what bootloader is in use.") + } +} -- GitLab