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) (#3150)
* 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>
(cherry picked from commit a73720c103
)
Co-authored-by: Ricky White <rickywhite@outlook.com>
This commit is contained in:
parent
548758a878
commit
f493110651
2 changed files with 20 additions and 3 deletions
|
@ -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).
|
|
@ -112,16 +112,17 @@ EXAMPLES = r"""
|
|||
- ansible.builtin.debug:
|
||||
msg: the password is {{ secret_password }}
|
||||
"""
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||
|
||||
sdk_is_missing = False
|
||||
|
||||
try:
|
||||
from thycotic import __version__ as sdk_version
|
||||
from thycotic.secrets.server import (
|
||||
SecretServer,
|
||||
SecretServerAccessError,
|
||||
SecretServerError,
|
||||
PasswordGrantAuthorizer,
|
||||
)
|
||||
except ImportError:
|
||||
sdk_is_missing = True
|
||||
|
@ -136,7 +137,20 @@ display = Display()
|
|||
class LookupModule(LookupBase):
|
||||
@staticmethod
|
||||
def Client(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):
|
||||
if sdk_is_missing:
|
||||
|
|
Loading…
Reference in a new issue