summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/SiteSpecific
diff options
context:
space:
mode:
authorJoey Hess2015-12-05 17:52:43 -0400
committerJoey Hess2015-12-05 17:53:16 -0400
commit12548bae3d8feecce6a322162d91b827289ae824 (patch)
tree45f5ec5131817aab5133c9c1e4dbcf3364953e76 /src/Propellor/Property/SiteSpecific
parentb816e40e2618a8932144bceb7c7039adc5c44c11 (diff)
UncheckedProperty for cmdProperty et al
* Properties that run an arbitrary command, such as cmdProperty and scriptProperty are converted to use UncheckedProperty, since they cannot tell on their own if the command truely made a change or not. (API Change) Transition guide: - When GHC complains about an UncheckedProperty, add: `assume` MadeChange - Since these properties used to always return MadeChange, that change is always safe to make. - Or, if you know that the command should modifiy a file, use: `changesFile` filename * A few properties have had their Result improved, for example Apt.buldDep and Apt.autoRemove now check if a change was made or not.
Diffstat (limited to 'src/Propellor/Property/SiteSpecific')
-rw-r--r--src/Propellor/Property/SiteSpecific/Branchable.hs2
-rw-r--r--src/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs8
-rw-r--r--src/Propellor/Property/SiteSpecific/GitHome.hs2
-rw-r--r--src/Propellor/Property/SiteSpecific/IABak.hs19
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs13
5 files changed, 32 insertions, 12 deletions
diff --git a/src/Propellor/Property/SiteSpecific/Branchable.hs b/src/Propellor/Property/SiteSpecific/Branchable.hs
index 66b7ed11..5c85610b 100644
--- a/src/Propellor/Property/SiteSpecific/Branchable.hs
+++ b/src/Propellor/Property/SiteSpecific/Branchable.hs
@@ -17,7 +17,7 @@ server hosts = propertyList "branchable server" $ props
, "en_US.UTF-8 UTF-8"
, "fi_FI.UTF-8 UTF-8"
]
- `onChange` cmdProperty "locale-gen" []
+ `onChange` (cmdProperty "locale-gen" [] `assume` MadeChange)
& Apt.installed ["etckeeper", "ssh", "popularity-contest"]
& Apt.serviceInstalledRunning "apache2"
diff --git a/src/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs b/src/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs
index 3f7cbad1..a34071ce 100644
--- a/src/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs
+++ b/src/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs
@@ -60,10 +60,12 @@ tree buildarch flavor = combineProperties "gitannexbuilder tree" $ props
, "cd " ++ gitbuilderdir
, "git checkout " ++ buildarch ++ fromMaybe "" flavor
]
+ `assume` MadeChange
`describe` "gitbuilder setup"
builddircloned = check (not <$> doesDirectoryExist builddir) $ userScriptProperty (User builduser)
[ "git clone git://git-annex.branchable.com/ " ++ builddir
]
+ `assume` MadeChange
buildDepsApt :: Property HasInfo
buildDepsApt = combineProperties "gitannexbuilder build deps" $ props
@@ -88,13 +90,16 @@ haskellPkgsInstalled dir = flagFile go ("/haskellpkgsinstalled")
go = userScriptProperty (User builduser)
[ "cd " ++ builddir ++ " && ./standalone/" ++ dir ++ "/install-haskell-packages"
]
+ `assume` MadeChange
-- Installs current versions of git-annex's deps from cabal, but only
-- does so once.
cabalDeps :: Property NoInfo
cabalDeps = flagFile go cabalupdated
where
- go = userScriptProperty (User builduser) ["cabal update && cabal install git-annex --only-dependencies || true"]
+ go = userScriptProperty (User builduser)
+ ["cabal update && cabal install git-annex --only-dependencies || true"]
+ `assume` MadeChange
cabalupdated = homedir </> ".cabal" </> "packages" </> "hackage.haskell.org" </> "00-index.cache"
autoBuilderContainer :: (System -> Flavor -> Property HasInfo) -> System -> Flavor -> Times -> TimeOut -> Systemd.Container
@@ -158,5 +163,6 @@ androidContainer name setupgitannexdir gitannexdir = Systemd.container name osve
chrootsetup = scriptProperty
[ "cd " ++ gitannexdir ++ " && ./standalone/android/buildchroot-inchroot"
]
+ `assume` MadeChange
osver = System (Debian (Stable "jessie")) "i386"
bootstrap = Chroot.debootstrapped mempty
diff --git a/src/Propellor/Property/SiteSpecific/GitHome.hs b/src/Propellor/Property/SiteSpecific/GitHome.hs
index 9b01b5e2..83a1a16a 100644
--- a/src/Propellor/Property/SiteSpecific/GitHome.hs
+++ b/src/Propellor/Property/SiteSpecific/GitHome.hs
@@ -14,11 +14,13 @@ installedFor user@(User u) = check (not <$> hasGitDir user) $
let tmpdir = home </> "githome"
ensureProperty $ combineProperties "githome setup"
[ userScriptProperty user ["git clone " ++ url ++ " " ++ tmpdir]
+ `assume` MadeChange
, property "moveout" $ makeChange $ void $
moveout tmpdir home
, property "rmdir" $ makeChange $ void $
catchMaybeIO $ removeDirectory tmpdir
, userScriptProperty user ["rm -rf .aptitude/ .bashrc .profile; bin/mr checkout; bin/fixups"]
+ `assume` MadeChange
]
moveout tmpdir home = do
fs <- dirContents tmpdir
diff --git a/src/Propellor/Property/SiteSpecific/IABak.hs b/src/Propellor/Property/SiteSpecific/IABak.hs
index fce5aefb..bb62fba7 100644
--- a/src/Propellor/Property/SiteSpecific/IABak.hs
+++ b/src/Propellor/Property/SiteSpecific/IABak.hs
@@ -30,7 +30,7 @@ gitServer knownhosts = propertyList "iabak git server" $ props
& Ssh.knownHost knownhosts "gitlab.com" (User "root")
& Git.cloned (User "root") userrepo "/usr/local/IA.BAK/pubkeys" (Just "master")
& Apt.serviceInstalledRunning "apache2"
- & cmdProperty "ln" ["-sf", "/usr/local/IA.BAK/pushme.cgi", "/usr/lib/cgi-bin/pushme.cgi"]
+ & "/usr/lib/cgi-bin/pushme.cgi" `File.isSymlinkedTo` File.LinkTarget "/usr/local/IA.BAK/pushme.cgi"
& File.containsLine "/etc/sudoers" "www-data ALL=NOPASSWD:/usr/local/IA.BAK/pushed.sh"
& Cron.niceJob "shardstats" (Cron.Times "*/30 * * * *") (User "root") "/"
"/usr/local/IA.BAK/shardstats-all"
@@ -51,8 +51,9 @@ registrationServer knownhosts = propertyList "iabak registration server" $ props
& Git.cloned (User "registrar") userrepo "/home/registrar/users" (Just "master")
& Apt.serviceInstalledRunning "apache2"
& Apt.installed ["perl", "perl-modules"]
- & cmdProperty "ln" ["-sf", "/home/registrar/IA.BAK/registrar/register.cgi", link]
+ & link `File.isSymlinkedTo` File.LinkTarget "/home/registrar/IA.BAK/registrar/register.cgi"
& cmdProperty "chown" ["-h", "registrar:registrar", link]
+ `changesFile` link
& File.containsLine "/etc/sudoers" "www-data ALL=(registrar) NOPASSWD:/home/registrar/IA.BAK/registrar/register.pl"
& Apt.installed ["kgb-client"]
& File.hasPrivContentExposed "/etc/kgb-bot/kgb-client.conf" anyContext
@@ -84,11 +85,15 @@ graphiteServer = propertyList "iabak graphite server" $ props
, "retentions = 60s:1d"
]
& graphiteCSRF
- & cmdProperty "graphite-manage" ["syncdb", "--noinput"] `flagFile` "/etc/flagFiles/graphite-syncdb"
- & cmdProperty "graphite-manage" ["createsuperuser", "--noinput", "--username=joey", "--email=joey@localhost"] `flagFile` "/etc/flagFiles/graphite-user-joey"
- `flagFile` "/etc/graphite-superuser-joey"
- & cmdProperty "graphite-manage" ["createsuperuser", "--noinput", "--username=db48x", "--email=db48x@localhost"] `flagFile` "/etc/flagFiles/graphite-user-db48x"
- `flagFile` "/etc/graphite-superuser-db48x"
+ & cmdProperty "graphite-manage" ["syncdb", "--noinput"]
+ `assume` MadeChange
+ `flagFile` "/etc/flagFiles/graphite-syncdb"
+ & cmdProperty "graphite-manage" ["createsuperuser", "--noinput", "--username=joey", "--email=joey@localhost"]
+ `assume` MadeChange
+ `flagFile` "/etc/flagFiles/graphite-user-joey"
+ & cmdProperty "graphite-manage" ["createsuperuser", "--noinput", "--username=db48x", "--email=db48x@localhost"]
+ `assume` MadeChange
+ `flagFile` "/etc/flagFiles/graphite-user-db48x"
-- TODO: deal with passwords somehow
& File.ownerGroup "/var/lib/graphite/graphite.db" (User "_graphite") (Group "_graphite")
& "/etc/apache2/ports.conf" `File.containsLine` "Listen 8080"
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index ff92bf2d..732714db 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -39,6 +39,7 @@ scrollBox = propertyList "scroll server" $ props
, "cabal configure"
, "make"
]
+ `assume` MadeChange
& s `File.hasContent`
[ "#!/bin/sh"
, "set -e"
@@ -165,7 +166,9 @@ oldUseNetInstalled pkg = check (not <$> Apt.isInstalled pkg) $
, "dpkg -i ../" ++ pkg ++ "_*.deb || true"
, "apt-get -fy install" -- dependencies
, "rm -rf /root/tmp/oldusenet"
- ] `describe` "olduse.net built"
+ ]
+ `assume` MadeChange
+ `describe` "olduse.net built"
kgbServer :: Property HasInfo
kgbServer = propertyList desc $ props
@@ -197,7 +200,8 @@ mumbleServer hosts = combineProperties hn $ props
(Context hn)
(SshRsa, "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSXXSM3mM8SNu+qel9R/LkDIkjpV3bfpUtRtYv2PTNqicHP+DdoThrr0ColFCtLH+k2vQJvR2n8uMzHn53Dq2IO3TtD27+7rJSsJwAZ8oftNzuTir8IjAwX5g6JYJs+L0Ny4RB0ausd+An0k/CPMRl79zKxpZd2MBMDNXt8hyqu0vS0v1ohq5VBEVhBBvRvmNQvWOCj7PdrKQXpUBHruZOeVVEdUUXZkVc1H0t7LVfJnE+nGKyWbw2jM+7r3Rn5Semc4R1DxsfaF8lKkZyE88/5uZQ/ddomv8ptz6YZ5b+Bg6wfooWPC3RWAALjxnHaC2yN1VONAvHmT0uNn1o6v0b")
`requires` Ssh.knownHost hosts "usw-s002.rsync.net" (User "root")
- & trivial (cmdProperty "chown" ["-R", "mumble-server:mumble-server", "/var/lib/mumble-server"])
+ & cmdProperty "chown" ["-R", "mumble-server:mumble-server", "/var/lib/mumble-server"]
+ `assume` NoChange
where
hn = "mumble.debian.net"
sshkey = "/root/.ssh/mumble.debian.net.key"
@@ -274,6 +278,7 @@ annexWebSite origin hn uuid remotes = propertyList (hn ++" website using git-ann
dir = "/srv/web/" ++ hn
postupdatehook = dir </> ".git/hooks/post-update"
setup = userScriptProperty (User "joey") setupscript
+ `assume` MadeChange
setupscript =
[ "cd " ++ shellEscape dir
, "git annex reinit " ++ shellEscape uuid
@@ -393,6 +398,7 @@ twitRss = combineProperties "twitter rss" $ props
[ "cd " ++ dir
, "ghc --make twitRss"
]
+ `assume` NoChange
`requires` Apt.installed
[ "libghc-xml-dev"
, "libghc-feed-dev"
@@ -413,7 +419,8 @@ ircBouncer = propertyList "IRC bouncer" $ props
& File.ownerGroup conf (User "znc") (Group "znc")
& Cron.job "znconboot" (Cron.Times "@reboot") (User "znc") "~" "znc"
-- ensure running if it was not already
- & trivial (userScriptProperty (User "znc") ["znc || true"])
+ & userScriptProperty (User "znc") ["znc || true"]
+ `assume` NoChange
`describe` "znc running"
where
conf = "/home/znc/.znc/configs/znc.conf"