From e0eee3c37e8e802113d5c3c41681b1cf4af7b0e9 Mon Sep 17 00:00:00 2001 From: Ruheena Ansari Date: Fri, 28 Feb 2020 17:05:53 -0500 Subject: [PATCH] Run Powershell modules on windows container via docker connection (#67832) * Run modules on windows container This provides an ability to run Powershell modules on windows container via docker connection. Otherwise, Ansible tries to run python modules on windows containers and fails. * Removing whitespace in the blank lines * Adding a changelog fragment --- .../67832-run_powershell_modules_on_windows_containers.yml | 2 ++ lib/ansible/plugins/connection/docker.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/67832-run_powershell_modules_on_windows_containers.yml diff --git a/changelogs/fragments/67832-run_powershell_modules_on_windows_containers.yml b/changelogs/fragments/67832-run_powershell_modules_on_windows_containers.yml new file mode 100644 index 00000000000..faddb90a09e --- /dev/null +++ b/changelogs/fragments/67832-run_powershell_modules_on_windows_containers.yml @@ -0,0 +1,2 @@ +minor_changes: + - docker connection plugin - run Powershell modules on Windows containers. diff --git a/lib/ansible/plugins/connection/docker.py b/lib/ansible/plugins/connection/docker.py index 118434ad41a..380a84d877d 100644 --- a/lib/ansible/plugins/connection/docker.py +++ b/lib/ansible/plugins/connection/docker.py @@ -76,6 +76,10 @@ class Connection(ConnectionBase): # configured to be connected to by root and they are not running as # root. + # Windows uses Powershell modules + if getattr(self._shell, "_IS_WINDOWS", False): + self.module_implementation_preferences = ('.ps1', '.exe', '') + if 'docker_command' in kwargs: self.docker_cmd = kwargs['docker_command'] else: