From cbe3f4e5e137963b189180a3a7a849513813eea9 Mon Sep 17 00:00:00 2001 From: Fabio Alessandro Locati Date: Mon, 5 Dec 2016 16:24:19 +0000 Subject: [PATCH] Make `main()` calls conditional - system (#3652) --- lib/ansible/modules/extras/system/at.py | 4 +++- lib/ansible/modules/extras/system/capabilities.py | 4 +++- lib/ansible/modules/extras/system/cronvar.py | 3 ++- lib/ansible/modules/extras/system/crypttab.py | 3 ++- lib/ansible/modules/extras/system/debconf.py | 3 ++- lib/ansible/modules/extras/system/facter.py | 4 ++-- lib/ansible/modules/extras/system/getent.py | 4 ++-- lib/ansible/modules/extras/system/gluster_volume.py | 3 ++- lib/ansible/modules/extras/system/kernel_blacklist.py | 4 +++- lib/ansible/modules/extras/system/known_hosts.py | 3 ++- lib/ansible/modules/extras/system/locale_gen.py | 3 ++- lib/ansible/modules/extras/system/lvg.py | 4 +++- lib/ansible/modules/extras/system/modprobe.py | 3 ++- lib/ansible/modules/extras/system/ohai.py | 3 ++- lib/ansible/modules/extras/system/open_iscsi.py | 4 ++-- lib/ansible/modules/extras/system/osx_defaults.py | 3 ++- lib/ansible/modules/extras/system/pam_limits.py | 4 +++- lib/ansible/modules/extras/system/puppet.py | 3 ++- lib/ansible/modules/extras/system/selinux_permissive.py | 4 ++-- lib/ansible/modules/extras/system/seport.py | 3 ++- lib/ansible/modules/extras/system/solaris_zone.py | 4 +++- lib/ansible/modules/extras/system/svc.py | 3 ++- lib/ansible/modules/extras/system/ufw.py | 3 ++- lib/ansible/modules/extras/system/zfs.py | 4 +++- 24 files changed, 55 insertions(+), 28 deletions(-) diff --git a/lib/ansible/modules/extras/system/at.py b/lib/ansible/modules/extras/system/at.py index 52006e54710..9c5f10b5947 100644 --- a/lib/ansible/modules/extras/system/at.py +++ b/lib/ansible/modules/extras/system/at.py @@ -206,4 +206,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/capabilities.py b/lib/ansible/modules/extras/system/capabilities.py index 009507669fb..67cd66b2b0c 100644 --- a/lib/ansible/modules/extras/system/capabilities.py +++ b/lib/ansible/modules/extras/system/capabilities.py @@ -189,4 +189,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/cronvar.py b/lib/ansible/modules/extras/system/cronvar.py index a986f159a90..d4e9b909588 100644 --- a/lib/ansible/modules/extras/system/cronvar.py +++ b/lib/ansible/modules/extras/system/cronvar.py @@ -437,4 +437,5 @@ def main(): module.exit_json(msg="Unable to execute cronvar task.") -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/crypttab.py b/lib/ansible/modules/extras/system/crypttab.py index 0565f57f9eb..27523415dfb 100644 --- a/lib/ansible/modules/extras/system/crypttab.py +++ b/lib/ansible/modules/extras/system/crypttab.py @@ -370,4 +370,5 @@ class Options(dict): ret.append('%s=%s' % (k, v)) return ','.join(ret) -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/debconf.py b/lib/ansible/modules/extras/system/debconf.py index 468f0b5725e..3c9218b408e 100644 --- a/lib/ansible/modules/extras/system/debconf.py +++ b/lib/ansible/modules/extras/system/debconf.py @@ -188,4 +188,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/facter.py b/lib/ansible/modules/extras/system/facter.py index bb8553d0a25..834428cb698 100644 --- a/lib/ansible/modules/extras/system/facter.py +++ b/lib/ansible/modules/extras/system/facter.py @@ -55,5 +55,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() - +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/getent.py b/lib/ansible/modules/extras/system/getent.py index d3cf9eed4a0..8e3103ae790 100644 --- a/lib/ansible/modules/extras/system/getent.py +++ b/lib/ansible/modules/extras/system/getent.py @@ -157,5 +157,5 @@ def main(): module.fail_json(msg=msg) -main() - +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/gluster_volume.py b/lib/ansible/modules/extras/system/gluster_volume.py index f5bca5f9e83..f34511a3eaf 100644 --- a/lib/ansible/modules/extras/system/gluster_volume.py +++ b/lib/ansible/modules/extras/system/gluster_volume.py @@ -522,4 +522,5 @@ def main(): module.exit_json(changed=changed, ansible_facts=facts) -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/kernel_blacklist.py b/lib/ansible/modules/extras/system/kernel_blacklist.py index 2100b158fda..701ba883517 100644 --- a/lib/ansible/modules/extras/system/kernel_blacklist.py +++ b/lib/ansible/modules/extras/system/kernel_blacklist.py @@ -140,4 +140,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/known_hosts.py b/lib/ansible/modules/extras/system/known_hosts.py index 40c13002ddc..656fb38d4a1 100644 --- a/lib/ansible/modules/extras/system/known_hosts.py +++ b/lib/ansible/modules/extras/system/known_hosts.py @@ -305,4 +305,5 @@ def main(): results = enforce_state(module,module.params) module.exit_json(**results) -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/locale_gen.py b/lib/ansible/modules/extras/system/locale_gen.py index db3e41a8cbd..6736a952f4b 100644 --- a/lib/ansible/modules/extras/system/locale_gen.py +++ b/lib/ansible/modules/extras/system/locale_gen.py @@ -237,4 +237,5 @@ def main(): module.exit_json(name=name, changed=changed, msg="OK") -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/lvg.py b/lib/ansible/modules/extras/system/lvg.py index d0b0409a634..427cb1b1c1d 100644 --- a/lib/ansible/modules/extras/system/lvg.py +++ b/lib/ansible/modules/extras/system/lvg.py @@ -260,4 +260,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/modprobe.py b/lib/ansible/modules/extras/system/modprobe.py index 1acd2ef3ed3..ef5a9dd4ed8 100644 --- a/lib/ansible/modules/extras/system/modprobe.py +++ b/lib/ansible/modules/extras/system/modprobe.py @@ -127,4 +127,5 @@ def main(): module.exit_json(**args) -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/ohai.py b/lib/ansible/modules/extras/system/ohai.py index 8ecf725006f..0fe76098474 100644 --- a/lib/ansible/modules/extras/system/ohai.py +++ b/lib/ansible/modules/extras/system/ohai.py @@ -51,4 +51,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/open_iscsi.py b/lib/ansible/modules/extras/system/open_iscsi.py index 77586289e77..71eeda1aa8c 100644 --- a/lib/ansible/modules/extras/system/open_iscsi.py +++ b/lib/ansible/modules/extras/system/open_iscsi.py @@ -381,5 +381,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() - +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/osx_defaults.py b/lib/ansible/modules/extras/system/osx_defaults.py index 71e4ee6289b..f199250a5ce 100644 --- a/lib/ansible/modules/extras/system/osx_defaults.py +++ b/lib/ansible/modules/extras/system/osx_defaults.py @@ -412,4 +412,5 @@ def main(): # /main ------------------------------------------------------------------- }}} -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/pam_limits.py b/lib/ansible/modules/extras/system/pam_limits.py index 55ae4d52a71..1993310af5d 100644 --- a/lib/ansible/modules/extras/system/pam_limits.py +++ b/lib/ansible/modules/extras/system/pam_limits.py @@ -263,4 +263,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/puppet.py b/lib/ansible/modules/extras/system/puppet.py index 411552d86b8..6686682cae1 100644 --- a/lib/ansible/modules/extras/system/puppet.py +++ b/lib/ansible/modules/extras/system/puppet.py @@ -284,4 +284,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/selinux_permissive.py b/lib/ansible/modules/extras/system/selinux_permissive.py index e97e168290b..5a357493a0e 100644 --- a/lib/ansible/modules/extras/system/selinux_permissive.py +++ b/lib/ansible/modules/extras/system/selinux_permissive.py @@ -131,5 +131,5 @@ def main(): permissive=permissive, domain=domain) - -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/seport.py b/lib/ansible/modules/extras/system/seport.py index 09ff7dcc0e7..0bd3a889727 100644 --- a/lib/ansible/modules/extras/system/seport.py +++ b/lib/ansible/modules/extras/system/seport.py @@ -316,4 +316,5 @@ def main(): module.exit_json(**result) -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/solaris_zone.py b/lib/ansible/modules/extras/system/solaris_zone.py index 62d1bf4338d..aa4895fa22b 100644 --- a/lib/ansible/modules/extras/system/solaris_zone.py +++ b/lib/ansible/modules/extras/system/solaris_zone.py @@ -480,4 +480,6 @@ def main(): module.exit_json(changed=zone.changed, msg=', '.join(zone.msg)) from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/svc.py b/lib/ansible/modules/extras/system/svc.py index 376062b4be5..43eea5b0f7b 100755 --- a/lib/ansible/modules/extras/system/svc.py +++ b/lib/ansible/modules/extras/system/svc.py @@ -312,4 +312,5 @@ def main(): -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/ufw.py b/lib/ansible/modules/extras/system/ufw.py index 67eaba131c7..c0f48fca667 100644 --- a/lib/ansible/modules/extras/system/ufw.py +++ b/lib/ansible/modules/extras/system/ufw.py @@ -329,4 +329,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() +if __name__ == '__main__': + main() diff --git a/lib/ansible/modules/extras/system/zfs.py b/lib/ansible/modules/extras/system/zfs.py index 47ce13edce8..7dda883b893 100644 --- a/lib/ansible/modules/extras/system/zfs.py +++ b/lib/ansible/modules/extras/system/zfs.py @@ -272,4 +272,6 @@ def main(): # import module snippets from ansible.module_utils.basic import * -main() + +if __name__ == '__main__': + main()