propellor spin

This commit is contained in:
Joey Hess 2014-04-13 20:22:35 -04:00
parent 774f6600eb
commit fb1d65125b
Failed to extract signature
2 changed files with 68 additions and 87 deletions

View File

@ -79,7 +79,21 @@ gitServer hosts = propertyList "git.kitenet.net setup"
, toProp $ Apache.modEnabled "cgi" , toProp $ Apache.modEnabled "cgi"
] ]
where where
website hn = toProp $ Apache.siteEnabled hn (gitapacheconf hn) website hn = toProp $ Apache.siteEnabled hn $ apachecfg hn True
[ " DocumentRoot /srv/web/git.kitenet.net/"
, " <Directory /srv/web/git.kitenet.net/>"
, " Options Indexes ExecCGI FollowSymlinks"
, " AllowOverride None"
, " AddHandler cgi-script .cgi"
, " DirectoryIndex index.cgi"
, " </Directory>"
, ""
, " ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/"
, " <Directory /usr/lib/cgi-bin>"
, " SetHandler cgi-script"
, " Options ExecCGI"
, " </Directory>"
]
type AnnexUUID = String type AnnexUUID = String
@ -88,10 +102,6 @@ annexWebSite :: [Host] -> Git.RepoUrl -> HostName -> AnnexUUID -> [(String, Git.
annexWebSite hosts origin hn uuid remotes = Git.cloned "joey" origin dir Nothing annexWebSite hosts origin hn uuid remotes = Git.cloned "joey" origin dir Nothing
`onChange` setup `onChange` setup
`onChange` setupapache `onChange` setupapache
`requires` File.hasPrivContent "/etc/ssl/certs/web.pem"
`requires` File.hasPrivContent "/etc/ssl/private/web.pem"
`requires` File.hasPrivContent "/etc/ssl/certs/startssl.pem"
`requires` toProp (Apache.modEnabled "ssl")
where where
dir = "/srv/web/" ++ hn dir = "/srv/web/" ++ hn
setup = userScriptProperty "joey" setupscript setup = userScriptProperty "joey" setupscript
@ -104,91 +114,56 @@ annexWebSite hosts origin hn uuid remotes = Git.cloned "joey" origin dir Nothing
[ "git annex get" [ "git annex get"
] ]
addremote (name, url) = "git remote add " ++ shellEscape name ++ " " ++ shellEscape url addremote (name, url) = "git remote add " ++ shellEscape name ++ " " ++ shellEscape url
setupapache = toProp (Apache.siteEnabled hn $ annexwebsiteconf hn) setupapache = toProp $ Apache.siteEnabled hn $ apachecfg hn True $
[ " ServerAlias www."++hn
, ""
, " DocumentRoot /srv/web/"++hn
, " <Directory /srv/web/"++hn++">"
, " Options FollowSymLinks"
, " AllowOverride None"
, " </Directory>"
, " <Directory /srv/web/"++hn++">"
, " Options Indexes FollowSymLinks ExecCGI"
, " AllowOverride None"
, " Order allow,deny"
, " allow from all"
, " </Directory>"
]
annexwebsiteconf :: HostName -> Apache.ConfigFile apachecfg :: HostName -> Bool -> Apache.ConfigFile -> Apache.ConfigFile
annexwebsiteconf hn = stanza 80 False ++ stanza 443 True apachecfg hn withssl middle
| withssl = vhost False ++ vhost True
| otherwise = vhost False
where where
stanza :: Int -> Bool -> Apache.ConfigFile vhost ssl =
stanza port withssl = catMaybes [ "<VirtualHost *:"++show port++">"
[ Just $ "<VirtualHost *:"++show port++">" , " ServerAdmin grue@joeyh.name"
, Just $ " ServerAdmin joey@kitenet.net" , " ServerName "++hn++":"++show port
, Just $ "" ]
, Just $ " ServerName "++hn++":"++show port ++ mainhttpscert ssl
, Just $ " ServerAlias www."++hn ++ middle ++
, Just $ "" [ ""
, ssl $ " SSLEngine on" , " ErrorLog /var/log/apache2/error.log"
, ssl $ " SSLCertificateFile /etc/ssl/certs/web.pem" , " LogLevel warn"
, ssl $ " SSLCertificateKeyFile /etc/ssl/private/web.pem" , " CustomLog /var/log/apache2/access.log combined"
, ssl $ " SSLCertificateChainFile /etc/ssl/certs/startssl.pem" , " ServerSignature On"
, Just $ "" , " "
, Just $ " DocumentRoot /srv/web/"++hn , " <Directory \"/usr/share/apache2/icons\">"
, Just $ " <Directory /srv/web/"++hn++">" , " Options Indexes MultiViews"
, Just $ " Options FollowSymLinks" , " AllowOverride None"
, Just $ " AllowOverride None" , " Order allow,deny"
, Just $ " </Directory>" , " Allow from all"
, Just $ " <Directory /srv/web/"++hn++">" , " </Directory>"
, Just $ " Options Indexes FollowSymLinks ExecCGI" , "</VirtualHost>"
, Just $ " AllowOverride None"
, Just $ " Order allow,deny"
, Just $ " allow from all"
, Just $ " </Directory>"
, Just $ ""
, Just $ " ErrorLog /var/log/apache2/error.log"
, Just $ " LogLevel warn"
, Just $ " CustomLog /var/log/apache2/access.log combined"
, Just $ " ServerSignature On"
, Just $ " "
, Just $ " <Directory \"/usr/share/apache2/icons\">"
, Just $ " Options Indexes MultiViews"
, Just $ " AllowOverride None"
, Just $ " Order allow,deny"
, Just $ " Allow from all"
, Just $ " </Directory>"
, Just $ "</VirtualHost>"
] ]
where where
ssl l port = if ssl then 443 else 80 :: Int
| withssl = Just l
| otherwise = Nothing
gitapacheconf :: HostName -> Apache.ConfigFile mainhttpscert :: Bool -> Apache.ConfigFile
gitapacheconf hn = mainhttpscert False = []
[ "<VirtualHost *:80>" mainhttpscert True =
, " ServerAdmin joey@kitenet.net" [ " SSLEngine on"
, "" , " SSLCertificateFile /etc/ssl/certs/web.pem"
, " ServerName " ++ hn ++ ":80" , " SSLCertificateKeyFile /etc/ssl/private/web.pem"
, "" , " SSLCertificateChainFile /etc/ssl/certs/startssl.pem"
, " DocumentRoot /srv/web/git.kitenet.net/"
, " <Directory /srv/web/git.kitenet.net/>"
, " Options Indexes ExecCGI FollowSymlinks"
, " AllowOverride None"
, " AddHandler cgi-script .cgi"
, " DirectoryIndex index.cgi"
, " </Directory>"
, ""
, " ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/"
, " <Directory /usr/lib/cgi-bin>"
, " SetHandler cgi-script"
, " Options ExecCGI"
, " </Directory>"
, ""
, " ErrorLog /var/log/apache2/error.log"
, " LogLevel warn"
, " CustomLog /var/log/apache2/access.log combined"
, ""
, " # Possible values include: debug, info, notice, warn, error, crit,"
, " # alert, emerg."
, " LogLevel warn"
, ""
, " CustomLog /var/log/apache2/access.log combined"
, " ServerSignature On"
, " "
, " <Directory \"/usr/share/apache2/icons\">"
, " Options Indexes MultiViews"
, " AllowOverride None"
, " Order allow,deny"
, " Allow from all"
, " </Directory>"
, "</VirtualHost>"
] ]

View File

@ -17,6 +17,7 @@ import qualified Propellor.Property.Dns as Dns
import qualified Propellor.Property.OpenId as OpenId import qualified Propellor.Property.OpenId as OpenId
import qualified Propellor.Property.Docker as Docker import qualified Propellor.Property.Docker as Docker
import qualified Propellor.Property.Git as Git import qualified Propellor.Property.Git as Git
import qualified Propellor.Property.Apache as Apache
import qualified Propellor.Property.Service as Service import qualified Propellor.Property.Service as Service
import qualified Propellor.Property.SiteSpecific.GitHome as GitHome import qualified Propellor.Property.SiteSpecific.GitHome as GitHome
import qualified Propellor.Property.SiteSpecific.GitAnnexBuilder as GitAnnexBuilder import qualified Propellor.Property.SiteSpecific.GitAnnexBuilder as GitAnnexBuilder
@ -74,7 +75,12 @@ hosts =
& Apt.unattendedUpgrades & Apt.unattendedUpgrades
& Apt.serviceInstalledRunning "ntp" & Apt.serviceInstalledRunning "ntp"
& Dns.zones myDnsSecondary & Dns.zones myDnsSecondary
& Apt.serviceInstalledRunning "apache2" & Apt.serviceInstalledRunning "apache2"
& File.hasPrivContent "/etc/ssl/certs/web.pem"
& File.hasPrivContent "/etc/ssl/private/web.pem"
& File.hasPrivContent "/etc/ssl/certs/startssl.pem"
& Apache.modEnabled "ssl"
& File.ownerGroup "/srv/web" "joey" "joey" & File.ownerGroup "/srv/web" "joey" "joey"
& cname "git.kitenet.net" & cname "git.kitenet.net"