Example #1
0
def main():
    argument_spec = dict(name=dict(type='str', required=True), )

    client = AnsibleDockerClient(
        argument_spec=argument_spec,
        supports_check_mode=True,
        min_docker_api_version='1.21',
    )

    try:
        network = client.get_network(client.module.params['name'])

        client.module.exit_json(
            changed=False,
            exists=(True if network else False),
            network=network,
        )
    except DockerException as e:
        client.fail('An unexpected docker error occurred: {0}'.format(e),
                    exception=traceback.format_exc())
    except RequestException as e:
        client.fail(
            'An unexpected requests error occurred when docker-py tried to talk to the docker daemon: {0}'
            .format(e),
            exception=traceback.format_exc())
Example #2
0
def main():
    argument_spec = dict(name=dict(type='str', required=True), )

    client = AnsibleDockerClient(
        argument_spec=argument_spec,
        supports_check_mode=True,
        min_docker_api_version='1.21',
    )

    network = client.get_network(client.module.params['name'])

    client.module.exit_json(
        changed=False,
        exists=(True if network else False),
        docker_network=network,
    )