From 74ac229fa877572a036eac4b4bfe278f0cd3826f Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 22 Jul 2019 13:24:31 -0400 Subject: [PATCH] fix all cases of none remote/become users (#59397) some cases failed, when defaults were None on the plugins --- changelogs/fragments/fix_all_none_users.yml | 2 ++ lib/ansible/plugins/action/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/fix_all_none_users.yml diff --git a/changelogs/fragments/fix_all_none_users.yml b/changelogs/fragments/fix_all_none_users.yml new file mode 100644 index 00000000000..047713ae4ec --- /dev/null +++ b/changelogs/fragments/fix_all_none_users.yml @@ -0,0 +1,2 @@ +bugfixes: + - ensure all cases of a None remote/become user are covered. diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 38bafb163ff..0358df94d79 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -1043,7 +1043,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): buser = self.get_become_option('become_user') if (sudoable and self._connection.become and # if sudoable and have become self._connection.transport != 'network_cli' and # if not using network_cli - (C.BECOME_ALLOW_SAME_USER or (buser != ruser and (ruser or buser)))): # if we allow same user PE or users are different and either is set + (C.BECOME_ALLOW_SAME_USER or (buser != ruser or not any((ruser, buser))))): # if we allow same user PE or users are different and either is set display.debug("_low_level_execute_command(): using become for this command") cmd = self._connection.become.build_become_command(cmd, self._connection._shell)