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.20', ) try: container = client.get_container(client.module.params['name']) client.module.exit_json( changed=False, exists=(True if container else False), container=container, ) 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())
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.20', ) container = client.get_container(client.module.params['name']) client.module.exit_json( changed=False, exists=(True if container else False), container=container, )