From a144abfc0623020f7facb881eff329263b698205 Mon Sep 17 00:00:00 2001 From: arnaud@30aba4d9f1742050874551d3ddc55ca8694809f8 Date: Thu, 11 Jun 2015 19:19:07 +0000 Subject: Added a comment: Works like a charm... --- ...ent_5_cd61e6fb0d5694575edb95728f0c8370._comment | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doc/forum/passing_host_address_dynamically_to_propellor/comment_5_cd61e6fb0d5694575edb95728f0c8370._comment (limited to 'doc/forum/passing_host_address_dynamically_to_propellor') 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 +``` +"""]] -- cgit v1.2.3