|
|
@ -94,17 +94,23 @@ EXAMPLES = '''
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import os.path
|
|
|
|
import tempfile
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_package_installed(module, name, easy_install, executable_arguments):
|
|
|
|
def install_package(module, name, easy_install, executable_arguments):
|
|
|
|
executable_arguments = executable_arguments + ['--dry-run']
|
|
|
|
|
|
|
|
cmd = '%s %s %s' % (easy_install, ' '.join(executable_arguments), name)
|
|
|
|
cmd = '%s %s %s' % (easy_install, ' '.join(executable_arguments), name)
|
|
|
|
rc, status_stdout, status_stderr = module.run_command(cmd)
|
|
|
|
rc, out, err = module.run_command(cmd)
|
|
|
|
|
|
|
|
return rc, out, err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _is_package_installed(module, name, easy_install, executable_arguments):
|
|
|
|
|
|
|
|
# Copy and add to the arguments
|
|
|
|
|
|
|
|
executable_arguments = executable_arguments[:]
|
|
|
|
|
|
|
|
executable_arguments.append('--dry-run')
|
|
|
|
|
|
|
|
rc, out, err = install_package(module, name, easy_install, executable_arguments)
|
|
|
|
if rc:
|
|
|
|
if rc:
|
|
|
|
module.fail_json(msg=status_stderr)
|
|
|
|
module.fail_json(msg=err)
|
|
|
|
return not ('Reading' in status_stdout or 'Downloading' in status_stdout)
|
|
|
|
return 'Downloading' not in out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_easy_install(module, env=None, executable=None):
|
|
|
|
def _get_easy_install(module, env=None, executable=None):
|
|
|
@ -186,8 +192,7 @@ def main():
|
|
|
|
if not installed:
|
|
|
|
if not installed:
|
|
|
|
if module.check_mode:
|
|
|
|
if module.check_mode:
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
cmd = '%s %s %s' % (easy_install, ' '.join(executable_arguments), name)
|
|
|
|
rc_easy_inst, out_easy_inst, err_easy_inst = install_package(module, name, easy_install, executable_arguments)
|
|
|
|
rc_easy_inst, out_easy_inst, err_easy_inst = module.run_command(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rc += rc_easy_inst
|
|
|
|
rc += rc_easy_inst
|
|
|
|
out += out_easy_inst
|
|
|
|
out += out_easy_inst
|
|
|
|