From 9f39294f50fdc6c793b1de805dd814beb31716de Mon Sep 17 00:00:00 2001 From: Tom Reeb Date: Tue, 23 Aug 2022 15:53:06 -0400 Subject: [PATCH] adding nested try block for tss.py to import new Delinea library (#5151) * adding nested try block to import delinea library * whitespace * Update plugins/lookup/tss.py Co-authored-by: Felix Fontein * adding changelog fragment * Update changelogs/fragments/5151-add-delinea-support-tss-lookup.yml Co-authored-by: Felix Fontein Co-authored-by: Tom Reeb Co-authored-by: Felix Fontein --- .../5151-add-delinea-support-tss-lookup.yml | 3 +++ plugins/lookup/tss.py | 24 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/5151-add-delinea-support-tss-lookup.yml diff --git a/changelogs/fragments/5151-add-delinea-support-tss-lookup.yml b/changelogs/fragments/5151-add-delinea-support-tss-lookup.yml new file mode 100644 index 0000000000..38d9c9e593 --- /dev/null +++ b/changelogs/fragments/5151-add-delinea-support-tss-lookup.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - tss lookup plugin - adding support for updated Delinea library (https://github.com/DelineaXPM/python-tss-sdk/issues/9, https://github.com/ansible-collections/community.general/pull/5151). diff --git a/plugins/lookup/tss.py b/plugins/lookup/tss.py index 756f168e5b..935b5f4b46 100644 --- a/plugins/lookup/tss.py +++ b/plugins/lookup/tss.py @@ -171,19 +171,29 @@ try: HAS_TSS_SDK = True except ImportError: - SecretServer = None - SecretServerError = None - HAS_TSS_SDK = False + try: + from delinea.secrets.server import SecretServer, SecretServerError + + HAS_TSS_SDK = True + except ImportError: + SecretServer = None + SecretServerError = None + HAS_TSS_SDK = False try: from thycotic.secrets.server import PasswordGrantAuthorizer, DomainPasswordGrantAuthorizer, AccessTokenAuthorizer HAS_TSS_AUTHORIZER = True except ImportError: - PasswordGrantAuthorizer = None - DomainPasswordGrantAuthorizer = None - AccessTokenAuthorizer = None - HAS_TSS_AUTHORIZER = False + try: + from delinea.secrets.server import PasswordGrantAuthorizer, DomainPasswordGrantAuthorizer, AccessTokenAuthorizer + + HAS_TSS_AUTHORIZER = True + except ImportError: + PasswordGrantAuthorizer = None + DomainPasswordGrantAuthorizer = None + AccessTokenAuthorizer = None + HAS_TSS_AUTHORIZER = False display = Display()