From 33ccd3b78d4612a18e57b5282fb13fad40bf495e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 9 Nov 2018 19:15:22 +0100 Subject: [PATCH] [2.7] Fix advertise addr (#48405) * Fix advertise addr (#47608) * Fix issue #46326 * Update example to create a default swarm (cherry picked from commit 87de2dde9f9efbcde8030261322a8f9d71faa355) * Add changelog. --- .../47608-docker_swarm-advertise_addr.yml | 3 +++ lib/ansible/modules/cloud/docker/docker_swarm.py | 4 ---- .../targets/docker_swarm/tasks/test_swarm.yml | 14 +++----------- 3 files changed, 6 insertions(+), 15 deletions(-) create mode 100644 changelogs/fragments/47608-docker_swarm-advertise_addr.yml diff --git a/changelogs/fragments/47608-docker_swarm-advertise_addr.yml b/changelogs/fragments/47608-docker_swarm-advertise_addr.yml new file mode 100644 index 00000000000..4deff2f38e3 --- /dev/null +++ b/changelogs/fragments/47608-docker_swarm-advertise_addr.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- "docker_swarm - making ``advertise_addr`` optional, as it was already documented." diff --git a/lib/ansible/modules/cloud/docker/docker_swarm.py b/lib/ansible/modules/cloud/docker/docker_swarm.py index ec2f8ef2377..d3de6142c4b 100644 --- a/lib/ansible/modules/cloud/docker/docker_swarm.py +++ b/lib/ansible/modules/cloud/docker/docker_swarm.py @@ -151,7 +151,6 @@ EXAMPLES = ''' - name: Init a new swarm with default parameters docker_swarm: state: present - advertise_addr: 192.168.1.1 - name: Update swarm configuration docker_swarm: @@ -330,9 +329,6 @@ class SwarmManager(DockerBaseClass): return try: - if self.parameters.advertise_addr is None: - self.client.fail(msg="advertise_addr is required to initialize a swarm cluster.") - self.client.init_swarm( advertise_addr=self.parameters.advertise_addr, listen_addr=self.parameters.listen_addr, force_new_cluster=self.parameters.force_new_cluster, swarm_spec=self.parameters.spec) diff --git a/test/integration/targets/docker_swarm/tasks/test_swarm.yml b/test/integration/targets/docker_swarm/tasks/test_swarm.yml index 9e6bf808445..14a2eaecd2c 100644 --- a/test/integration/targets/docker_swarm/tasks/test_swarm.yml +++ b/test/integration/targets/docker_swarm/tasks/test_swarm.yml @@ -1,14 +1,7 @@ -- name: Test parameters with state=present +- name: Make sure we're not already using Docker swarm docker_swarm: - state: present - ignore_errors: yes - register: output - -- name: assert failure when called with state=init and no advertise_addr - assert: - that: - - 'output.failed' - - 'output.msg == "advertise_addr is required to initialize a swarm cluster."' + state: absent + force: true - name: Test parameters with state=join docker_swarm: @@ -37,7 +30,6 @@ - name: Create a Swarm cluster docker_swarm: state: present - advertise_addr: "{{ansible_default_ipv4.address}}" register: output - name: assert changed when create a new swarm cluster