Add networking mode parameter (net) to docker

Since 0.11 Docker supports different networking modes (see docker run
--net). This commit add support for that to the ansible docker module.

This depends on
2d58351164
pull/7408/head
Johannes 'fish' Ziemke 11 years ago
parent 3b8a35d65e
commit 352daa0138

@ -183,6 +183,13 @@ options:
default: false default: false
aliases: [] aliases: []
version_added: "1.6" version_added: "1.6"
net:
description:
- Set Network mode for the container (bridge, none, container:<name|id>, host)
required: false
default: false
aliases: []
version_added: "1.11"
author: Cove Schneider, Joshua Conner, Pavel Antonov author: Cove Schneider, Joshua Conner, Pavel Antonov
requirements: [ "docker-py >= 0.3.0", "docker >= 0.10.0" ] requirements: [ "docker-py >= 0.3.0", "docker >= 0.10.0" ]
''' '''
@ -575,6 +582,7 @@ class DockerManager:
'publish_all_ports': self.module.params.get('publish_all_ports'), 'publish_all_ports': self.module.params.get('publish_all_ports'),
'privileged': self.module.params.get('privileged'), 'privileged': self.module.params.get('privileged'),
'links': self.links, 'links': self.links,
'network_mode': self.module.params.get('net'),
} }
if docker.utils.compare_version('1.10', self.client.version()['ApiVersion']) >= 0 and hasattr(docker, '__version__') and docker.__version__ > '0.3.0': if docker.utils.compare_version('1.10', self.client.version()['ApiVersion']) >= 0 and hasattr(docker, '__version__') and docker.__version__ > '0.3.0':
params['dns'] = self.module.params.get('dns') params['dns'] = self.module.params.get('dns')
@ -660,7 +668,8 @@ def main():
stdin_open = dict(default=False, type='bool'), stdin_open = dict(default=False, type='bool'),
tty = dict(default=False, type='bool'), tty = dict(default=False, type='bool'),
lxc_conf = dict(default=None, type='list'), lxc_conf = dict(default=None, type='list'),
name = dict(default=None) name = dict(default=None),
net = dict(default=None)
) )
) )

Loading…
Cancel
Save