diff options
author | Anton Aksola <anton.aksola@nebula.fi> | 2014-05-02 12:51:20 +0300 |
---|---|---|
committer | Anton Aksola <anton.aksola@nebula.fi> | 2014-05-02 12:51:20 +0300 |
commit | 34af261b7928ba7d62496d2d87fbe64b1badc930 (patch) | |
tree | 042a7321ed59c6aa2e95df5c53a201d4d22bbed3 | |
parent | 1a68ed15f20fd6b6128ae9533ec276341b35a530 (diff) |
Introduce group level configuration for auth
For rancid-like behaviour one can now set username and password for node groups. These parameters are considered in the following order:
1) node parameters (from source)
2) group level parameters
3) global level parameters
example configuration for group 'testlab'
groups:
testlab:
username: testuser
password: testpassword
-rw-r--r-- | lib/oxidized/node.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index 3ac1c90..fce4c21 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -99,9 +99,19 @@ module Oxidized end def resolve_auth opt + # Resolve configured username/password, give priority to group level configuration + # TODO: refactor to use revised behaviour of Asetus + cfg_username, cfg_password = + if CFG.groups.has_key?(@group) and ['username', 'password'].all? {|e| CFG.groups[@group].has_key?(e)} + [CFG.groups[@group].username, CFG.groups[@group].password] + elsif ['username', 'password'].all? {|e| CFG.has_key?(e)} + [CFG.username, CFG.password] + else + [nil, nil] + end auth = {} - auth[:username] = (opt[:username] or CFG.username) - auth[:password] = (opt[:passowrd] or CFG.password) + auth[:username] = (opt[:username] or cfg_username) + auth[:password] = (opt[:password] or cfg_password) auth end |