Fix module loading for Windows jobs

The recent security fix that caused loading ansible.bultin.command
to load the normal command module was a little too aggressive since
the same mechanism is used by Ansible to load Windows powershell
support code, which is under the Ansible.ModuleUtils.* hierarchy.

This would result in an error from Ansible when attempting to run
the setup playbook:

  Could not find imported module support code for 'Ansible.ModuleUtils.Legacy'"'

This is corrected by reducing the scope of the mutation to just
ansible.builtin and ansible.legacy.

Change-Id: I70e9481478a3326692cb848ce0782f5331dc4758
This commit is contained in:
James E. Blair 2022-03-30 13:26:56 -07:00
parent b2c9334efc
commit 08348143f5
2 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,7 @@
---
fixes:
- |
An issue introduced in Zuul version 5.2.0 which could cause jobs
running on Windows nodes to fail with the error `Could not find
imported module support code for 'Ansible.ModuleUtils.Legacy'"`
has been corrected.

View File

@ -220,13 +220,17 @@ orig_find_plugin = PluginLoader.find_plugin
def mp_get(self, name, *args, **kwargs):
name = name.rsplit('.', 1)[-1]
if (name.startswith('ansible.builtin.') or
name.startswith('ansible.legacy.')):
name = name.rsplit('.', 1)[-1]
ret = orig_get(self, name, *args, **kwargs)
return ret
def mp_find_plugin(self, name, *args, **kwargs):
name = name.rsplit('.', 1)[-1]
if (name.startswith('ansible.builtin.') or
name.startswith('ansible.legacy.')):
name = name.rsplit('.', 1)[-1]
ret = orig_find_plugin(self, name, *args, **kwargs)
return ret