From a0ce33a53788757d16ad7bc4e84f8e7e04f959c7 Mon Sep 17 00:00:00 2001 From: Bombar Maxime Date: Sun, 19 Apr 2020 19:57:38 +0200 Subject: [PATCH] [re2oapi] If user is not specified, use re2o_service_user from the cpasswords vault. --- lookup_plugins/re2oapi.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lookup_plugins/re2oapi.py b/lookup_plugins/re2oapi.py index 6dcbe2b9..3e047916 100644 --- a/lookup_plugins/re2oapi.py +++ b/lookup_plugins/re2oapi.py @@ -12,8 +12,6 @@ For now: TODO: Implement a small client for our needs, this will also remove the sys.path extension ... """ - - from ansible.plugins.lookup import LookupBase from ansible.errors import AnsibleError @@ -47,6 +45,10 @@ class LookupModule(LookupBase): if api_hostname is None: raise AnsibleError('You must specify a hostname to contact re2oAPI') + if api_username is None and api_password is None: + api_username = variables.get('vault_re2o_service_user') + api_password = variables.get('vault_re2o_service_password') + if api_username is None: raise AnsibleError('You must specify a valid username to connect to re2oAPI')