docker_swarm_service: Add hosts option (#53290)

* Add hosts option

* Add changelog fragment
This commit is contained in:
Hannes Ljungberg
2019-03-05 19:59:49 +01:00
committed by John R Barker
parent 1323dca9e9
commit 7a130d5446
4 changed files with 77 additions and 0 deletions

View File

@@ -1064,6 +1064,58 @@
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in hostname_1.msg"
when: docker_api_version is version('1.25', '<')
###################################################################
## hosts ##########################################################
###################################################################
- name: hosts
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"'
hosts:
example.com: 1.2.3.4
example.org: 4.3.2.1
register: hosts_1
- name: hosts (idempotency)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"'
hosts:
example.com: 1.2.3.4
example.org: 4.3.2.1
register: hosts_2
- name: hosts (change)
docker_swarm_service:
name: "{{ service_name }}"
image: alpine:3.8
command: '/bin/sh -v -c "sleep 10m"'
hosts:
example.com: 1.2.3.4
register: hosts_3
- name: cleanup
docker_swarm_service:
name: "{{ service_name }}"
state: absent
diff: no
- assert:
that:
- hosts_1 is changed
- hosts_2 is not changed
- hosts_3 is changed
when: docker_api_version is version('1.25', '>=')
- assert:
that:
- hosts_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.25') in hosts_1.msg"
when: docker_api_version is version('1.25', '<')
###################################################################
## image ##########################################################
###################################################################

View File

@@ -16,6 +16,7 @@ service_expected_output:
healthcheck: null
healthcheck_disabled: null
hostname: null
hosts: null
image: busybox
labels: null
limit_cpu: null