def main():
    arg_spec = dict(name=dict(default=None, required=False, aliases=['pkg']), from_path=dict(default=None, required=False, type='path'), notest=dict(default=False, type='bool'), locallib=dict(default=None, required=False, type='path'), mirror=dict(default=None, required=False), mirror_only=dict(default=False, type='bool'), installdeps=dict(default=False, type='bool'), system_lib=dict(default=False, type='bool', aliases=['use_sudo']), version=dict(default=None, required=False), executable=dict(required=False, type='path'))
    module = AnsibleModule(argument_spec=arg_spec, required_one_of=[['name', 'from_path']])
    cpanm = _get_cpanm_path(module)
    name = module.params['name']
    from_path = module.params['from_path']
    notest = module.boolean(module.params.get('notest', False))
    locallib = module.params['locallib']
    mirror = module.params['mirror']
    mirror_only = module.params['mirror_only']
    installdeps = module.params['installdeps']
    use_sudo = module.params['system_lib']
    version = module.params['version']
    changed = False
    installed = _is_package_installed(module, name, locallib, cpanm, version)
    if (not installed):
        cmd = _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, installdeps, cpanm, use_sudo)
        (rc_cpanm, out_cpanm, err_cpanm) = module.run_command(cmd, check_rc=False)
        if (rc_cpanm != 0):
            module.fail_json(msg=err_cpanm, cmd=cmd)
        if ((err_cpanm.find('is up to date') == (- 1)) and (out_cpanm.find('is up to date') == (- 1))):
            changed = True
    module.exit_json(changed=changed, binary=cpanm, name=name)
def main():
    arg_spec = dict(name=dict(default=None, required=False, aliases=['pkg']), from_path=dict(default=None, required=False, type='path'), notest=dict(default=False, type='bool'), locallib=dict(default=None, required=False, type='path'), mirror=dict(default=None, required=False), mirror_only=dict(default=False, type='bool'), installdeps=dict(default=False, type='bool'), system_lib=dict(default=False, type='bool', aliases=['use_sudo']), version=dict(default=None, required=False), executable=dict(required=False, type='path'))
    module = AnsibleModule(argument_spec=arg_spec, required_one_of=[['name', 'from_path']])
    cpanm = _get_cpanm_path(module)
    name = module.params['name']
    from_path = module.params['from_path']
    notest = module.boolean(module.params.get('notest', False))
    locallib = module.params['locallib']
    mirror = module.params['mirror']
    mirror_only = module.params['mirror_only']
    installdeps = module.params['installdeps']
    use_sudo = module.params['system_lib']
    version = module.params['version']
    changed = False
    installed = _is_package_installed(module, name, locallib, cpanm, version)
    if (not installed):
        cmd = _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, installdeps, cpanm, use_sudo)
        (rc_cpanm, out_cpanm, err_cpanm) = module.run_command(cmd, check_rc=False)
        if (rc_cpanm != 0):
            module.fail_json(msg=err_cpanm, cmd=cmd)
        if ((err_cpanm.find('is up to date') == (- 1)) and (out_cpanm.find('is up to date') == (- 1))):
            changed = True
    module.exit_json(changed=changed, binary=cpanm, name=name)