Changeset - 796d87f58565
[Not reviewed]
0 1 0
Branko Majic (branko) - 12 days ago 2024-09-07 14:48:33
branko@majic.rs
MAR-218: Fix the custom m_ldap_permissions module to work correctly with ansible-lint:

- In order for things to behave correctly, module should not invoke
the main part of code automatically during import, but only if run
via CLI.
- Without this the ansible-lint kept erroring out with:

"missing required arguments: filter, rules"
1 file changed with 10 insertions and 3 deletions:
0 comments (0 inline, 0 general)
roles/ldap_server/library/m_ldap_permissions.py
Show inline comments
 
#!/usr/bin/python3
 

	
 
from __future__ import (absolute_import, division, print_function)
 
from ansible.module_utils.basic import AnsibleModule
 

	
 
__metaclass__ = type
 

	
 
# Try to load the Python LDAP module.
 
try:
 
    import ldap
 
@@ -256,7 +259,7 @@ class LDAPPermissions(object):
 
            return True
 

	
 

	
 
def main():
 
def run_module():
 
    """
 
    Runs the module.
 
    """
 
@@ -298,5 +301,9 @@ def main():
 
    module.exit_json(changed=changed)
 

	
 

	
 
# Import module snippets.
 
main()
 
def main():
 
    run_module()
 

	
 

	
 
if __name__ == '__main__':
 
    main()
0 comments (0 inline, 0 general)