From 8c2a9de94b179c01fbb40324a5c06101f0713e9c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Jul 2014 02:58:34 -0400 Subject: propellor spin --- src/Propellor/Property/Grub.hs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Propellor/Property/Grub.hs (limited to 'src/Propellor/Property/Grub.hs') diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs new file mode 100644 index 00000000..96b1e5bf --- /dev/null +++ b/src/Propellor/Property/Grub.hs @@ -0,0 +1,37 @@ +module Propellor.Property.Grub where + +import Propellor +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt +import Utility.Applicative + +-- | Eg, hd0,0 or xen/xvda1 +type GrubDevice = String + +-- | Use PV-grub chaining to boot +-- +-- Useful when the VPS's pv-grub is too old to boot a modern kernel image. +-- +-- http://notes.pault.ag/linode-pv-grub-chainning/ +-- +-- The rootdev should be in the form "hd0", while the bootdev is in the form +-- "xen/xvda". +chainPVGrub :: GrubDevice -> GrubDevice -> Property +chainPVGrub rootdev bootdev = combineProperties desc + [ "/boot/grub/menu.lst" `File.hasContent` + [ "default 1" + , "timeout 30" + , "" + , "title grub-xen shim" + , "root (" ++ rootdev ++ ")" + , "kernel /boot/xen-shim" + , "boot" + ] + , "/boot/load.cf" `File.hasContent` + [ "configfile (" ++ bootdev ++ ")/boot/grub/grub.cfg" ] + , Apt.installed ["grub-xen"] + , flagFile (scriptProperty ["update-grub; grub-mkimage --prefix '(" ++ bootdev ++ ")/boot/grub' -c /boot/load.cf -O x86_64-xen /usr/lib/grub/x86_64-xen/*.mod > /boot/xen-shim"]) "/boot/xen-shim" + `describe` "/boot-xen-shim" + ] + where + desc = "chain PV-grub" -- cgit v1.3-2-g0d8e From a1679dfd92b0ecaf2f4bea8c1bb9b1c74d261f13 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Jul 2014 03:00:49 -0400 Subject: propellor spin --- config-joey.hs | 1 - src/Propellor/Property/Grub.hs | 1 - 2 files changed, 2 deletions(-) (limited to 'src/Propellor/Property/Grub.hs') diff --git a/config-joey.hs b/config-joey.hs index cce50052..6dd56c07 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -78,7 +78,6 @@ hosts = -- (o) ` & ipv6 "2600:3c03::f03c:91ff:fe73:b0d2" & Apt.installed ["linux-image-amd64"] - & Grub.chainPVGrub "hd0,0" "xen/xvda1" & Grub.chainPVGrub "hd0" "xen/xvda" & Hostname.sane & Apt.unattendedUpgrades diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index 96b1e5bf..7ca6275b 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -3,7 +3,6 @@ module Propellor.Property.Grub where import Propellor import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt -import Utility.Applicative -- | Eg, hd0,0 or xen/xvda1 type GrubDevice = String -- cgit v1.3-2-g0d8e From dba84b8219d29506886065cc6bcd821d977d2bf8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Jul 2014 03:08:12 -0400 Subject: propellor spin --- config-joey.hs | 3 ++- propellor.cabal | 4 +++- src/Propellor/Property/Grub.hs | 3 ++- src/Propellor/Property/HostingProvider/Linode.hs | 10 ++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/Propellor/Property/HostingProvider/Linode.hs (limited to 'src/Propellor/Property/Grub.hs') diff --git a/config-joey.hs b/config-joey.hs index 6dd56c07..09df857f 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -24,6 +24,7 @@ import qualified Propellor.Property.Service as Service import qualified Propellor.Property.Grub as Grub import qualified Propellor.Property.HostingProvider.DigitalOcean as DigitalOcean import qualified Propellor.Property.HostingProvider.CloudAtCost as CloudAtCost +import qualified Propellor.Property.HostingProvider.Linode as Linode import qualified Propellor.Property.SiteSpecific.GitHome as GitHome import qualified Propellor.Property.SiteSpecific.GitAnnexBuilder as GitAnnexBuilder import qualified Propellor.Property.SiteSpecific.JoeySites as JoeySites @@ -78,7 +79,7 @@ hosts = -- (o) ` & ipv6 "2600:3c03::f03c:91ff:fe73:b0d2" & Apt.installed ["linux-image-amd64"] - & Grub.chainPVGrub "hd0" "xen/xvda" + & Linode.chainPVGrub & Hostname.sane & Apt.unattendedUpgrades & Apt.installed ["systemd"] diff --git a/propellor.cabal b/propellor.cabal index 1c3c8681..e5c8f48a 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -81,6 +81,7 @@ Library Propellor.Property.File Propellor.Property.Git Propellor.Property.Gpg + Propellor.Property.Grub Propellor.Property.Network Propellor.Property.Obnam Propellor.Property.OpenId @@ -92,8 +93,9 @@ Library Propellor.Property.Sudo Propellor.Property.Tor Propellor.Property.User - Propellor.Property.HostingProvider.DigitalOcean Propellor.Property.HostingProvider.CloudAtCost + Propellor.Property.HostingProvider.DigitalOcean + Propellor.Property.HostingProvider.Linode Propellor.Property.SiteSpecific.GitHome Propellor.Property.SiteSpecific.JoeySites Propellor.Property.SiteSpecific.GitAnnexBuilder diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index 7ca6275b..b8e1b662 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -17,7 +17,8 @@ type GrubDevice = String -- "xen/xvda". chainPVGrub :: GrubDevice -> GrubDevice -> Property chainPVGrub rootdev bootdev = combineProperties desc - [ "/boot/grub/menu.lst" `File.hasContent` + [ File.dirExists "/boot/grub" + , "/boot/grub/menu.lst" `File.hasContent` [ "default 1" , "timeout 30" , "" diff --git a/src/Propellor/Property/HostingProvider/Linode.hs b/src/Propellor/Property/HostingProvider/Linode.hs new file mode 100644 index 00000000..cfabe814 --- /dev/null +++ b/src/Propellor/Property/HostingProvider/Linode.hs @@ -0,0 +1,10 @@ +module Propellor.Property.HostingProvider.Linode where + +import Propellor +import qualified Propellor.Property.Grub as Grub + +-- | Linode's pv-grub-x86_64 does not currently support booting recent +-- Debian kernels compressed with xz. This sets up pv-grub chaing to enable +-- it. +chainPVGrub :: Property +chainPVGrub = Grub.chainPVGrub "hd0" "xen/xvda" -- cgit v1.3-2-g0d8e From 461b8cbd32352d9dc9614e16db7404df974faf91 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Jul 2014 03:16:18 -0400 Subject: propellor spin --- config-joey.hs | 9 +++++++-- src/Propellor/Property/Grub.hs | 8 +++++--- src/Propellor/Property/HostingProvider/Linode.hs | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Propellor/Property/Grub.hs') diff --git a/config-joey.hs b/config-joey.hs index 09df857f..d269c4e7 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -78,8 +78,13 @@ hosts = -- (o) ` & ipv4 "66.228.36.95" & ipv6 "2600:3c03::f03c:91ff:fe73:b0d2" + & File.hasContent "/etc/motd" + [ "Welcome to the new kitenet.net server!" + , "This is still under construction and not yet live.." + ] + & Apt.installed ["linux-image-amd64"] - & Linode.chainPVGrub + & Linode.chainPVGrub 5 & Hostname.sane & Apt.unattendedUpgrades & Apt.installed ["systemd"] @@ -151,7 +156,7 @@ hosts = -- (o) ` in standardSystem "elephant.kitenet.net" Unstable "amd64" & ipv4 "193.234.225.114" - & Grub.chainPVGrub "hd0,0" "xen/xvda1" + & Grub.chainPVGrub "hd0,0" "xen/xvda1" 30 & Hostname.sane & Postfix.satellite & Apt.unattendedUpgrades diff --git a/src/Propellor/Property/Grub.hs b/src/Propellor/Property/Grub.hs index b8e1b662..841861f4 100644 --- a/src/Propellor/Property/Grub.hs +++ b/src/Propellor/Property/Grub.hs @@ -7,6 +7,8 @@ import qualified Propellor.Property.Apt as Apt -- | Eg, hd0,0 or xen/xvda1 type GrubDevice = String +type TimeoutSecs = Int + -- | Use PV-grub chaining to boot -- -- Useful when the VPS's pv-grub is too old to boot a modern kernel image. @@ -15,12 +17,12 @@ type GrubDevice = String -- -- The rootdev should be in the form "hd0", while the bootdev is in the form -- "xen/xvda". -chainPVGrub :: GrubDevice -> GrubDevice -> Property -chainPVGrub rootdev bootdev = combineProperties desc +chainPVGrub :: GrubDevice -> GrubDevice -> TimeoutSecs -> Property +chainPVGrub rootdev bootdev timeout = combineProperties desc [ File.dirExists "/boot/grub" , "/boot/grub/menu.lst" `File.hasContent` [ "default 1" - , "timeout 30" + , "timeout " ++ show timeout , "" , "title grub-xen shim" , "root (" ++ rootdev ++ ")" diff --git a/src/Propellor/Property/HostingProvider/Linode.hs b/src/Propellor/Property/HostingProvider/Linode.hs index cfabe814..34d72184 100644 --- a/src/Propellor/Property/HostingProvider/Linode.hs +++ b/src/Propellor/Property/HostingProvider/Linode.hs @@ -6,5 +6,5 @@ import qualified Propellor.Property.Grub as Grub -- | Linode's pv-grub-x86_64 does not currently support booting recent -- Debian kernels compressed with xz. This sets up pv-grub chaing to enable -- it. -chainPVGrub :: Property +chainPVGrub :: Grub.TimeoutSecs -> Property chainPVGrub = Grub.chainPVGrub "hd0" "xen/xvda" -- cgit v1.3-2-g0d8e