From ac2bdd68346634dbc19c9b22ed744fdb01edc249 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 14 Dec 2021 16:07:36 +0100 Subject: [PATCH] Fix AttributeError when providing file via --conn-password-file (#76534) Fixes #76530 --- changelogs/fragments/76530-connection-password-file-tb-fix.yml | 2 ++ lib/ansible/cli/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/76530-connection-password-file-tb-fix.yml diff --git a/changelogs/fragments/76530-connection-password-file-tb-fix.yml b/changelogs/fragments/76530-connection-password-file-tb-fix.yml new file mode 100644 index 00000000000..963ebb222c8 --- /dev/null +++ b/changelogs/fragments/76530-connection-password-file-tb-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix ``AttributeError`` when providing password file via ``--connection-password-file`` (https://github.com/ansible/ansible/issues/76530) diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index e9b2eb3437c..08a971738f0 100644 --- a/lib/ansible/cli/__init__.py +++ b/lib/ansible/cli/__init__.py @@ -52,6 +52,7 @@ from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError from ansible.inventory.manager import InventoryManager from ansible.module_utils.six import string_types from ansible.module_utils._text import to_bytes, to_text +from ansible.module_utils.common.file import is_executable from ansible.parsing.dataloader import DataLoader from ansible.parsing.vault import PromptVaultSecret, get_file_vault_secret from ansible.plugins.loader import add_all_plugin_dirs @@ -540,7 +541,7 @@ class CLI(ABC): elif not os.path.exists(b_pwd_file): raise AnsibleError("The password file %s was not found" % pwd_file) - elif os.path.is_executable(b_pwd_file): + elif is_executable(b_pwd_file): display.vvvv(u'The password file %s is a script.' % to_text(pwd_file)) cmd = [b_pwd_file]