mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Added fix for bug report in issue #3192 * Added changelog fragment * Typo fix * Added Importerror to exception - as req by linters * Moved the conditional import statement to try/except block
This commit is contained in:
parent
41101e55a0
commit
6ac410b3f6
2 changed files with 22 additions and 7 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- tss lookup plugin - fixed backwards compatibility issue with ``python-tss-sdk`` version <=0.0.5
|
||||||
|
(https://github.com/ansible-collections/community.general/issues/3192, https://github.com/ansible-collections/community.general/pull/3199).
|
|
@ -118,15 +118,23 @@ 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 SecretServer, SecretServerError
|
||||||
from thycotic.secrets.server import (
|
|
||||||
SecretServer,
|
|
||||||
SecretServerError,
|
|
||||||
PasswordGrantAuthorizer,
|
|
||||||
)
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sdk_is_missing = True
|
sdk_is_missing = True
|
||||||
|
|
||||||
|
# Added for backwards compatability - See issue #3192
|
||||||
|
# https://github.com/ansible-collections/community.general/issues/3192
|
||||||
|
try:
|
||||||
|
from thycotic import __version__ as sdk_version
|
||||||
|
except ImportError:
|
||||||
|
sdk_version = "0.0.5"
|
||||||
|
|
||||||
|
try:
|
||||||
|
from thycotic.secrets.server import PasswordGrantAuthorizer
|
||||||
|
sdK_version_below_v1 = False
|
||||||
|
except ImportError:
|
||||||
|
sdK_version_below_v1 = True
|
||||||
|
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
from ansible.plugins.lookup import LookupBase
|
from ansible.plugins.lookup import LookupBase
|
||||||
|
|
||||||
|
@ -138,9 +146,13 @@ class LookupModule(LookupBase):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def Client(server_parameters):
|
def Client(server_parameters):
|
||||||
|
|
||||||
if LooseVersion(sdk_version) < LooseVersion('1.0.0'):
|
if LooseVersion(sdk_version) < LooseVersion('1.0.0') or sdK_version_below_v1:
|
||||||
return SecretServer(**server_parameters)
|
return SecretServer(**server_parameters)
|
||||||
else:
|
else:
|
||||||
|
# The Password Authorizer became available in v1.0.0 and beyond.
|
||||||
|
# Import only if sdk_version requires it.
|
||||||
|
# from thycotic.secrets.server import PasswordGrantAuthorizer
|
||||||
|
|
||||||
authorizer = PasswordGrantAuthorizer(
|
authorizer = PasswordGrantAuthorizer(
|
||||||
server_parameters["base_url"],
|
server_parameters["base_url"],
|
||||||
server_parameters["username"],
|
server_parameters["username"],
|
||||||
|
|
Loading…
Reference in a new issue