From 90f86b8b2bb7f0a3c834387827c9ec2e1876f342 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 1 Apr 2014 01:12:05 -0400 Subject: not quite working docker container interface --- config.hs | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'config.hs') diff --git a/config.hs b/config.hs index 75309f6c..88703db7 100644 --- a/config.hs +++ b/config.hs @@ -1,5 +1,5 @@ -{- This is the main configuration file for Propellor, and is used to build - - the propellor program. -} +-- | This is the main configuration file for Propellor, and is used to build +-- the propellor program. import Propellor import Propellor.CmdLine @@ -18,16 +18,15 @@ import qualified Propellor.Property.GitHome as GitHome import qualified Propellor.Property.JoeySites as JoeySites main :: IO () -main = defaultMain getProperties +main = defaultMain [host, Docker.containerProperties container] -{- | This is where the system's HostName, either as returned by uname - - or one specified on the command line, is converted into a list of - - Properties for that system. - - - - Edit this to configure propellor! - -} -getProperties :: HostName -> Maybe [Property] -getProperties hostname@"clam.kitenet.net" = Just +-- | This is where the system's HostName, either as returned by uname +-- or one specified on the command line, is converted into a list of +-- Properties for that system. +-- +-- Edit this to configure propellor! +host :: HostName -> Maybe [Property] +host hostname@"clam.kitenet.net" = Just [ cleanCloudAtCost hostname , standardSystem Apt.Unstable , Apt.unattendedUpgrades True @@ -37,18 +36,31 @@ getProperties hostname@"clam.kitenet.net" = Just , Tor.isBridge , JoeySites.oldUseNetshellBox , Docker.configured + , File.dirExists "/var/www" + , Docker.hasContainer hostname "webserver" container , Apt.installed ["git-annex", "mtr"] -- Should come last as it reboots. , Apt.installed ["systemd-sysv"] `onChange` Reboot.now ] -getProperties "orca.kitenet.net" = Just +host "orca.kitenet.net" = Just [ standardSystem Apt.Unstable , Apt.unattendedUpgrades True , Docker.configured ] -- add more hosts here... ---getProperties "foo" = -getProperties _ = Nothing +--host "foo.example.com" = +host _ = Nothing + +-- | This is where Docker containers are set up. A container +-- can vary by hostname where it's used, or be the same everywhere. +container :: HostName -> Docker.ContainerName -> Maybe (Docker.Container) +container _ "webserver" = Just $ Docker.containerFromImage "debian" + [ Docker.publish "80:80" + , Docker.volume "/var/www:/var/www" + , Docker.inside $ serviceRunning "apache2" + `requires` Apt.installed ["apache2"] + ] +container _ _ = Nothing -- This is my standard system setup standardSystem :: Apt.Suite -> Property -- cgit v1.3-2-g0d8e