summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rw-r--r--joeyconfig.hs8
-rw-r--r--propellor.cabal2
-rw-r--r--src/Propellor/Property/Network.hs29
-rw-r--r--src/Propellor/Property/OS.hs2
5 files changed, 38 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog
index 9e1c15c1..0e7c6314 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,11 @@
-propellor (4.5.3) UNRELEASED; urgency=medium
+propellor (4.6.0) UNRELEASED; urgency=medium
* Add Typeable instance to Bootstrapper, fixing build with old versions
of ghc.
+ * Network.static changed to take address and gateway parameters.
+ If you used the old Network.static property, it has been renamed to
+ Network.preserveStatic.
+ (Minor API change)
-- Joey Hess <id@joeyh.name> Tue, 25 Jul 2017 21:01:23 -0400
diff --git a/joeyconfig.hs b/joeyconfig.hs
index be7b9ef0..fd477111 100644
--- a/joeyconfig.hs
+++ b/joeyconfig.hs
@@ -197,8 +197,10 @@ honeybee = host "honeybee.kitenet.net" $ props
& Apt.serviceInstalledRunning "ntp"
-- Home router
- & Network.dhcp "eth0" `requires` Network.cleanInterfacesFile
- -- todo configure wlan0 on ip 10.1.1.1
+ & Network.dhcp "eth0"
+ `requires` Network.cleanInterfacesFile
+ & Network.static "wlan0" (IPv4 "10.1.1.1") Nothing
+ `requires` Network.cleanInterfacesFile
& Apt.serviceInstalledRunning "hostapd" -- todo write hostapd.conf 1st
& Apt.serviceInstalledRunning "dnsmasq" -- todo write dnsmasq.conf file
& JoeySites.ipmasq "eth0" "wlan0"
@@ -234,7 +236,7 @@ kite = host "kite.kitenet.net" $ props
, (SshEd25519, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFZftKMnH/zH29BHMKbcBO4QsgTrstYFVhbrzrlRzBO3")
]
- & Network.static "eth0" `requires` Network.cleanInterfacesFile
+ & Network.preserveStatic "eth0" `requires` Network.cleanInterfacesFile
& Apt.installed ["linux-image-amd64"]
& Linode.serialGrub
& Linode.mlocateEnabled
diff --git a/propellor.cabal b/propellor.cabal
index 170aed7e..5d1ad0e9 100644
--- a/propellor.cabal
+++ b/propellor.cabal
@@ -1,5 +1,5 @@
Name: propellor
-Version: 4.5.2
+Version: 4.6.0
Cabal-Version: >= 1.20
License: BSD2
Maintainer: Joey Hess <id@joeyh.name>
diff --git a/src/Propellor/Property/Network.hs b/src/Propellor/Property/Network.hs
index 9ed9e591..0e47b88f 100644
--- a/src/Propellor/Property/Network.hs
+++ b/src/Propellor/Property/Network.hs
@@ -39,7 +39,30 @@ dhcp iface = tightenTargets $ hasContent (interfaceDFile iface)
`describe` ("dhcp " ++ iface)
`requires` interfacesDEnabled
--- | Writes a static interface file for the specified interface.
+newtype Gateway = Gateway IPAddr
+
+-- | Configures an interface with a static address and gateway.
+static :: Interface -> IPAddr -> Maybe Gateway-> Property DebianLike
+static iface addr gateway =
+ tightenTargets $ hasContent (interfaceDFile iface) ls
+ `describe` ("static IP address for " ++ iface)
+ `requires` interfacesDEnabled
+ where
+ ls = catMaybes
+ [ Just $ "auto " ++ iface
+ , Just $ "iface " ++ iface ++ " " ++ inet ++ " static"
+ , Just $ "\taddress" ++ val addr
+ , case gateway of
+ Just (Gateway gaddr) ->
+ Just $ "\tgateway" ++ val gaddr
+ Nothing -> Nothing
+ ]
+ inet = case addr of
+ IPv4 _ -> "inet"
+ IPv6 _ -> "inet6"
+
+-- | Writes a static interface file for the specified interface
+-- to preserve its current configuration.
--
-- The interface has to be up already. It could have been brought up by
-- DHCP, or by other means. The current ipv4 addresses
@@ -50,8 +73,8 @@ dhcp iface = tightenTargets $ hasContent (interfaceDFile iface)
--
-- (ipv6 addresses are not included because it's assumed they come up
-- automatically in most situations.)
-static :: Interface -> Property DebianLike
-static iface = tightenTargets $
+preserveStatic :: Interface -> Property DebianLike
+preserveStatic iface = tightenTargets $
check (not <$> doesFileExist f) setup
`describe` desc
`requires` interfacesDEnabled
diff --git a/src/Propellor/Property/OS.hs b/src/Propellor/Property/OS.hs
index 10d7afc0..c31bef7b 100644
--- a/src/Propellor/Property/OS.hs
+++ b/src/Propellor/Property/OS.hs
@@ -207,7 +207,7 @@ preserveNetwork = go `requires` Network.cleanInterfacesFile
["route", "list", "scope", "global"]
case words <$> headMaybe ls of
Just ("default":"via":_:"dev":iface:_) ->
- ensureProperty w $ Network.static iface
+ ensureProperty w $ Network.preserveStatic iface
_ -> do
warningMessage "did not find any default ipv4 route"
return FailedChange