ansible/ansible — pull request #9017 by abhishekkr (2014-09-16 06:48:24+00:00)
Title: defining Top-level env for main(), modules easily extensible via import

The way core modules are written, they are not extensible (import and build upon).
Suppose if I want to import ansible file module for reusing existing pieces of "library/files/lineinfile" level functions, currently... the module is like

```
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.splitter import *

main()
```

which will call main() even if it is imported.

This Pull Request modifies, all such module definitions (all python, except one in Powershell for Windows), to be like

```
if __name__ == "__main__":

# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.splitter import *

main()
```

which will make sure, "main()" only runs when it get called as a script and not when it gets imported to be extended.