From 2b998d030d69587888337909850a52c1e5e0c507 Mon Sep 17 00:00:00 2001 From: Jadyn Emma Jaeger Date: Wed, 16 Jun 2021 11:22:00 +0200 Subject: [PATCH] fix(gpg_secretstore): allow recrypt of all datatypes --- plugins/modules/gpg_secretstore.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/modules/gpg_secretstore.py b/plugins/modules/gpg_secretstore.py index 6d40a78..6a8f5f5 100644 --- a/plugins/modules/gpg_secretstore.py +++ b/plugins/modules/gpg_secretstore.py @@ -299,6 +299,7 @@ def main(): data_type = module.params["data_type"] overwrite = module.params["overwrite"] recrypt = module.params["recrypt"] + secret_type = module.params["secret_type"] if overwrite or recrypt: try: @@ -314,7 +315,15 @@ def main(): except (PasswordDecodeError, FileNotFoundError): result["action"] = "add" try: - store.put(slug=password_slug, data=secretGenerator.getSecret()) + if secretGenerator.secret_type == "binary": + save_as_data_type = "plain" + else: + save_as_data_type = data_type + store.put( + slug=password_slug, + data=secretGenerator.getSecret(), + data_type=save_as_data_type, + ) except (FileNotFoundError, PasswordStoreException): failed = True result[ @@ -331,7 +340,15 @@ def main(): logging.v("No secret found, new secret will be generated") result["secret"] = secretGenerator.getSecret() try: - store.put(slug=password_slug, data=secretGenerator.getSecret()) + if secretGenerator.secret_type == "binary": + save_as_data_type = "plain" + else: + save_as_data_type = data_type + store.put( + slug=password_slug, + data=secretGenerator.getSecret(), + data_type=save_as_data_type, + ) except (FileNotFoundError, PasswordStoreException): failed = True result[