mirror of
				https://github.com/ansible-collections/community.general.git
				synced 2025-10-26 05:50:36 -07:00 
			
		
		
		
	This version just gets the relevant paths from PluginLoader and then uses the existing imp.find_plugin() calls in the AnsiballZ code to load the proper module_utils. Modify PluginLoader to optionally omit subdirectories (module_utils needs to operate on top level dirs, not on subdirs because it has a hierarchical namespace whereas all other plugins use a flat namespace). Rename snippet* variables to module_utils* Add a small number of unittests for recursive_finder Add a larger number of integration tests to demonstrate that module_utils is working. Whitelist module-style shebang in test target library dirs Prefix module_data variable with b_ to be clear that it holds bytes data
		
			
				
	
	
		
			14 lines
		
	
	
	
		
			445 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
	
		
			445 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| #!/usr/bin/python
 | |
| 
 | |
| results = {}
 | |
| # Test that we are rooted correctly
 | |
| # Following files:
 | |
| #   module_utils/yak/zebra/foo.py
 | |
| try:
 | |
|     from ansible.module_utils.zebra import foo
 | |
|     results['zebra'] = foo.data
 | |
| except ImportError:
 | |
|     results['zebra'] = 'Failed in module as expected but incorrectly did not fail in AnsiballZ construction'
 | |
| 
 | |
| from ansible.module_utils.basic import AnsibleModule
 | |
| AnsibleModule(argument_spec=dict()).exit_json(**results)
 |