2018-09-28 09:33:38 +02:00
|
|
|
---
|
|
|
|
- name: Registering container name
|
|
|
|
set_fact:
|
|
|
|
cname: "{{ cname_prefix ~ '-comparisons' }}"
|
|
|
|
- name: Registering container name
|
|
|
|
set_fact:
|
2019-05-31 23:47:53 +02:00
|
|
|
cnames: "{{ cnames + [cname] }}"
|
2018-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## value ###########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: value
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.com
|
|
|
|
register: value_1
|
|
|
|
|
|
|
|
- name: value (change, ignore)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.org
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
hostname: ignore
|
|
|
|
register: value_2
|
|
|
|
|
|
|
|
- name: value (change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.org
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
hostname: strict
|
|
|
|
register: value_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-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- value_1 is changed
|
|
|
|
- value_2 is not changed
|
|
|
|
- value_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## list ############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: list
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_servers:
|
|
|
|
- 1.1.1.1
|
|
|
|
- 8.8.8.8
|
|
|
|
register: list_1
|
|
|
|
|
|
|
|
- name: list (change, ignore)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_servers:
|
|
|
|
- 9.9.9.9
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
dns_servers: ignore
|
|
|
|
register: list_2
|
|
|
|
|
|
|
|
- name: list (change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_servers:
|
|
|
|
- 9.9.9.9
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
dns_servers: strict
|
|
|
|
register: list_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-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- list_1 is changed
|
|
|
|
- list_2 is not changed
|
|
|
|
- list_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## set #############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: set
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "1010"
|
|
|
|
- "1011"
|
2018-09-28 09:33:38 +02:00
|
|
|
register: set_1
|
|
|
|
|
|
|
|
- name: set (change, ignore)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "1010"
|
|
|
|
- "1011"
|
|
|
|
- "1012"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
groups: ignore
|
|
|
|
register: set_2
|
|
|
|
|
|
|
|
- name: set (change, allow_more_present)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "1010"
|
|
|
|
- "1011"
|
|
|
|
- "1012"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
groups: allow_more_present
|
|
|
|
register: set_3
|
|
|
|
|
|
|
|
- name: set (change, allow_more_present)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "1010"
|
|
|
|
- "1012"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
groups: allow_more_present
|
|
|
|
register: set_4
|
|
|
|
|
|
|
|
- name: set (change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
2019-03-11 10:04:06 +01:00
|
|
|
- "1010"
|
|
|
|
- "1012"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
groups: strict
|
|
|
|
register: set_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-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- set_1 is changed
|
|
|
|
- set_2 is not changed
|
|
|
|
- set_3 is changed
|
|
|
|
- set_4 is not changed
|
|
|
|
- set_5 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## set(dict) #######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: set(dict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
- "/dev/urandom:/dev/virt-urandom:rwm"
|
|
|
|
register: set_dict_1
|
|
|
|
|
|
|
|
- name: set(dict) (change, ignore)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
- "/dev/urandom:/dev/virt-urandom:rwm"
|
|
|
|
- "/dev/null:/dev/virt-null:rwm"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
devices: ignore
|
|
|
|
register: set_dict_2
|
|
|
|
|
|
|
|
- name: set(dict) (change, allow_more_present)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
- "/dev/urandom:/dev/virt-urandom:rwm"
|
|
|
|
- "/dev/null:/dev/virt-null:rwm"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
devices: allow_more_present
|
|
|
|
register: set_dict_3
|
|
|
|
|
|
|
|
- name: set(dict) (change, allow_more_present)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
- "/dev/null:/dev/virt-null:rwm"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
devices: allow_more_present
|
|
|
|
register: set_dict_4
|
|
|
|
|
|
|
|
- name: set(dict) (change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
- "/dev/null:/dev/virt-null:rwm"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
devices: strict
|
|
|
|
register: set_dict_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-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- set_dict_1 is changed
|
|
|
|
- set_dict_2 is not changed
|
|
|
|
- set_dict_3 is changed
|
|
|
|
- set_dict_4 is not changed
|
|
|
|
- set_dict_5 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## dict ############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: dict
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
register: dict_1
|
|
|
|
|
|
|
|
- name: dict (change, ignore)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.3: ansible
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
labels: ignore
|
|
|
|
register: dict_2
|
|
|
|
|
|
|
|
- name: dict (change, allow_more_present)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.3: ansible
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
labels: allow_more_present
|
|
|
|
register: dict_3
|
|
|
|
|
|
|
|
- name: dict (change, allow_more_present)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.3: ansible
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
labels: allow_more_present
|
|
|
|
register: dict_4
|
|
|
|
|
|
|
|
- name: dict (change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.3: ansible
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
labels: strict
|
|
|
|
register: dict_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-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- dict_1 is changed
|
|
|
|
- dict_2 is not changed
|
|
|
|
- dict_3 is changed
|
|
|
|
- dict_4 is not changed
|
|
|
|
- dict_5 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## wildcard ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: Pull hello-world image to make sure wildcard_2 test succeeds
|
|
|
|
# If the image isn't there, it will pull it and return 'changed'.
|
|
|
|
docker_image:
|
|
|
|
name: hello-world
|
|
|
|
pull: true
|
|
|
|
|
|
|
|
- name: wildcard
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.com
|
2018-09-30 13:03:53 +02:00
|
|
|
stop_timeout: 1
|
2018-09-28 09:33:38 +02:00
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.3: ansible
|
|
|
|
register: wildcard_1
|
|
|
|
|
|
|
|
- name: wildcard (change, ignore)
|
|
|
|
docker_container:
|
|
|
|
image: hello-world
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.org
|
2018-09-30 13:03:53 +02:00
|
|
|
stop_timeout: 2
|
2018-09-28 09:33:38 +02:00
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.4: ignore
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
'*': ignore
|
|
|
|
register: wildcard_2
|
|
|
|
|
|
|
|
- name: wildcard (change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.org
|
|
|
|
stop_timeout: 1
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.3: ansible
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
'*': strict
|
|
|
|
register: wildcard_3
|
|
|
|
|
|
|
|
- name: wildcard (no change, strict)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
hostname: example.org
|
|
|
|
stop_timeout: 1
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.3: ansible
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-28 09:33:38 +02:00
|
|
|
comparisons:
|
|
|
|
'*': strict
|
|
|
|
register: wildcard_4
|
|
|
|
|
|
|
|
- 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-09-28 09:33:38 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- wildcard_1 is changed
|
|
|
|
- wildcard_2 is not changed
|
|
|
|
- wildcard_3 is changed
|
|
|
|
- wildcard_4 is not changed
|