1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Updated the tss lookup plugin to reflect breaking changes introduced in the underpinning SDK (#3139)

* Updated the plugin to reflect breaking changes introduced in the underlying SDK v1.0.0 update.

* Added Changelog fragment

* Updates based on feedback/review

* Added newline to pass CI

* Added whitepace for linter

* Update changelogs/fragments/3139-tss-lookup-plugin-update-to-make-compatible-with-sdk-v1.yml

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>

Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
This commit is contained in:
Ricky White 2021-08-05 13:28:32 -04:00 committed by GitHub
parent 3dba697e33
commit a73720c103
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- tss lookup plugin - fixed incompatibility with ``python-tss-sdk`` version 1.0.0
(https://github.com/ansible-collections/community.general/issues/3057, https://github.com/ansible-collections/community.general/pull/3139).

View file

@ -112,16 +112,17 @@ EXAMPLES = r"""
- ansible.builtin.debug: - ansible.builtin.debug:
msg: the password is {{ secret_password }} msg: the password is {{ secret_password }}
""" """
from distutils.version import LooseVersion
from ansible.errors import AnsibleError, AnsibleOptionsError from ansible.errors import AnsibleError, AnsibleOptionsError
sdk_is_missing = False sdk_is_missing = False
try: try:
from thycotic import __version__ as sdk_version
from thycotic.secrets.server import ( from thycotic.secrets.server import (
SecretServer, SecretServer,
SecretServerAccessError,
SecretServerError, SecretServerError,
PasswordGrantAuthorizer,
) )
except ImportError: except ImportError:
sdk_is_missing = True sdk_is_missing = True
@ -136,7 +137,20 @@ display = Display()
class LookupModule(LookupBase): class LookupModule(LookupBase):
@staticmethod @staticmethod
def Client(server_parameters): def Client(server_parameters):
return SecretServer(**server_parameters)
if LooseVersion(sdk_version) < LooseVersion('1.0.0'):
return SecretServer(**server_parameters)
else:
authorizer = PasswordGrantAuthorizer(
server_parameters["base_url"],
server_parameters["username"],
server_parameters["password"],
server_parameters["token_path_uri"],
)
return SecretServer(
server_parameters["base_url"], authorizer, server_parameters["api_path_uri"]
)
def run(self, terms, variables, **kwargs): def run(self, terms, variables, **kwargs):
if sdk_is_missing: if sdk_is_missing: