summaryrefslogtreecommitdiff
path: root/src/Propellor/Property
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property')
-rw-r--r--src/Propellor/Property/Bootstrap.hs1
-rw-r--r--src/Propellor/Property/Ccache.hs1
-rw-r--r--src/Propellor/Property/Cron.hs1
-rw-r--r--src/Propellor/Property/Debootstrap.hs1
-rw-r--r--src/Propellor/Property/DiskImage.hs1
-rw-r--r--src/Propellor/Property/File.hs1
-rw-r--r--src/Propellor/Property/HostingProvider/Linode.hs1
-rw-r--r--src/Propellor/Property/Localdir.hs61
-rw-r--r--src/Propellor/Property/Mount.hs14
-rw-r--r--src/Propellor/Property/Openssl.hs2
-rw-r--r--src/Propellor/Property/PropellorRepo.hs29
-rw-r--r--src/Propellor/Property/Sbuild.hs17
-rw-r--r--src/Propellor/Property/Schroot.hs2
-rw-r--r--src/Propellor/Property/Service.hs1
-rw-r--r--src/Propellor/Property/SiteSpecific/Branchable.hs2
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs1
-rw-r--r--src/Propellor/Property/Ssh.hs1
-rw-r--r--src/Propellor/Property/Systemd.hs1
-rw-r--r--src/Propellor/Property/Tor.hs1
19 files changed, 90 insertions, 49 deletions
diff --git a/src/Propellor/Property/Bootstrap.hs b/src/Propellor/Property/Bootstrap.hs
index 25a6af33..6bbb4512 100644
--- a/src/Propellor/Property/Bootstrap.hs
+++ b/src/Propellor/Property/Bootstrap.hs
@@ -15,7 +15,6 @@ import Propellor.Bootstrap
import Propellor.Types.Info
import Propellor.Property.Chroot
import Propellor.PrivData.Paths
-import Utility.FileMode
import Data.List
import qualified Data.ByteString as B
diff --git a/src/Propellor/Property/Ccache.hs b/src/Propellor/Property/Ccache.hs
index ea729b7c..fad3a28f 100644
--- a/src/Propellor/Property/Ccache.hs
+++ b/src/Propellor/Property/Ccache.hs
@@ -11,7 +11,6 @@ import Propellor.Base
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
-import Utility.FileMode
import Utility.DataUnits
import System.Posix.Files
import qualified Data.Semigroup as Sem
diff --git a/src/Propellor/Property/Cron.hs b/src/Propellor/Property/Cron.hs
index b9fb10e0..0271b0b3 100644
--- a/src/Propellor/Property/Cron.hs
+++ b/src/Propellor/Property/Cron.hs
@@ -4,7 +4,6 @@ import Propellor.Base
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
import Propellor.Bootstrap
-import Utility.FileMode
import Data.Char
diff --git a/src/Propellor/Property/Debootstrap.hs b/src/Propellor/Property/Debootstrap.hs
index 923229be..6336e775 100644
--- a/src/Propellor/Property/Debootstrap.hs
+++ b/src/Propellor/Property/Debootstrap.hs
@@ -15,7 +15,6 @@ import qualified Propellor.Property.Apt as Apt
import Propellor.Property.Chroot.Util
import Propellor.Property.Qemu
import Utility.Path
-import Utility.FileMode
import Data.List
import Data.Char
diff --git a/src/Propellor/Property/DiskImage.hs b/src/Propellor/Property/DiskImage.hs
index 29bc2d1c..b7651b98 100644
--- a/src/Propellor/Property/DiskImage.hs
+++ b/src/Propellor/Property/DiskImage.hs
@@ -42,7 +42,6 @@ import Propellor.Types.Info
import Propellor.Types.Bootloader
import Propellor.Container
import Utility.Path
-import Utility.FileMode
import Utility.DataUnits
import Data.List (isPrefixOf, isInfixOf, sortBy, unzip4)
diff --git a/src/Propellor/Property/File.hs b/src/Propellor/Property/File.hs
index 3188879e..e6d657f9 100644
--- a/src/Propellor/Property/File.hs
+++ b/src/Propellor/Property/File.hs
@@ -3,7 +3,6 @@
module Propellor.Property.File where
import Propellor.Base
-import Utility.FileMode
import qualified Data.ByteString.Lazy as L
import Data.List (isInfixOf, isPrefixOf)
diff --git a/src/Propellor/Property/HostingProvider/Linode.hs b/src/Propellor/Property/HostingProvider/Linode.hs
index ebe8d261..fc5d1a0c 100644
--- a/src/Propellor/Property/HostingProvider/Linode.hs
+++ b/src/Propellor/Property/HostingProvider/Linode.hs
@@ -3,7 +3,6 @@ module Propellor.Property.HostingProvider.Linode where
import Propellor.Base
import qualified Propellor.Property.Grub as Grub
import qualified Propellor.Property.File as File
-import Utility.FileMode
-- | Configures grub to use the serial console as set up by Linode.
-- Useful when running a distribution supplied kernel.
diff --git a/src/Propellor/Property/Localdir.hs b/src/Propellor/Property/Localdir.hs
new file mode 100644
index 00000000..018a054b
--- /dev/null
+++ b/src/Propellor/Property/Localdir.hs
@@ -0,0 +1,61 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+
+-- | Properties to manipulate propellor's @/usr/local/propellor@ on spun hosts
+
+module Propellor.Property.Localdir where
+
+import Propellor.Base
+import Propellor.Git.Config
+import Propellor.Types.Info
+import Propellor.Property.Chroot (inChroot)
+import Propellor.Property.Mount (partialBindMountsOf, umountLazy)
+
+-- | Sets the url to use as the origin of propellor's git repository.
+--
+-- By default, the url is taken from the deploy or origin remote of
+-- the repository that propellor --spin is run in. Setting this property
+-- overrides that default behavior with a different url.
+--
+-- When hosts are being updated without using -- --spin, eg when using
+-- the `Propellor.Property.Cron.runPropellor` cron job, this property can
+-- be set to redirect them to a new git repository url.
+hasOriginUrl :: String -> Property (HasInfo + UnixLike)
+hasOriginUrl u = setInfoProperty p (toInfo (InfoVal (OriginUrl u)))
+ where
+ p :: Property UnixLike
+ p = property ("propellor repo url " ++ u) $ do
+ curru <- liftIO getRepoUrl
+ if curru == Just u
+ then return NoChange
+ else makeChange $ setRepoUrl u
+
+newtype OriginUrl = OriginUrl String
+ deriving (Show, Typeable)
+
+-- | Removes the @/usr/local/propellor@ directory used to spin the host, after
+-- ensuring other properties. Without this property, that directory is left
+-- behind after the spin.
+--
+-- Does not perform other clean up, such as removing Haskell libraries that were
+-- installed in order to build propellor, or removing cronjobs such as created
+-- by 'Propellor.Property.Cron.runPropellor'.
+removed :: Property UnixLike
+removed = check (doesDirectoryExist localdir) $
+ property "propellor's /usr/local dir to be removed" $ do
+ endAction "removing /usr/local/propellor" atend
+ return NoChange
+ where
+ atend _ = do
+ ifM inChroot
+ -- In a chroot, all we have to do is unmount localdir,
+ -- and then delete it
+ ( liftIO $ umountLazy localdir
+ -- Outside of a chroot, if we don't unmount any bind
+ -- mounts of localdir before deleting it, another run of
+ -- propellor will have problems reestablishing those
+ -- bind mounts in order to spin chroots
+ , liftIO $ partialBindMountsOf localdir
+ >>= mapM_ umountLazy
+ )
+ liftIO $ removeDirectoryRecursive localdir
+ return NoChange
diff --git a/src/Propellor/Property/Mount.hs b/src/Propellor/Property/Mount.hs
index 53129f50..03c4f04d 100644
--- a/src/Propellor/Property/Mount.hs
+++ b/src/Propellor/Property/Mount.hs
@@ -89,6 +89,20 @@ mountPointsBelow target = filter (\p -> simplifyPath p /= simplifyPath target)
. filter (dirContains target)
<$> mountPoints
+-- | Get mountpoints which are bind mounts of subdirectories of mounted
+-- filesystems
+--
+-- E.g. as created by @mount --bind /etc/foo /etc/bar@ where @/etc/foo@ is not
+-- itself a mount point, but just a subdirectory. These are sometimes known as
+-- "partial bind mounts"
+partialBindMountsOf :: FilePath -> IO [MountPoint]
+partialBindMountsOf sourceDir =
+ map (drop 2 . dropWhile (/= ']')) . filter getThem . lines
+ <$> readProcess "findmnt" ["-rn", "--output", "source,target"]
+ where
+ getThem l = bracketed `isSuffixOf` (takeWhile (/= ' ') l)
+ bracketed = "[" ++ sourceDir ++ "]"
+
-- | Filesystem type mounted at a given location.
getFsType :: MountPoint -> IO (Maybe FsType)
getFsType p = findmntField "fstype" [p]
diff --git a/src/Propellor/Property/Openssl.hs b/src/Propellor/Property/Openssl.hs
index a91b8195..0cb7c9c2 100644
--- a/src/Propellor/Property/Openssl.hs
+++ b/src/Propellor/Property/Openssl.hs
@@ -5,10 +5,8 @@ module Propellor.Property.Openssl where
import Propellor.Base
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.File as File
-import Utility.FileMode
import Utility.SafeCommand
-
installed :: Property DebianLike
installed = Apt.installed ["openssl"]
diff --git a/src/Propellor/Property/PropellorRepo.hs b/src/Propellor/Property/PropellorRepo.hs
deleted file mode 100644
index 825efdfd..00000000
--- a/src/Propellor/Property/PropellorRepo.hs
+++ /dev/null
@@ -1,29 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-
-module Propellor.Property.PropellorRepo where
-
-import Propellor.Base
-import Propellor.Git.Config
-import Propellor.Types.Info
-
--- | Sets the url to use as the origin of propellor's git repository.
---
--- By default, the url is taken from the deploy or origin remote of
--- the repository that propellor --spin is run in. Setting this property
--- overrides that default behavior with a different url.
---
--- When hosts are being updated without using -- --spin, eg when using
--- the `Propellor.Property.Cron.runPropellor` cron job, this property can
--- be set to redirect them to a new git repository url.
-hasOriginUrl :: String -> Property (HasInfo + UnixLike)
-hasOriginUrl u = setInfoProperty p (toInfo (InfoVal (OriginUrl u)))
- where
- p :: Property UnixLike
- p = property ("propellor repo url " ++ u) $ do
- curru <- liftIO getRepoUrl
- if curru == Just u
- then return NoChange
- else makeChange $ setRepoUrl u
-
-newtype OriginUrl = OriginUrl String
- deriving (Show, Typeable)
diff --git a/src/Propellor/Property/Sbuild.hs b/src/Propellor/Property/Sbuild.hs
index 8cc2e3be..3de82af3 100644
--- a/src/Propellor/Property/Sbuild.hs
+++ b/src/Propellor/Property/Sbuild.hs
@@ -29,6 +29,7 @@ Suggested usage in @config.hs@:
> where
> sidSchrootBuilt = Sbuild.built Sbuild.UseCcache $ props
> & osDebian Unstable X86_32
+> & Sbuild.osDebianStandard
> & Sbuild.update `period` Weekly (Just 1)
> & Sbuild.useHostProxy mybox
@@ -65,6 +66,7 @@ module Propellor.Property.Sbuild (
-- * Properties for use inside sbuild schroots
update,
useHostProxy,
+ osDebianStandard,
-- * Global sbuild configuration
-- blockNetwork,
keypairGenerated,
@@ -86,8 +88,8 @@ import qualified Propellor.Property.File as File
-- import qualified Propellor.Property.Firewall as Firewall
import qualified Propellor.Property.Schroot as Schroot
import qualified Propellor.Property.Reboot as Reboot
+import qualified Propellor.Property.Localdir as Localdir
import qualified Propellor.Property.User as User
-import Utility.FileMode
import Data.List
@@ -222,8 +224,11 @@ built' cc (Props ps) suite arch = provisioned <!> deleted
schroot = Chroot.debootstrapped Debootstrap.BuilddD
schrootRoot (Props schrootProps)
schrootProps =
- ps ++ [toChildProperty Apt.stdSourcesList
- , toChildProperty $ Apt.installed ["eatmydata", "ccache"]]
+ ps ++ [toChildProperty $ Apt.installed ["eatmydata", "ccache"]
+ -- Drop /usr/local/propellor since build chroots should be
+ -- clean. Note that propellor does not have to install its
+ -- build-deps into the chroot, so this is sufficient cleanup
+ , toChildProperty $ Localdir.removed]
-- static values
suiteArch = suite ++ "-" ++ arch
@@ -251,6 +256,12 @@ built' cc (Props ps) suite arch = provisioned <!> deleted
where
base = ["eatmydata"]
+-- | Properties that will be wanted in almost any Debian schroot, but not in
+-- schroots for other operating systems.
+osDebianStandard :: Property Debian
+osDebianStandard = propertyList "standard Debian sbuild properties" $ props
+ & Apt.stdSourcesList
+
-- | Ensure that an sbuild schroot's packages and apt indexes are updated
--
-- This replaces use of sbuild-update(1).
diff --git a/src/Propellor/Property/Schroot.hs b/src/Propellor/Property/Schroot.hs
index 2f399b7c..82afdc79 100644
--- a/src/Propellor/Property/Schroot.hs
+++ b/src/Propellor/Property/Schroot.hs
@@ -9,8 +9,6 @@ import Propellor.Types.Info
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
-import Utility.FileMode
-
data UseOverlays = UseOverlays deriving (Eq, Show, Typeable)
-- | Indicate that a schroots on a host should use @union-type=overlay@
diff --git a/src/Propellor/Property/Service.hs b/src/Propellor/Property/Service.hs
index 1c230ce0..396fbaf1 100644
--- a/src/Propellor/Property/Service.hs
+++ b/src/Propellor/Property/Service.hs
@@ -5,7 +5,6 @@ module Propellor.Property.Service where
import Propellor.Base
import Propellor.Types.Info
import qualified Propellor.Property.File as File
-import Utility.FileMode
type ServiceName = String
diff --git a/src/Propellor/Property/SiteSpecific/Branchable.hs b/src/Propellor/Property/SiteSpecific/Branchable.hs
index 3c4d44a1..79a5b45f 100644
--- a/src/Propellor/Property/SiteSpecific/Branchable.hs
+++ b/src/Propellor/Property/SiteSpecific/Branchable.hs
@@ -56,7 +56,7 @@ server hosts = propertyList "branchable server" $ props
]
[ Borg.KeepDays 7
, Borg.KeepWeeks 5
- , Borg.KeepMonths 12
+ , Borg.KeepMonths 3
, Borg.KeepYears 1
]
& Ssh.userKeys (User "root") (Context "branchable.com")
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index e3dbbabd..c5cfbc71 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -25,7 +25,6 @@ import qualified Propellor.Property.Network as Network
import qualified Propellor.Property.Fail2Ban as Fail2Ban
import qualified Propellor.Property.LetsEncrypt as LetsEncrypt
import qualified Propellor.Property.Mount as Mount
-import Utility.FileMode
import Utility.Split
import Data.List
diff --git a/src/Propellor/Property/Ssh.hs b/src/Propellor/Property/Ssh.hs
index c23a121b..59698ec0 100644
--- a/src/Propellor/Property/Ssh.hs
+++ b/src/Propellor/Property/Ssh.hs
@@ -40,7 +40,6 @@ import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.Apt as Apt
import Propellor.Property.User
import Propellor.Types.Info
-import Utility.FileMode
import System.PosixCompat
import qualified Data.Map as M
diff --git a/src/Propellor/Property/Systemd.hs b/src/Propellor/Property/Systemd.hs
index 9c9f5914..9e9a1de1 100644
--- a/src/Propellor/Property/Systemd.hs
+++ b/src/Propellor/Property/Systemd.hs
@@ -55,7 +55,6 @@ import qualified Propellor.Property.Chroot as Chroot
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.File as File
import Propellor.Property.Systemd.Core
-import Utility.FileMode
import Utility.Split
import Data.List
diff --git a/src/Propellor/Property/Tor.hs b/src/Propellor/Property/Tor.hs
index 8794bc7f..426d4209 100644
--- a/src/Propellor/Property/Tor.hs
+++ b/src/Propellor/Property/Tor.hs
@@ -7,7 +7,6 @@ import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.ConfFile as ConfFile
-import Utility.FileMode
import Utility.DataUnits
import System.Posix.Files