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.
This commit is contained in:
Felix Fontein 2019-03-09 21:28:04 +01:00 committed by Sloane Hertel
parent be7b8dc047
commit c75da35595
2 changed files with 11 additions and 1 deletions

View file

@ -1,2 +1,2 @@
bugfixes: 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."

View file

@ -52,6 +52,7 @@ options:
- Set to C(join), to join an existing cluster. - Set to C(join), to join an existing cluster.
- Set to C(absent), to leave an existing cluster. - Set to C(absent), to leave an existing cluster.
- Set to C(remove), to remove an absent node from the 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. - Set to C(inspect) to display swarm informations.
type: str type: str
required: yes required: yes
@ -530,6 +531,10 @@ class SwarmManager(DockerBaseClass):
self.results['changed'] = True self.results['changed'] = True
def _detect_remove_operation(client):
return client.module.params['state'] == 'remove'
def main(): def main():
argument_spec = dict( argument_spec = dict(
advertise_addr=dict(type='str'), advertise_addr=dict(type='str'),
@ -569,6 +574,11 @@ def main():
ca_force_rotate=dict(docker_py_version='2.6.0', docker_api_version='1.30'), ca_force_rotate=dict(docker_py_version='2.6.0', docker_api_version='1.30'),
autolock_managers=dict(docker_py_version='2.6.0'), autolock_managers=dict(docker_py_version='2.6.0'),
log_driver=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 = AnsibleDockerSwarmClient( client = AnsibleDockerSwarmClient(