From 369fe78c609dd8ac7f0c6b1fa6ae32f70bf6a684 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 24 Sep 2015 12:15:59 +0700 Subject: [PATCH] Add stop_timeout option to docker module --- lib/ansible/modules/cloud/docker/docker.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/docker/docker.py b/lib/ansible/modules/cloud/docker/docker.py index fcc61a11053..a6eb65e3d9a 100644 --- a/lib/ansible/modules/cloud/docker/docker.py +++ b/lib/ansible/modules/cloud/docker/docker.py @@ -345,6 +345,12 @@ options: required: false default: null version_added: "1.9.4" + stop_timeout: + description: + - How many seconds to wait for the container to stop before killing it. + required: false + default: 10 + version_added: "2.0" author: - "Cove Schneider (@cove)" - "Joshua Conner (@joshuaconner)" @@ -630,6 +636,7 @@ class DockerManager(object): 'cap_drop': ((0, 5, 0), '1.14'), 'read_only': ((1, 0, 0), '1.17'), 'labels': ((1, 2, 0), '1.18'), + 'stop_timeout': ((0, 5, 0), '1.0'), # Clientside only 'insecure_registry': ((0, 5, 0), '0.0') } @@ -1559,7 +1566,7 @@ class DockerManager(object): def stop_containers(self, containers): for i in containers: - self.client.stop(i['Id']) + self.client.stop(i['Id'], self.module.params.get('stop_timeout')) self.increment_counter('stopped') return [self.client.wait(i['Id']) for i in containers] @@ -1762,6 +1769,7 @@ def main(): cap_drop = dict(default=None, type='list'), read_only = dict(default=None, type='bool'), labels = dict(default={}, type='dict'), + stop_timeout = dict(default=10, type='int'), ), required_together = ( ['tls_client_cert', 'tls_client_key'],