From 65646179f1b45787c19a7aae13ccd50fe2c86631 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 20 Feb 2020 10:01:09 -0800 Subject: [PATCH] Fix become for network_cli in collections. --- changelogs/fragments/network-cli-become-collections.yml | 2 ++ lib/ansible/plugins/action/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/network-cli-become-collections.yml diff --git a/changelogs/fragments/network-cli-become-collections.yml b/changelogs/fragments/network-cli-become-collections.yml new file mode 100644 index 00000000000..465a1f63bc6 --- /dev/null +++ b/changelogs/fragments/network-cli-become-collections.yml @@ -0,0 +1,2 @@ +bugfixes: + - Skipping of become for ``network_cli`` connections now works when ``network_cli`` is sourced from a collection. diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 1b8689dbe92..d1b034d763d 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -1048,7 +1048,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): ruser = self._get_remote_user() 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 + self._connection.transport.split('.')[-1] != 'network_cli' and # if not using network_cli (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)