Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding module_utils to allow for common utilites that can be shared a…
…mong ansible modules. (#2623) What is the motivation for this PR? Sometimes, there are utilities that are required for across multiple ansible modules in ansible/library. For example: * creating of a timestamped debug file, and printing message to it. * minigraph_facts has logic to get port_name_to_alias_map that is based on 'hwksu'. If we want to use the same logic in some other ansible module, then we would have to replicate the same code in both the modules. How did you do it? Usage of ansible module_utils is defined at https://docs.ansible.com/ansible/latest/dev_guide/developing_module_utilities.html To have custom module_utils, we need to: * Add module_utils directory under ansible. * Add module_utils in ansible.cfg to point to this module_utils directory. So, we did the following: * Added module_utils directory under ansible * Added module_utils in ansible.cfg to use this directory for ansible modules. Added debug_utils as an example with the following methods/utilities: * create_debug_file - create a timestamped debug file * print_debug_msg - print a message to the debug file. Added debug commands above to conn_graph_facts as an example. How did you verify/test it? Made sure that conn_graph_facts works and the debug file is created.
- Loading branch information