2018-10-08 09:23:23 +02:00
|
|
|
---
|
|
|
|
- name: Registering container name
|
|
|
|
set_fact:
|
|
|
|
cname: "{{ cname_prefix ~ '-options' }}"
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## published_ports: all ############################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: published_ports -- all
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-10-08 09:23:23 +02:00
|
|
|
published_ports:
|
|
|
|
- all
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 09:23:23 +02:00
|
|
|
register: published_ports_1
|
|
|
|
|
|
|
|
- name: published_ports -- all (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-10-08 09:23:23 +02:00
|
|
|
published_ports:
|
|
|
|
- all
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 09:23:23 +02:00
|
|
|
register: published_ports_2
|
|
|
|
|
|
|
|
- name: published_ports -- all (writing out 'all')
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-10-08 09:23:23 +02:00
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 09:23:23 +02:00
|
|
|
register: published_ports_3
|
|
|
|
|
|
|
|
- name: published_ports -- all (idempotency 2)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-10-08 09:23:23 +02:00
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 09:23:23 +02:00
|
|
|
register: published_ports_4
|
|
|
|
|
|
|
|
- name: published_ports -- all (switching back to 'all')
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "8081"
|
2018-10-08 09:23:23 +02:00
|
|
|
published_ports:
|
|
|
|
- all
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 09:23:23 +02:00
|
|
|
register: published_ports_5
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-10-08 09:23:23 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- published_ports_1 is changed
|
|
|
|
- published_ports_2 is not changed
|
|
|
|
- published_ports_3 is changed
|
|
|
|
- published_ports_4 is not changed
|
|
|
|
- published_ports_5 is changed
|
2018-10-08 11:53:24 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## published_ports: port range #####################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: published_ports -- port range
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "5000-5040"
|
2018-10-08 11:53:24 +02:00
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080:8080"
|
|
|
|
- "5000-5040:5000-5040"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_1
|
|
|
|
|
|
|
|
- name: published_ports -- port range (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "5000-5040"
|
2018-10-08 11:53:24 +02:00
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080:8080"
|
|
|
|
- "5000-5040:5000-5040"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_2
|
|
|
|
|
|
|
|
- name: published_ports -- port range (different range)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080"
|
|
|
|
- "5000-5040"
|
2018-10-08 11:53:24 +02:00
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "8080:8080"
|
|
|
|
- "5010-5050:5010-5050"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_3
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-10-08 11:53:24 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- published_ports_1 is changed
|
|
|
|
- published_ports_2 is not changed
|
|
|
|
- published_ports_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## published_ports: IPv6 addresses #################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: published_ports -- IPv6
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
|
|
|
- "[::1]:8080:8080"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_1
|
|
|
|
|
|
|
|
- name: published_ports -- IPv6 (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
|
|
|
- "[::1]:8080:8080"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_2
|
|
|
|
|
|
|
|
- name: published_ports -- IPv6 (different IP)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "127.0.0.1:8080:8080"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_3
|
|
|
|
|
|
|
|
- name: published_ports -- IPv6 (hostname)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "localhost:8080:8080"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:53:24 +02:00
|
|
|
register: published_ports_4
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-10-08 11:53:24 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- published_ports_1 is changed
|
|
|
|
- published_ports_2 is not changed
|
|
|
|
- published_ports_3 is changed
|
|
|
|
- published_ports_4 is failed
|