propellor spin

This commit is contained in:
Joey Hess 2014-05-31 16:48:14 -04:00
parent 1a83bf2630
commit 6383d8c388
Failed to extract signature
6 changed files with 48 additions and 17 deletions

View File

@ -53,7 +53,6 @@ hosts = -- (o) `
& Postfix.satellite & Postfix.satellite
& Docker.configured & Docker.configured
& alias "shell.olduse.net"
& Docker.docked hosts "oldusenet-shellbox" & Docker.docked hosts "oldusenet-shellbox"
& alias "openid.kitenet.net" & alias "openid.kitenet.net"
@ -198,6 +197,7 @@ hosts = -- (o) `
, standardContainer "oldusenet-shellbox" Stable "amd64" , standardContainer "oldusenet-shellbox" Stable "amd64"
& Docker.publish "4200:4200" & Docker.publish "4200:4200"
& alias "shell.olduse.net"
& JoeySites.oldUseNetShellBox & JoeySites.oldUseNetShellBox
-- git-annex autobuilder containers -- git-annex autobuilder containers

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
propellor (0.6.0) UNRELEASED; urgency=medium
* Docker containers now propigate DNS attributes out to the host they're
docked in. So if a docker container sets a DNS alias, every container
it's docked in will automatically become part of a round-robin DNS,
if propellor is used to manage DNS for the domain.
-- Joey Hess <joeyh@debian.org> Sat, 31 May 2014 16:41:56 -0400
propellor (0.5.3) unstable; urgency=medium propellor (0.5.3) unstable; urgency=medium
* Fix unattended-upgrades config for !stable. * Fix unattended-upgrades config for !stable.

View File

@ -4,5 +4,3 @@
* There is no way for a property of a docker container to require * There is no way for a property of a docker container to require
some property be met outside the container. For example, some servers some property be met outside the container. For example, some servers
need ntp installed for a good date source. need ntp installed for a good date source.
* Docking a container in a host should add to the host any cnames that
are assigned to the container.

View File

@ -1,5 +1,5 @@
Name: propellor Name: propellor
Version: 0.5.3 Version: 0.6.0
Cabal-Version: >= 1.6 Cabal-Version: >= 1.6
License: BSD3 License: BSD3
Maintainer: Joey Hess <joey@kitenet.net> Maintainer: Joey Hess <joey@kitenet.net>

View File

@ -33,21 +33,31 @@ getOS = asks _os
-- TODO check at run time if the host really has this address. -- TODO check at run time if the host really has this address.
-- (Can't change the host's address, but as a sanity check.) -- (Can't change the host's address, but as a sanity check.)
ipv4 :: String -> Property ipv4 :: String -> Property
ipv4 addr = pureAttrProperty ("ipv4 " ++ addr) ipv4 = addDNS . Address . IPv4
(addDNS $ Address $ IPv4 addr)
-- | Indidate that a host has an AAAA record in the DNS. -- | Indidate that a host has an AAAA record in the DNS.
ipv6 :: String -> Property ipv6 :: String -> Property
ipv6 addr = pureAttrProperty ("ipv6 " ++ addr) ipv6 = addDNS . Address . IPv6
(addDNS $ Address $ IPv6 addr)
-- | Indicates another name for the host in the DNS. -- | Indicates another name for the host in the DNS.
alias :: Domain -> Property alias :: Domain -> Property
alias domain = pureAttrProperty ("alias " ++ domain) alias = addDNS . CNAME . AbsDomain
(addDNS $ CNAME $ AbsDomain domain)
addDNS :: Record -> SetAttr addDNS :: Record -> Property
addDNS record d = d { _dns = S.insert record (_dns d) } addDNS r = pureAttrProperty (rdesc r) $
\d -> d { _dns = S.insert r (_dns d) }
where
rdesc (CNAME d) = unwords ["alias", ddesc d]
rdesc (Address (IPv4 addr)) = unwords ["ipv4", addr]
rdesc (Address (IPv6 addr)) = unwords ["ipv6", addr]
rdesc (MX n d) = unwords ["MX", show n, ddesc d]
rdesc (NS d) = unwords ["NS", ddesc d]
rdesc (TXT s) = unwords ["TXT", s]
rdesc (SRV x y z d) = unwords ["SRV", show x, show y, show z, ddesc d]
ddesc (AbsDomain domain) = domain
ddesc (RelDomain domain) = domain
ddesc RootDomain = "@"
-- | Adds a DNS NamedConf stanza. -- | Adds a DNS NamedConf stanza.
-- --

View File

@ -21,6 +21,7 @@ import System.Posix.Directory
import System.Posix.Process import System.Posix.Process
import Data.List import Data.List
import Data.List.Utils import Data.List.Utils
import qualified Data.Set as S
-- | Configures docker with an authentication file, so that images can be -- | Configures docker with an authentication file, so that images can be
-- pushed to index.docker.io. -- pushed to index.docker.io.
@ -56,18 +57,25 @@ cn2hn cn = cn ++ ".docker"
-- has its own Properties which are handled by running propellor -- has its own Properties which are handled by running propellor
-- inside the container. -- inside the container.
-- --
-- Additionally, the container can have DNS attributes, such as a CNAME.
-- These become attributes of the host(s) it's docked in.
--
-- Reverting this property ensures that the container is stopped and -- Reverting this property ensures that the container is stopped and
-- removed. -- removed.
docked docked
:: [Host] :: [Host]
-> ContainerName -> ContainerName
-> RevertableProperty -> RevertableProperty
docked hosts cn = RevertableProperty (go "docked" setup) (go "undocked" teardown) docked hosts cn = RevertableProperty
(go "docked" setup)
(go "undocked" teardown)
where where
go desc a = property (desc ++ " " ++ cn) $ do go desc a = property (desc ++ " " ++ cn) $ do
hn <- getHostName hn <- getHostName
let cid = ContainerId hn cn let cid = ContainerId hn cn
ensureProperties [findContainer hosts cid cn $ a cid] ensureProperties [findContainer mhost cid cn $ a cid]
mhost = findHost hosts (cn2hn cn)
setup cid (Container image runparams) = setup cid (Container image runparams) =
provisionContainer cid provisionContainer cid
@ -86,13 +94,19 @@ docked hosts cn = RevertableProperty (go "docked" setup) (go "undocked" teardown
] ]
] ]
exposeDnsAttrs :: Host -> Property -> Property
exposeDnsAttrs (Host _ containerattr) p = combineProperties (propertyDesc p) $
p : map addDNS (S.toList containerdns)
where
containerdns = _dns $ containerattr $ newAttr undefined
findContainer findContainer
:: [Host] :: Maybe Host
-> ContainerId -> ContainerId
-> ContainerName -> ContainerName
-> (Container -> Property) -> (Container -> Property)
-> Property -> Property
findContainer hosts cid cn mk = case findHost hosts (cn2hn cn) of findContainer mhost cid cn mk = case mhost of
Nothing -> cantfind Nothing -> cantfind
Just h -> maybe cantfind mk (mkContainer cid h) Just h -> maybe cantfind mk (mkContainer cid h)
where where