Skip to content

Instantly share code, notes, and snippets.

@mattyw
Created February 1, 2017 12:53
Show Gist options
  • Save mattyw/37bd419bed69954adfb7ff625d367ce6 to your computer and use it in GitHub Desktop.
Save mattyw/37bd419bed69954adfb7ff625d367ce6 to your computer and use it in GitHub Desktop.
cheap juju bootstrap, now in haskell \o/
#!/usr/bin/env runhaskell
{-# LANGUAGE OverloadedStrings #-}
import System.Environment
import System.Process
import System.Exit
usage = putStrLn "need to specify cloud and controller name"
parse [""] = usage >> exitWith ExitSuccess
parse ["-h"] = usage >> exitWith ExitSuccess
parse a = run a >> exitWith ExitSuccess
main = getArgs >>= parse
run :: [[Char]] -> IO ExitCode
run ("aws" : controller : xs) = bootstrapAndConstraint "aws" "t1.micro" controller
run ("google" : controller: xs) = bootstrapAndConstraint "google" "g1-small" controller
run a = usage >> exitWith ExitSuccess
bootstrapAndConstraint cloud inst controller = system (bootstrap cloud inst controller) >> system (constraint inst)
bootstrap cloud inst controller = "juju bootstrap " ++ cloud ++ " " ++controller ++ " --constraints instance-type=" ++ inst
constraint inst = "juju set-model-constraints instance-type=" ++ inst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment