mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add --sysctl support for cloud/docker_container
This commit is contained in:
parent
e90f1d6449
commit
b3a37da671
1 changed files with 28 additions and 0 deletions
|
@ -436,6 +436,12 @@ options:
|
|||
- "List of ulimit options. A ulimit is specified as C(nofile:262144:262144)"
|
||||
default: null
|
||||
required: false
|
||||
sysctls:
|
||||
description:
|
||||
- Dictionary of key,value pairs.
|
||||
default: null
|
||||
required: false
|
||||
version_added: 2.4
|
||||
user:
|
||||
description:
|
||||
- Sets the username or UID used and optionally the groupname or GID for the specified command.
|
||||
|
@ -484,6 +490,7 @@ author:
|
|||
- "Daan Oosterveld (@dusdanig)"
|
||||
- "James Tanner (@jctanner)"
|
||||
- "Chris Houseknecht (@chouseknecht)"
|
||||
- "Kassian Sun (@kassiansun)"
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
|
@ -798,6 +805,7 @@ class TaskParameters(DockerBaseClass):
|
|||
|
||||
self.env = self._get_environment()
|
||||
self.ulimits = self._parse_ulimits()
|
||||
self.sysctls = self._parse_sysctls()
|
||||
self.log_config = self._parse_log_config()
|
||||
self.exp_links = None
|
||||
self.volume_binds = self._get_volume_binds(self.volumes)
|
||||
|
@ -949,6 +957,7 @@ class TaskParameters(DockerBaseClass):
|
|||
ipc_mode='ipc_mode',
|
||||
security_opt='security_opts',
|
||||
ulimits='ulimits',
|
||||
sysctls='sysctls',
|
||||
log_config='log_config',
|
||||
mem_limit='memory',
|
||||
memswap_limit='memory_swap',
|
||||
|
@ -1126,6 +1135,12 @@ class TaskParameters(DockerBaseClass):
|
|||
self.fail("Error parsing ulimits value %s - %s" % (limit, exc))
|
||||
return results
|
||||
|
||||
def _parse_sysctls(self):
|
||||
'''
|
||||
Turn sysctls into an hash of Sysctl objects
|
||||
'''
|
||||
return self.sysctls
|
||||
|
||||
def _parse_log_config(self):
|
||||
'''
|
||||
Create a LogConfig object
|
||||
|
@ -1191,6 +1206,7 @@ class Container(DockerBaseClass):
|
|||
self.parameters.expected_exposed = None
|
||||
self.parameters.expected_volumes = None
|
||||
self.parameters.expected_ulimits = None
|
||||
self.parameters.expected_sysctls = None
|
||||
self.parameters.expected_etc_hosts = None
|
||||
self.parameters.expected_env = None
|
||||
|
||||
|
@ -1220,6 +1236,7 @@ class Container(DockerBaseClass):
|
|||
self.parameters.expected_volumes = self._get_expected_volumes(image)
|
||||
self.parameters.expected_binds = self._get_expected_binds(image)
|
||||
self.parameters.expected_ulimits = self._get_expected_ulimits(self.parameters.ulimits)
|
||||
self.parameters.expected_sysctls = self._get_expected_sysctls(self.parameters.sysctls)
|
||||
self.parameters.expected_etc_hosts = self._convert_simple_dict_to_list('etc_hosts')
|
||||
self.parameters.expected_env = self._get_expected_env(image)
|
||||
self.parameters.expected_cmd = self._get_expected_cmd()
|
||||
|
@ -1289,6 +1306,7 @@ class Container(DockerBaseClass):
|
|||
stop_signal=config.get("StopSignal"),
|
||||
tty=config.get('Tty'),
|
||||
expected_ulimits=host_config.get('Ulimits'),
|
||||
expected_sysctls=host_config.get('Sysctls'),
|
||||
uts=host_config.get('UTSMode'),
|
||||
expected_volumes=config.get('Volumes'),
|
||||
expected_binds=host_config.get('Binds'),
|
||||
|
@ -1676,6 +1694,15 @@ class Container(DockerBaseClass):
|
|||
))
|
||||
return results
|
||||
|
||||
def _get_expected_sysctls(self, config_sysctls):
|
||||
self.log('_get_expected_sysctls')
|
||||
if config_sysctls is None:
|
||||
return None
|
||||
result = dict()
|
||||
for key, value in config_sysctls.items():
|
||||
result[key] = str(value)
|
||||
return result
|
||||
|
||||
def _get_expected_cmd(self):
|
||||
self.log('_get_expected_cmd')
|
||||
if not self.parameters.command:
|
||||
|
@ -2046,6 +2073,7 @@ def main():
|
|||
trust_image_content=dict(type='bool', default=False),
|
||||
tty=dict(type='bool', default=False),
|
||||
ulimits=dict(type='list'),
|
||||
sysctls=dict(type='dict'),
|
||||
user=dict(type='str'),
|
||||
uts=dict(type='str'),
|
||||
volumes=dict(type='list'),
|
||||
|
|
Loading…
Reference in a new issue