From bb10fdfb30948fe096f746fa1b8c1020ab306fe9 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 15 Jul 2017 08:12:42 -0700 Subject: add Apt.proxy, Apt.useLocalCacher --- src/Propellor/Property/Apt.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Propellor/Property/Apt.hs') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index 686ddb6c..07164df6 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -20,6 +20,9 @@ import Propellor.Types.Info data HostMirror = HostMirror Url deriving (Eq, Show, Typeable) +data HostAptProxy = HostAptProxy Url + deriving (Eq, Show, Typeable) + -- | Indicate host's preferred apt mirror (e.g. an apt cacher on the host's LAN) mirror :: Url -> Property (HasInfo + UnixLike) mirror u = pureInfoProperty (u ++ " apt mirror selected") @@ -493,3 +496,19 @@ suitePinBlock p suite pin = dpkgStatus :: FilePath dpkgStatus = "/var/lib/dpkg/status" + +-- | Set apt's proxy +proxy :: Url -> Property (HasInfo + DebianLike) +proxy u = tightenTargets $ + proxyInfo `before` proxyConfig `describe` desc + where + proxyInfo = pureInfoProperty desc (InfoVal (HostAptProxy u)) + proxyConfig = "/etc/apt/apt.conf.d/20proxy" `File.hasContent` + [ "Acquire::HTTP::Proxy \"" ++ u ++ "\";" ] + desc = (u ++ " apt proxy selected") + +-- | Cause apt to proxy downloads via an apt cacher on localhost +useLocalCacher :: Property (HasInfo + DebianLike) +useLocalCacher = proxy "http://localhost:3142" + `requires` serviceInstalledRunning "apt-cacher-ng" + -- cgit v1.2.3 From 4be2ef464c066600a4551975aee7efe61f739393 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 15 Jul 2017 08:12:53 -0700 Subject: drop suggestion to use Apt.mirror for a LAN apt cacher It is probably best to use Apt.proxy for this. --- src/Propellor/Property/Apt.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor/Property/Apt.hs') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index 07164df6..2e4757f8 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -23,7 +23,7 @@ data HostMirror = HostMirror Url data HostAptProxy = HostAptProxy Url deriving (Eq, Show, Typeable) --- | Indicate host's preferred apt mirror (e.g. an apt cacher on the host's LAN) +-- | Indicate host's preferred apt mirror mirror :: Url -> Property (HasInfo + UnixLike) mirror u = pureInfoProperty (u ++ " apt mirror selected") (InfoVal (HostMirror u)) -- cgit v1.2.3 From 56fda8c3ae6af1241ce4836a6122393871fca151 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 15 Jul 2017 13:51:23 -0700 Subject: add a description for Apt.useLocalCacher --- src/Propellor/Property/Apt.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Propellor/Property/Apt.hs') diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs index 2e4757f8..5630d83a 100644 --- a/src/Propellor/Property/Apt.hs +++ b/src/Propellor/Property/Apt.hs @@ -511,4 +511,4 @@ proxy u = tightenTargets $ useLocalCacher :: Property (HasInfo + DebianLike) useLocalCacher = proxy "http://localhost:3142" `requires` serviceInstalledRunning "apt-cacher-ng" - + `describe` "apt uses local apt cacher" -- cgit v1.2.3