mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-01 20:50:23 -07:00
docker_swarm: Return UnlockKey (#54490)
* Return UnlockKey * Add changelog fragment * Add method to check if a parameter exists in diffs * Add method to get swarm unlock key * Add option unlock_key * Only return unlock key when created or changed * Rename difference check * Extend unlock key example * Assert that unlock_key is a string * Fix docker_swarm_info authors * Don’t silence APIErrors * Test unlock_key on unlocked swarm * Catch APIError when retrieving unlock key * Better return value description * Lint * Fix UnlockKey return value documentation Co-Authored-By: hannseman <hannes@5monkeys.se> * Get unlock key safely Co-Authored-By: hannseman <hannes@5monkeys.se> * Return None on empty UnlockKey * Assert swarm_unlock_key is undefined if unqueried * Add documentation about swarm_info unlock_key * Add change log fragment for unlock_key option * Revert "Add change log fragment for unlock_key option" This reverts commit e3cb2325b552e5d14cc3f42b33a86bf3ee84d3b9. * Use generator expression instead * Restart docker more decisively * Use systemctl kill Co-Authored-By: hannseman <hannes@5monkeys.se> * Try to restart docker daemon
This commit is contained in:
parent
21c8650180
commit
e58f23b73e
8 changed files with 146 additions and 4 deletions
|
@ -846,6 +846,12 @@ class DifferenceTracker(object):
|
|||
after[item['name']] = item['parameter']
|
||||
return before, after
|
||||
|
||||
def has_difference_for(self, name):
|
||||
'''
|
||||
Returns a boolean if a difference exists for name
|
||||
'''
|
||||
return any(diff for diff in self._diff if diff['name'] == name)
|
||||
|
||||
def get_legacy_docker_container_diffs(self):
|
||||
'''
|
||||
Return differences in the docker_container legacy format.
|
||||
|
|
|
@ -13,7 +13,10 @@ except ImportError:
|
|||
pass
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.docker.common import AnsibleDockerClient
|
||||
from ansible.module_utils.docker.common import (
|
||||
AnsibleDockerClient,
|
||||
LooseVersion,
|
||||
)
|
||||
|
||||
|
||||
class AnsibleDockerSwarmClient(AnsibleDockerClient):
|
||||
|
@ -241,3 +244,8 @@ class AnsibleDockerSwarmClient(AnsibleDockerClient):
|
|||
|
||||
def get_node_name_by_id(self, nodeid):
|
||||
return self.get_node_inspect(nodeid)['Description']['Hostname']
|
||||
|
||||
def get_unlock_key(self):
|
||||
if self.docker_py_version < LooseVersion('2.7.0'):
|
||||
return None
|
||||
return super(AnsibleDockerSwarmClient, self).get_unlock_key()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue