Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyring option to vault program to set the CEPH_KEYRING envvar #80

Merged
merged 6 commits into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# 2.6.2

## User interface

* The `CEPH_KEYRING` environment variable no longer needs to be manually
specified; it can be passed in as the `--keyring` command-line
option to the `vault` program.

* The unused `Event` type has been removed from the `Vaultaire.Writer`
module.

# 2.6.1

## User interface

To disable profiling, run ``vault --no-profiling``. By default,
profiling is enabled with a period of 1s and an accuracy bound of 2048
telemetric stats per second.
Expand Down
8 changes: 5 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ you want to make the broker highly-available, use a TCP load-balancer).

The defaults assume your Rados pool is called `vaultaire`, and you're
connecting with the username `vaultaire`; if this isn't the case,
override with `-p` and `-u` respectively. In either case, you'll need to
have the environment variable `CEPH_KEYRING` pointing to the correct
place.
override with `-p` and `-u` respectively.

Additionally, if your Ceph keyring is not at the default path used by
librados (`/etc/ceph/keyring` as of Feburary 2015) you'll need to
override it with `-k /path/to/your/keyring/file`.

```
vault -d broker # Start broker in debug mode
Expand Down
51 changes: 39 additions & 12 deletions src/Vault.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Data.Word (Word64)
import Options.Applicative hiding (Parser, option)
import qualified Options.Applicative as O
import System.Directory
import System.Environment
import System.Log.Logger
import Text.Read
import Text.Trifecta
Expand All @@ -30,16 +31,17 @@ import Vaultaire.Program


data Options = Options
{ pool :: String
, user :: String
, broker :: String
, debug :: Bool
, quiet :: Bool
, noprofile :: Bool
, period :: Int
, bound :: Int
, name :: String
, component :: Component }
{ pool :: String
, user :: String
, broker :: String
, debug :: Bool
, quiet :: Bool
, noprofile :: Bool
, period :: Int
, bound :: Int
, name :: String
, keyring :: String
, component :: Component }

data Component = Broker
| Reader
Expand All @@ -61,6 +63,7 @@ optionsParser Options{..} = Options <$> parsePool
<*> parsePeriod
<*> parseBound
<*> parseName
<*> parseKeyring
<*> parseComponents
where
parsePool = strOption $
Expand Down Expand Up @@ -123,6 +126,13 @@ optionsParser Options{..} = Options <$> parsePool
<> showDefault
<> help "Identifiable name for the daemon. Useful for telemetrics."

parseKeyring = strOption $
long "keyring"
<> short 'k'
<> metavar "KEYRING"
<> value ""
<> help "Path to Ceph keyring file. If set, this will override the CEPH_KEYRING environment variable."

parseComponents = subparser
( parseBrokerComponent
<> parseReaderComponent
Expand Down Expand Up @@ -168,8 +178,17 @@ parseConfig fp = do
Nothing -> error "Failed to parse config"
else return defaultConfig
where
defaultConfig = Options "vaultaire" "vaultaire" "localhost"
False False False 1000 2048 "" Broker
defaultConfig = Options "vaultaire" -- Use 'vaultaire' rados pool.
"vaultaire" -- Connect as 'vaultaire' user.
"localhost" -- Default to broker on localhost.
False -- Don't print debug output.
False -- Don't suppress all output.
False -- Don't disable profiling.
1000 -- Write telemetry every 1000ms.
2048 -- Handle <= 2048 telemetry reports per period.
"" -- Use a blank agent name for telemetry.
"" -- Don't set CEPH_KEYRING.
Broker -- Run in broker mode.
mergeConfig ls Options{..} = fromJust $
Options <$> lookup "pool" ls `mplus` pure pool
<*> lookup "user" ls `mplus` pure user
Expand All @@ -180,6 +199,7 @@ parseConfig fp = do
<*> (join $ readMaybe <$> lookup "period" ls) `mplus` pure period
<*> (join $ readMaybe <$> lookup "bound" ls) `mplus` pure period
<*> lookup "name" ls `mplus` pure name
<*> lookup "keyring" ls `mplus` pure keyring
<*> pure Broker

configParser :: Parser [(String, String)]
Expand All @@ -196,6 +216,11 @@ possibleKeys =
parseArgsWithConfig :: FilePath -> IO Options
parseArgsWithConfig = parseConfig >=> execParser . helpfulParser

-- If set, override CEPH_KEYRING envvar (used by librados).
updateCephKeyring :: String -> IO ()
updateCephKeyring "" = return ()
updateCephKeyring k = setEnv "CEPH_KEYRING" k

--
-- Main program entry point
--
Expand All @@ -208,6 +233,8 @@ main = do
| quiet = Quiet
| otherwise = Normal

updateCephKeyring keyring

quit <- initializeProgram (package ++ "-" ++ version) level

-- Run daemon(s, at present just one). These are all expected to fork
Expand Down
2 changes: 1 addition & 1 deletion vaultaire.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: >= 1.10
name: vaultaire
version: 2.6.1.4
version: 2.6.2.0
synopsis: Data vault for metrics
description: Data vault for metrics
license: BSD3
Expand Down