[2.7] docker_swarm: removing nodes requires docker >= 2.4.0 (#53592)
* Removing a swarm node does not work with docker-py < 2.4.0, since it calls client.inspect_node(). (#53565)
For the same reason, docker_node requires docker >= 2.4.0.
(cherry picked from commit c75da35595
)
* Reconstructing a change from devel which is required to make usage detection work this way.
This commit is contained in:
parent
b84d9a8365
commit
2773e215f7
4 changed files with 13 additions and 3 deletions
|
@ -1,2 +1,2 @@
|
|||
bugfixes:
|
||||
- "docker_swarm - now supports docker-py 1.10.0 and newer, instead only docker 2.6.0 and newer."
|
||||
- "docker_swarm - now supports docker-py 1.10.0 and newer for most operations, instead only docker 2.6.0 and newer."
|
||||
|
|
|
@ -442,7 +442,7 @@ class AnsibleDockerClient(Client):
|
|||
if not data['supported']:
|
||||
# Test whether option is specified
|
||||
if 'detect_usage' in data:
|
||||
used = data['detect_usage']()
|
||||
used = data['detect_usage'](self)
|
||||
else:
|
||||
used = self.module.params.get(option) is not None
|
||||
if used and 'default' in self.module.argument_spec[option]:
|
||||
|
|
|
@ -2234,7 +2234,7 @@ class AnsibleDockerClientContainer(AnsibleDockerClient):
|
|||
self.comparisons = comparisons
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
def detect_ipvX_address_usage():
|
||||
def detect_ipvX_address_usage(client):
|
||||
'''
|
||||
Helper function to detect whether any specified network uses ipv4_address or ipv6_address
|
||||
'''
|
||||
|
|
|
@ -52,6 +52,7 @@ options:
|
|||
- Set to C(join), to join an existing cluster.
|
||||
- Set to C(absent), to leave an existing cluster.
|
||||
- Set to C(remove), to remove an absent node from the cluster.
|
||||
Note that removing requires docker-py >= 2.4.0.
|
||||
- Set to C(inspect) to display swarm informations.
|
||||
type: str
|
||||
required: yes
|
||||
|
@ -553,6 +554,10 @@ class SwarmManager(DockerBaseClass):
|
|||
self.results['changed'] = True
|
||||
|
||||
|
||||
def _detect_remove_operation(client):
|
||||
return client.module.params['state'] == 'remove'
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = dict(
|
||||
advertise_addr=dict(type='str'),
|
||||
|
@ -592,6 +597,11 @@ def main():
|
|||
ca_force_rotate=dict(docker_py_version='2.6.0', docker_api_version='1.30'),
|
||||
autolock_managers=dict(docker_py_version='2.6.0'),
|
||||
log_driver=dict(docker_py_version='2.6.0'),
|
||||
remove_operation=dict(
|
||||
docker_py_version='2.4.0',
|
||||
detect_usage=_detect_remove_operation,
|
||||
usage_msg='remove swarm nodes'
|
||||
),
|
||||
)
|
||||
|
||||
client = AnsibleDockerClient(
|
||||
|
|
Loading…
Reference in a new issue