mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 03:52:05 +00:00
docker_swarm: adds data_path_addr option for swarm init and swarm join (#344)
* adds data_path_addr option for swarm init and swarm join. (ansible-collections/community.docker#339) * adds changelog fragment (ansible-collections/community.docker#339) * adds formatting to changelog entry Co-authored-by: Felix Fontein <felix@fontein.de> * adds version to doc entry in ansible_swarm Co-authored-by: Felix Fontein <felix@fontein.de> * rewrites doc entry to formal language Co-authored-by: Felix Fontein <felix@fontein.de> * Correct docker api version (src: docker api docs) Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
51d4c557e8
commit
98b227003e
2
changelogs/fragments/344-adds-data-path-addr.yml
Normal file
2
changelogs/fragments/344-adds-data-path-addr.yml
Normal file
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- docker_swarm - adds ``data_path_addr`` parameter during swarm initialization or when joining (https://github.com/ansible-collections/community.docker/issues/339).
|
||||
@ -175,6 +175,15 @@ options:
|
||||
description: Rotate the manager join token.
|
||||
type: bool
|
||||
default: no
|
||||
data_path_addr:
|
||||
description:
|
||||
- Address or interface to use for data path traffic.
|
||||
- This can either be an address in the form C(192.168.1.1), or an interface,
|
||||
like C(eth0).
|
||||
- Only used when swarm is initialised or joined. Because of this it is not
|
||||
considered for idempotency checking.
|
||||
type: str
|
||||
version_added: 2.5.0
|
||||
extends_documentation_fragment:
|
||||
- community.docker.docker
|
||||
- community.docker.docker.docker_py_1_documentation
|
||||
@ -218,6 +227,12 @@ EXAMPLES = '''
|
||||
community.docker.docker_swarm:
|
||||
state: remove
|
||||
node_id: mynode
|
||||
|
||||
- name: Init a new swarm with different data path interface
|
||||
community.docker.docker_swarm:
|
||||
state: present
|
||||
advertise_addr: eth0
|
||||
data_path_addr: ens10
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
@ -293,6 +308,7 @@ class TaskParameters(DockerBaseClass):
|
||||
self.listen_addr = None
|
||||
self.remote_addrs = None
|
||||
self.join_token = None
|
||||
self.data_path_addr = None
|
||||
|
||||
# Spec
|
||||
self.snapshot_interval = None
|
||||
@ -398,7 +414,7 @@ class TaskParameters(DockerBaseClass):
|
||||
for k in self.__dict__:
|
||||
if k in ('advertise_addr', 'listen_addr', 'remote_addrs', 'join_token',
|
||||
'rotate_worker_token', 'rotate_manager_token', 'spec',
|
||||
'default_addr_pool', 'subnet_size'):
|
||||
'default_addr_pool', 'subnet_size', 'data_path_addr'):
|
||||
continue
|
||||
if not client.option_minimal_versions[k]['supported']:
|
||||
continue
|
||||
@ -487,6 +503,7 @@ class SwarmManager(DockerBaseClass):
|
||||
init_arguments = {
|
||||
'advertise_addr': self.parameters.advertise_addr,
|
||||
'listen_addr': self.parameters.listen_addr,
|
||||
'data_path_addr': self.parameters.data_path_addr,
|
||||
'force_new_cluster': self.force,
|
||||
'swarm_spec': self.parameters.spec,
|
||||
}
|
||||
@ -548,7 +565,8 @@ class SwarmManager(DockerBaseClass):
|
||||
try:
|
||||
self.client.join_swarm(
|
||||
remote_addrs=self.parameters.remote_addrs, join_token=self.parameters.join_token,
|
||||
listen_addr=self.parameters.listen_addr, advertise_addr=self.parameters.advertise_addr)
|
||||
listen_addr=self.parameters.listen_addr, advertise_addr=self.parameters.advertise_addr,
|
||||
data_path_addr=self.parameters.data_path_addr)
|
||||
except APIError as exc:
|
||||
self.client.fail("Can not join the Swarm Cluster: %s" % to_native(exc))
|
||||
self.results['actions'].append("New node is added to swarm cluster")
|
||||
@ -597,6 +615,7 @@ def _detect_remove_operation(client):
|
||||
def main():
|
||||
argument_spec = dict(
|
||||
advertise_addr=dict(type='str'),
|
||||
data_path_addr=dict(type='str'),
|
||||
state=dict(type='str', default='present', choices=['present', 'join', 'absent', 'remove']),
|
||||
force=dict(type='bool', default=False),
|
||||
listen_addr=dict(type='str', default='0.0.0.0:2377'),
|
||||
@ -642,6 +661,7 @@ def main():
|
||||
),
|
||||
default_addr_pool=dict(docker_py_version='4.0.0', docker_api_version='1.39'),
|
||||
subnet_size=dict(docker_py_version='4.0.0', docker_api_version='1.39'),
|
||||
data_path_addr=dict(docker_py_version='4.0.0', docker_api_version='1.30'),
|
||||
)
|
||||
|
||||
client = AnsibleDockerSwarmClient(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user