summaryrefslogtreecommitdiff
path: root/doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment
diff options
context:
space:
mode:
Diffstat (limited to 'doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment')
-rw-r--r--doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment23
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment b/doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment
new file mode 100644
index 00000000..79f721f1
--- /dev/null
+++ b/doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment
@@ -0,0 +1,23 @@
+[[!comment format=mdwn
+ username="arnaud@30aba4d9f1742050874551d3ddc55ca8694809f8"
+ nickname="arnaud"
+ subject="Works like a charm..."
+ date="2015-06-11T19:19:07Z"
+ content="""
+I implemented this feature using a file, aptly named `hosts` that is versioned in the repo and populated (at the moment manually but will be automatic...) when boxes are created in DO.
+Then the following main will extract the information and create hosts config to be passed to main from propellor, reading the needed file:
+
+```
+main :: IO ()
+main = do
+ h <- map words <$> lines <$> readFile \"hosts\" `catch` (\ (_ :: IOException) -> return \"\")
+ let hosts = map selectHost h
+ defaultMain hosts
+
+selectHost :: [String] -> Host
+selectHost [\"prod\",ip,sha1] = host ip & Lending.lendingHost sha1
+selectHost [\"prod\",ip] = host ip & Lending.lendingHost currentSha1
+selectHost [\"monitor\",name,ip] = host name & Monitoring.monitoringHost ip
+selectHost h = error $ \"doesn't know how to handle host definition \" ++ show h
+```
+"""]]