From e7a995901f026b2d54eb676baeea06e7b71b8761 Mon Sep 17 00:00:00 2001 From: chrische <3012147+chrische@users.noreply.github.com> Date: Mon, 2 May 2022 21:10:26 +0200 Subject: [PATCH 1/6] adds data_path_addr option for swarm init and swarm join. (ansible-collections/community.docker#339) --- plugins/modules/docker_swarm.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/modules/docker_swarm.py b/plugins/modules/docker_swarm.py index cf6492762..1665114bf 100644 --- a/plugins/modules/docker_swarm.py +++ b/plugins/modules/docker_swarm.py @@ -175,6 +175,14 @@ 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's not + considered for idempotency checking. + type: str extends_documentation_fragment: - community.docker.docker - community.docker.docker.docker_py_1_documentation @@ -218,6 +226,12 @@ 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 +307,7 @@ def __init__(self): self.listen_addr = None self.remote_addrs = None self.join_token = None + self.data_path_addr = None # Spec self.snapshot_interval = None @@ -398,7 +413,7 @@ def compare_to_active(self, other, client, differences): 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 +502,7 @@ def init_swarm(self): 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 +564,8 @@ def join(self): 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 +614,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 +660,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.31'), ) client = AnsibleDockerSwarmClient( From 5e4e34b68bb2f840df5e7177b030b90e1ec9b305 Mon Sep 17 00:00:00 2001 From: chrische <3012147+chrische@users.noreply.github.com> Date: Mon, 2 May 2022 21:33:56 +0200 Subject: [PATCH 2/6] adds changelog fragment (ansible-collections/community.docker#339) --- changelogs/fragments/344-adds-data-path-addr.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/344-adds-data-path-addr.yml diff --git a/changelogs/fragments/344-adds-data-path-addr.yml b/changelogs/fragments/344-adds-data-path-addr.yml new file mode 100644 index 000000000..cb98cb104 --- /dev/null +++ b/changelogs/fragments/344-adds-data-path-addr.yml @@ -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). From 3c6e2d81d35caa870d2d83bfd3838d2dff10dc23 Mon Sep 17 00:00:00 2001 From: chrische <3012147+chrische@users.noreply.github.com> Date: Tue, 3 May 2022 11:01:15 +0200 Subject: [PATCH 3/6] adds formatting to changelog entry Co-authored-by: Felix Fontein --- changelogs/fragments/344-adds-data-path-addr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/344-adds-data-path-addr.yml b/changelogs/fragments/344-adds-data-path-addr.yml index cb98cb104..a85634b4e 100644 --- a/changelogs/fragments/344-adds-data-path-addr.yml +++ b/changelogs/fragments/344-adds-data-path-addr.yml @@ -1,2 +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). + - docker_swarm - adds ``data_path_addr`` parameter during swarm initialization or when joining (https://github.com/ansible-collections/community.docker/issues/339). From c910c0555c80998b715daef1c659de06be2ce578 Mon Sep 17 00:00:00 2001 From: chrische <3012147+chrische@users.noreply.github.com> Date: Tue, 3 May 2022 11:02:26 +0200 Subject: [PATCH 4/6] adds version to doc entry in ansible_swarm Co-authored-by: Felix Fontein --- plugins/modules/docker_swarm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/docker_swarm.py b/plugins/modules/docker_swarm.py index 1665114bf..00a5b8057 100644 --- a/plugins/modules/docker_swarm.py +++ b/plugins/modules/docker_swarm.py @@ -183,6 +183,7 @@ - Only used when swarm is initialised or joined. Because of this it's 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 From 9a627f45c9480aebf669b67f21fad57f6023f560 Mon Sep 17 00:00:00 2001 From: chrische <3012147+chrische@users.noreply.github.com> Date: Tue, 3 May 2022 11:03:05 +0200 Subject: [PATCH 5/6] rewrites doc entry to formal language Co-authored-by: Felix Fontein --- plugins/modules/docker_swarm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/docker_swarm.py b/plugins/modules/docker_swarm.py index 00a5b8057..52fb63176 100644 --- a/plugins/modules/docker_swarm.py +++ b/plugins/modules/docker_swarm.py @@ -180,7 +180,7 @@ - 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's not + - 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 From 384d88dd8b343b51ce0b00873e1f73a9eed26bc7 Mon Sep 17 00:00:00 2001 From: chrische <3012147+chrische@users.noreply.github.com> Date: Wed, 4 May 2022 11:35:56 +0200 Subject: [PATCH 6/6] Correct docker api version (src: docker api docs) Co-authored-by: Felix Fontein --- plugins/modules/docker_swarm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/docker_swarm.py b/plugins/modules/docker_swarm.py index 52fb63176..3903539cb 100644 --- a/plugins/modules/docker_swarm.py +++ b/plugins/modules/docker_swarm.py @@ -661,7 +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.31'), + data_path_addr=dict(docker_py_version='4.0.0', docker_api_version='1.30'), ) client = AnsibleDockerSwarmClient(