Lookups: use Ansible's config manager whenever possible (#5440)

* Start using Ansible's config manager to handle options.

* Docs improvements.

* Fix documentation, make options actual lookup options.

* The cyberarkpassword lookup does too strange things.

* The onepassword lookups are converted in #4728, let's not interfere.

* Improve docs.

* Skip shelvefile as well.

* Convert lmdb_kv.

* Convert and fix credstash.

* Convert manifold.

* Drop chef_databag.

* Convert dig.

* Update examples.

* Forgot the most important part.

* Fix lmdb_kv docs.

* Python 2.6 compatibility.

* Convert AnsibleUnicode to str.

* Load lookup with lookup loader.

* Fix environment handling and error message checking.

* Improve docs formatting.
This commit is contained in:
Felix Fontein 2022-11-01 21:58:46 +01:00 committed by GitHub
parent dc66aefa40
commit e718bd8445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 161 additions and 91 deletions

View file

@ -207,7 +207,7 @@ class ManifoldApiClient(object):
class LookupModule(LookupBase):
def run(self, terms, variables=None, api_token=None, project=None, team=None):
def run(self, terms, variables=None, **kwargs):
"""
:param terms: a list of resources lookups to run.
:param variables: ansible variables active at the time of the lookup
@ -217,10 +217,11 @@ class LookupModule(LookupBase):
:return: a dictionary of resources credentials
"""
if not api_token:
api_token = os.getenv('MANIFOLD_API_TOKEN')
if not api_token:
raise AnsibleError('API token is required. Please set api_token parameter or MANIFOLD_API_TOKEN env var')
self.set_options(var_options=variables, direct=kwargs)
api_token = self.get_option('api_token')
project = self.get_option('project')
team = self.get_option('team')
try:
labels = terms