Merge pull request #1102 from heiparta/extra_hosts

Add support for extra_hosts to docker module
reviewable/pr18780/r1
Brian Coca 10 years ago
commit 09aa79c58f

@ -246,6 +246,9 @@ options:
retries. retries.
default: 0 default: 0
version_added: "1.9" version_added: "1.9"
extra_hosts:
description:
- Dict of custom host-to-IP mappings to be defined in the container
insecure_registry: insecure_registry:
description: description:
- Use insecure private registry by HTTP instead of HTTPS. Needed for - Use insecure private registry by HTTP instead of HTTPS. Needed for
@ -492,6 +495,7 @@ class DockerManager(object):
'dns': ((0, 3, 0), '1.10'), 'dns': ((0, 3, 0), '1.10'),
'volumes_from': ((0, 3, 0), '1.10'), 'volumes_from': ((0, 3, 0), '1.10'),
'restart_policy': ((0, 5, 0), '1.14'), 'restart_policy': ((0, 5, 0), '1.14'),
'extra_hosts': ((0, 7, 0), '1.3.1'),
'pid': ((1, 0, 0), '1.17'), 'pid': ((1, 0, 0), '1.17'),
# Clientside only # Clientside only
'insecure_registry': ((0, 5, 0), '0.0') 'insecure_registry': ((0, 5, 0), '0.0')
@ -1233,7 +1237,7 @@ class DockerManager(object):
optionals = {} optionals = {}
for optional_param in ('dns', 'volumes_from', 'restart_policy', for optional_param in ('dns', 'volumes_from', 'restart_policy',
'restart_policy_retry', 'pid'): 'restart_policy_retry', 'pid', 'extra_hosts'):
optionals[optional_param] = self.module.params.get(optional_param) optionals[optional_param] = self.module.params.get(optional_param)
if optionals['dns'] is not None: if optionals['dns'] is not None:
@ -1254,6 +1258,10 @@ class DockerManager(object):
self.ensure_capability('pid') self.ensure_capability('pid')
params['pid_mode'] = optionals['pid'] params['pid_mode'] = optionals['pid']
if optionals['extra_hosts'] is not None:
self.ensure_capability('extra_hosts')
params['extra_hosts'] = optionals['extra_hosts']
for i in containers: for i in containers:
self.client.start(i['Id'], **params) self.client.start(i['Id'], **params)
self.increment_counter('started') self.increment_counter('started')
@ -1438,6 +1446,7 @@ def main():
state = dict(default='started', choices=['present', 'started', 'reloaded', 'restarted', 'stopped', 'killed', 'absent', 'running']), state = dict(default='started', choices=['present', 'started', 'reloaded', 'restarted', 'stopped', 'killed', 'absent', 'running']),
restart_policy = dict(default=None, choices=['always', 'on-failure', 'no']), restart_policy = dict(default=None, choices=['always', 'on-failure', 'no']),
restart_policy_retry = dict(default=0, type='int'), restart_policy_retry = dict(default=0, type='int'),
extra_hosts = dict(type='dict'),
debug = dict(default=False, type='bool'), debug = dict(default=False, type='bool'),
privileged = dict(default=False, type='bool'), privileged = dict(default=False, type='bool'),
stdin_open = dict(default=False, type='bool'), stdin_open = dict(default=False, type='bool'),

Loading…
Cancel
Save