summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2016-05-24 18:47:56 -0400
committerAdrian Likins <alikins@redhat.com>2016-05-24 18:47:56 -0400
commit675561e11627b3a8c82dca26b9ee262e57f99c1f (patch)
tree08eb777df14e7364ff1679a96eb06204ff69447e /contrib
parent650bfdce8f5ea0d83450e628db622d7ff34cb0a7 (diff)
downloadansible-675561e11627b3a8c82dca26b9ee262e57f99c1f.tar.gz
fix vault-keyring.py 'No [vault] section' error
vault-keyring.py was using an older version of the ansible.constants.load_config_file() API. The newer version returns a tuple, which caused the config load to fail and a catch all exception to blame it on a missing section. Update to new API, and catch the ConfigParser error specifically. Fixes #15984
Diffstat (limited to 'contrib')
-rwxr-xr-x[-rw-r--r--]contrib/vault/vault-keyring.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/contrib/vault/vault-keyring.py b/contrib/vault/vault-keyring.py
index bc001476c7..c154d56df1 100644..100755
--- a/contrib/vault/vault-keyring.py
+++ b/contrib/vault/vault-keyring.py
@@ -47,16 +47,17 @@
import sys
import getpass
import keyring
+import ConfigParser
-import ansible.constants as C
+import ansible.constants as C
def main():
- parser = C.load_config_file()
+ (parser,config_path) = C.load_config_file()
try:
username = parser.get('vault', 'username')
- except:
- sys.stderr.write('No [vault] section configured\n')
+ except ConfigParser.NoSectionError:
+ sys.stderr.write('No [vault] section configured in config file: %s\n' % config_path)
sys.exit(1)
if len(sys.argv) == 2 and sys.argv[1] == 'set':