propellor spin
This commit is contained in:
parent
845162a2b1
commit
6f032f7ee3
|
@ -44,15 +44,42 @@ docked
|
||||||
-> HostName
|
-> HostName
|
||||||
-> ContainerName
|
-> ContainerName
|
||||||
-> Property
|
-> Property
|
||||||
docked findcontainer hn cn =
|
docked findc hn cn = findContainer findc hn cn $
|
||||||
case findcontainer hn cn of
|
\(Container image containerprops) ->
|
||||||
Nothing -> containerDesc cid $ Property "" $ do
|
provisionContainer cid
|
||||||
warningMessage $ "missing definition for docker container \"" ++ fromContainerId cid
|
`requires`
|
||||||
return FailedChange
|
runningContainer cid image containerprops
|
||||||
Just (Container image containerprops) ->
|
where
|
||||||
provisionContainer cid
|
cid = ContainerId hn cn
|
||||||
`requires`
|
|
||||||
runningContainer cid image containerprops
|
-- | Ensures that a docker container is no longer running.
|
||||||
|
unDocked
|
||||||
|
:: (HostName -> ContainerName -> Maybe (Container))
|
||||||
|
-> HostName
|
||||||
|
-> ContainerName
|
||||||
|
-> Property
|
||||||
|
unDocked findc hn cn = findContainer findc hn cn $
|
||||||
|
\(Container image _containerprops) ->
|
||||||
|
Property ("undocked " ++ fromContainerId cid) $
|
||||||
|
report <$> mapM id
|
||||||
|
[ stopContainer cid
|
||||||
|
, removeContainer cid
|
||||||
|
, removeImage image
|
||||||
|
]
|
||||||
|
where
|
||||||
|
cid = ContainerId hn cn
|
||||||
|
|
||||||
|
findContainer
|
||||||
|
:: (HostName -> ContainerName -> Maybe (Container))
|
||||||
|
-> HostName
|
||||||
|
-> ContainerName
|
||||||
|
-> (Container -> Property)
|
||||||
|
-> Property
|
||||||
|
findContainer findc hn cn mk = case findc hn cn of
|
||||||
|
Nothing -> containerDesc (ContainerId hn cn) $ Property "" $ do
|
||||||
|
warningMessage $ "missing definition for docker container \"" ++ fromContainerId cid
|
||||||
|
return FailedChange
|
||||||
|
Just container -> mk container
|
||||||
where
|
where
|
||||||
cid = ContainerId hn cn
|
cid = ContainerId hn cn
|
||||||
|
|
||||||
|
@ -72,9 +99,6 @@ garbageCollected = propertyList "docker garbage collected"
|
||||||
report <$> (mapM removeContainer =<< listContainers AllContainers)
|
report <$> (mapM removeContainer =<< listContainers AllContainers)
|
||||||
gcimages = Property "docker images garbage collected" $ do
|
gcimages = Property "docker images garbage collected" $ do
|
||||||
report <$> (mapM removeImage =<< listImages)
|
report <$> (mapM removeImage =<< listImages)
|
||||||
report rmed
|
|
||||||
| or rmed = MadeChange
|
|
||||||
| otherwise = NoChange
|
|
||||||
|
|
||||||
-- | Pass to defaultMain to add docker containers.
|
-- | Pass to defaultMain to add docker containers.
|
||||||
-- You need to provide the function mapping from
|
-- You need to provide the function mapping from
|
||||||
|
@ -392,3 +416,9 @@ readIdentFile cid = fromMaybe (error "bad ident in identFile")
|
||||||
|
|
||||||
dockercmd :: String
|
dockercmd :: String
|
||||||
dockercmd = "docker.io"
|
dockercmd = "docker.io"
|
||||||
|
|
||||||
|
report :: [Bool] -> Result
|
||||||
|
report rmed
|
||||||
|
| or rmed = MadeChange
|
||||||
|
| otherwise = NoChange
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,10 @@ class ActionResult a where
|
||||||
|
|
||||||
instance ActionResult Bool where
|
instance ActionResult Bool where
|
||||||
getActionResult False = ("failed", Vivid, Red)
|
getActionResult False = ("failed", Vivid, Red)
|
||||||
getActionResult True = ("ok", Dull, Green)
|
getActionResult True = ("done", Dull, Green)
|
||||||
|
|
||||||
instance ActionResult Result where
|
instance ActionResult Result where
|
||||||
getActionResult NoChange = ("unchanged", Dull, Green)
|
getActionResult NoChange = ("ok", Dull, Green)
|
||||||
getActionResult MadeChange = ("done", Vivid, Green)
|
getActionResult MadeChange = ("done", Vivid, Green)
|
||||||
getActionResult FailedChange = ("failed", Vivid, Red)
|
getActionResult FailedChange = ("failed", Vivid, Red)
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ host hostname@"clam.kitenet.net" = Just
|
||||||
, File.dirExists "/var/www"
|
, File.dirExists "/var/www"
|
||||||
--, Docker.docked container hostname "webserver"
|
--, Docker.docked container hostname "webserver"
|
||||||
, Docker.garbageCollected
|
, Docker.garbageCollected
|
||||||
, Docker.docked container hostname "amd64-git-annex-builder"
|
, Docker.unDocked container hostname "amd64-git-annex-builder"
|
||||||
, Apt.installed ["git-annex", "mtr"]
|
, Apt.installed ["git-annex", "mtr"]
|
||||||
-- Should come last as it reboots.
|
-- Should come last as it reboots.
|
||||||
, Apt.installed ["systemd-sysv"] `onChange` Reboot.now
|
, Apt.installed ["systemd-sysv"] `onChange` Reboot.now
|
||||||
|
@ -54,8 +54,8 @@ host hostname@"orca.kitenet.net" = Just
|
||||||
, standardSystem Unstable
|
, standardSystem Unstable
|
||||||
, Apt.unattendedUpgrades True
|
, Apt.unattendedUpgrades True
|
||||||
, Docker.configured
|
, Docker.configured
|
||||||
, Docker.docked container hostname "amd64-git-annex-builder"
|
, Docker.unDocked container hostname "amd64-git-annex-builder"
|
||||||
, Docker.docked container hostname "i386-git-annex-builder"
|
, Docker.unDocked container hostname "i386-git-annex-builder"
|
||||||
, Docker.garbageCollected
|
, Docker.garbageCollected
|
||||||
]
|
]
|
||||||
-- add more hosts here...
|
-- add more hosts here...
|
||||||
|
|
Loading…
Reference in New Issue