summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-06-24 06:51:00 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-06-24 06:51:00 -0700
commit4519dd5f4d8fb1787bd81c56403b5fab02075dae (patch)
treeaed9e374231d638d2b51f5319af7836565eefd2a
parentc5324f54e61913a1573b1930fd599921c02319bc (diff)
downloadansible-modules-core-4519dd5f4d8fb1787bd81c56403b5fab02075dae.tar.gz
Small cleanups.
* Import url(lib|parse|lib2) if needed by the module rather than relying on module_utils.urls to do so. * Remove stdlib modules from requirements * Use the if __name__ conditional for invoking main()
-rw-r--r--network/basics/get_url.py7
-rw-r--r--packaging/os/rpm_key.py6
2 files changed, 9 insertions, 4 deletions
diff --git a/network/basics/get_url.py b/network/basics/get_url.py
index 074bf8bb..f7ea5008 100644
--- a/network/basics/get_url.py
+++ b/network/basics/get_url.py
@@ -113,7 +113,7 @@ options:
- all arguments accepted by the M(file) module also work here
required: false
# informational: requirements for nodes
-requirements: [ urllib2, urlparse ]
+requirements: [ ]
author: "Jan-Piet Mens (@jpmens)"
'''
@@ -125,6 +125,8 @@ EXAMPLES='''
get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf sha256sum=b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c
'''
+import urlparse
+
try:
import hashlib
HAS_HASHLIB=True
@@ -315,4 +317,5 @@ def main():
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls import *
-main()
+if __name__ == '__main__':
+ main()
diff --git a/packaging/os/rpm_key.py b/packaging/os/rpm_key.py
index 1b38da38..d2d5e684 100644
--- a/packaging/os/rpm_key.py
+++ b/packaging/os/rpm_key.py
@@ -60,9 +60,10 @@ EXAMPLES = '''
# Example action to ensure a key is not present in the db
- rpm_key: state=absent key=DEADB33F
'''
+import re
import syslog
import os.path
-import re
+import urllib2
import tempfile
def is_pubkey(string):
@@ -203,4 +204,5 @@ def main():
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.urls import *
-main()
+if __name__ == '__main__':
+ main()