Esempio n. 1
0
def main():
    with PulpEntityAnsibleModule(argument_spec=dict(
            name=dict(),
            url=dict(),
            download_concurrency=dict(type='int'),
            policy=dict(choices=['immediate', 'on-demand', 'streamed'], ),
            proxy_url=dict(type='str'),
            tls_validation=dict(type='bool'),
            includes=dict(
                type='list',
                elements='dict',
                options=dict(
                    name=dict(required=True),
                    version_specifier=dict(default=''),
                ),
            ),
            excludes=dict(
                type='list',
                elements='dict',
                options=dict(
                    name=dict(required=True),
                    version_specifier=dict(default=''),
                ),
            ),
            prereleases=dict(type='bool'),
    ),
                                 required_if=[
                                     ('state', 'present', ['name']),
                                     ('state', 'absent', ['name']),
                                 ]) as module:

        natural_key = {'name': module.params['name']}
        desired_attributes = {
            key: module.params[key]
            for key in DESIRED_KEYS if module.params[key] is not None
        }

        includes = module.params['includes']
        if includes is not None:
            desired_attributes['includes'] = [
                ProjectSpecifier(**include) for include in includes
            ]

        excludes = module.params['excludes']
        if excludes is not None:
            desired_attributes['excludes'] = [
                ProjectSpecifier(**exclude) for exclude in excludes
            ]

        PulpPythonRemote(module, natural_key, desired_attributes).process()