2018-09-24 11:40:05 +02:00
|
|
|
---
|
|
|
|
- name: Registering container name
|
|
|
|
set_fact:
|
|
|
|
cname: "{{ cname_prefix ~ '-options' }}"
|
|
|
|
cname_h1: "{{ cname_prefix ~ '-options-h1' }}"
|
|
|
|
cname_h2: "{{ cname_prefix ~ '-options-h2' }}"
|
|
|
|
cname_h3: "{{ cname_prefix ~ '-options-h3' }}"
|
|
|
|
nname_1: "{{ cname_prefix ~ '-network-1' }}"
|
|
|
|
nname_2: "{{ cname_prefix ~ '-network-2' }}"
|
|
|
|
- name: Registering container name
|
|
|
|
set_fact:
|
|
|
|
cnames: "{{ cnames }} + [cname, cname_h1, cname_h2, cname_h3]"
|
|
|
|
dnetworks: "{{ dnetworks }} + [nname_1, nname_2]"
|
|
|
|
|
|
|
|
- name: Create networks
|
|
|
|
docker_network:
|
|
|
|
name: "{{ network_name }}"
|
|
|
|
state: present
|
|
|
|
loop:
|
|
|
|
- "{{ nname_1 }}"
|
|
|
|
- "{{ nname_2 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: network_name
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## auto_remove #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: auto_remove
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "echo"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
auto_remove: yes
|
|
|
|
register: auto_remove_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: Give container 1 second to be sure it terminated
|
|
|
|
pause:
|
|
|
|
seconds: 1
|
|
|
|
|
|
|
|
- name: auto_remove (verify)
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
|
|
|
register: auto_remove_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- auto_remove_1 is changed
|
|
|
|
- auto_remove_2 is not changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.1.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- auto_remove_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.1.0') in auto_remove_1.msg"
|
|
|
|
when: docker_py_version is version('2.1.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## blkio_weight ####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: blkio_weight
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
blkio_weight: 123
|
|
|
|
register: blkio_weight_1
|
|
|
|
|
|
|
|
- name: blkio_weight (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
blkio_weight: 123
|
|
|
|
register: blkio_weight_2
|
|
|
|
|
|
|
|
- name: blkio_weight (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
blkio_weight: 234
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: blkio_weight_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- blkio_weight_1 is changed
|
|
|
|
- blkio_weight_2 is not changed
|
|
|
|
- blkio_weight_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## cap_drop, capabilities ##########################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: capabilities, cap_drop
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
capabilities:
|
|
|
|
- sys_time
|
|
|
|
cap_drop:
|
|
|
|
- all
|
|
|
|
register: capabilities_1
|
|
|
|
|
|
|
|
- name: capabilities, cap_drop (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
capabilities:
|
|
|
|
- sys_time
|
|
|
|
cap_drop:
|
|
|
|
- all
|
|
|
|
register: capabilities_2
|
|
|
|
|
|
|
|
- name: capabilities, cap_drop (less)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
capabilities: []
|
|
|
|
cap_drop:
|
|
|
|
- all
|
|
|
|
register: capabilities_3
|
|
|
|
|
|
|
|
- name: capabilities, cap_drop (changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
capabilities:
|
|
|
|
- setgid
|
|
|
|
cap_drop:
|
|
|
|
- all
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: capabilities_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- capabilities_1 is changed
|
|
|
|
- capabilities_2 is not changed
|
|
|
|
- capabilities_3 is not changed
|
|
|
|
- capabilities_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## command #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: command
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -v -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: command_1
|
|
|
|
|
|
|
|
- name: command (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -v -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: command_2
|
|
|
|
|
|
|
|
- name: command (less parameters)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: command_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- command_1 is changed
|
|
|
|
- command_2 is not changed
|
|
|
|
- command_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## cpu_period ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: cpu_period
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_period: 90000
|
|
|
|
state: started
|
|
|
|
register: cpu_period_1
|
|
|
|
|
|
|
|
- name: cpu_period (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_period: 90000
|
|
|
|
state: started
|
|
|
|
register: cpu_period_2
|
|
|
|
|
|
|
|
- name: cpu_period (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_period: 50000
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: cpu_period_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- cpu_period_1 is changed
|
|
|
|
- cpu_period_2 is not changed
|
|
|
|
- cpu_period_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## cpu_quota #######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: cpu_quota
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_quota: 150000
|
|
|
|
state: started
|
|
|
|
register: cpu_quota_1
|
|
|
|
|
|
|
|
- name: cpu_quota (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_quota: 150000
|
|
|
|
state: started
|
|
|
|
register: cpu_quota_2
|
|
|
|
|
|
|
|
- name: cpu_quota (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_quota: 50000
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: cpu_quota_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- cpu_quota_1 is changed
|
|
|
|
- cpu_quota_2 is not changed
|
|
|
|
- cpu_quota_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## cpu_shares ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: cpu_shares
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_shares: 900
|
|
|
|
state: started
|
|
|
|
register: cpu_shares_1
|
|
|
|
|
|
|
|
- name: cpu_shares (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_shares: 900
|
|
|
|
state: started
|
|
|
|
register: cpu_shares_2
|
|
|
|
|
|
|
|
- name: cpu_shares (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
cpu_shares: 1100
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: cpu_shares_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- cpu_shares_1 is changed
|
|
|
|
- cpu_shares_2 is not changed
|
|
|
|
- cpu_shares_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## cpuset_cpus #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: cpuset_cpus
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpuset_cpus: 0
|
|
|
|
state: started
|
|
|
|
register: cpuset_cpus_1
|
|
|
|
|
|
|
|
- name: cpuset_cpus (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpuset_cpus: 0
|
|
|
|
state: started
|
|
|
|
register: cpuset_cpus_2
|
|
|
|
|
|
|
|
- name: cpuset_cpus (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
cpuset_cpus: 1
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
# This will fail if the system the test is run on doesn't have
|
|
|
|
# multiple CPUs/cores available.
|
|
|
|
ignore_errors: yes
|
|
|
|
register: cpuset_cpus_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- cpuset_cpus_1 is changed
|
|
|
|
- cpuset_cpus_2 is not changed
|
|
|
|
- cpuset_cpus_3 is failed or cpuset_cpus_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## cpuset_mems #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: cpuset_mems
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpuset_mems: 0
|
|
|
|
state: started
|
|
|
|
register: cpuset_mems_1
|
|
|
|
|
|
|
|
- name: cpuset_mems (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
cpuset_mems: 0
|
|
|
|
state: started
|
|
|
|
register: cpuset_mems_2
|
|
|
|
|
|
|
|
- name: cpuset_mems (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
cpuset_mems: 1
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
# This will fail if the system the test is run on doesn't have
|
|
|
|
# multiple MEMs available.
|
|
|
|
ignore_errors: yes
|
|
|
|
register: cpuset_mems_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- cpuset_mems_1 is changed
|
|
|
|
- cpuset_mems_2 is not changed
|
|
|
|
- cpuset_mems_3 is failed or cpuset_mems_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## debug ###########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: debug (create)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: present
|
|
|
|
debug: yes
|
|
|
|
register: debug_1
|
|
|
|
|
|
|
|
- name: debug (start)
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
debug: yes
|
|
|
|
register: debug_2
|
|
|
|
|
|
|
|
- name: debug (stop)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: stopped
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
debug: yes
|
|
|
|
register: debug_3
|
|
|
|
|
|
|
|
- name: debug (absent)
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
|
|
|
debug: yes
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: debug_4
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- debug_1 is changed
|
|
|
|
- debug_2 is changed
|
|
|
|
- debug_3 is changed
|
|
|
|
- debug_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
2018-11-01 09:08:43 +01:00
|
|
|
## detach, cleanup #################################################
|
2018-09-24 11:40:05 +02:00
|
|
|
####################################################################
|
|
|
|
|
2018-10-23 08:51:24 +02:00
|
|
|
- name: detach without cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
image: hello-world
|
|
|
|
detach: no
|
|
|
|
register: detach_no_cleanup
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
|
|
|
register: detach_no_cleanup_cleanup
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-10-23 08:51:24 +02:00
|
|
|
|
|
|
|
- name: detach with cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
image: hello-world
|
|
|
|
detach: no
|
|
|
|
cleanup: yes
|
|
|
|
register: detach_cleanup
|
|
|
|
|
|
|
|
- name: cleanup (unnecessary)
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
|
|
|
register: detach_cleanup_cleanup
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-10-23 08:51:24 +02:00
|
|
|
|
|
|
|
- name: detach with auto_remove and cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
image: hello-world
|
|
|
|
detach: no
|
|
|
|
auto_remove: yes
|
|
|
|
cleanup: yes
|
|
|
|
register: detach_auto_remove
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-23 08:51:24 +02:00
|
|
|
|
|
|
|
- name: cleanup (unnecessary)
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
|
|
|
register: detach_auto_remove_cleanup
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-10-23 08:51:24 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2018-11-05 12:33:29 +01:00
|
|
|
# NOTE that 'Output' sometimes fails to contain the correct output
|
|
|
|
# of hello-world. We don't know why this happens, but it happens
|
|
|
|
# often enough to be annoying. That's why we disable this for now,
|
|
|
|
# and simply test that 'Output' is contained in the result.
|
2019-03-05 17:09:00 +01:00
|
|
|
- "'Output' in detach_no_cleanup.container"
|
|
|
|
# - "'Hello from Docker!' in detach_no_cleanup.container.Output"
|
2018-10-23 08:51:24 +02:00
|
|
|
- detach_no_cleanup_cleanup is changed
|
2019-03-05 17:09:00 +01:00
|
|
|
- "'Output' in detach_cleanup.container"
|
|
|
|
# - "'Hello from Docker!' in detach_cleanup.container.Output"
|
2018-10-23 08:51:24 +02:00
|
|
|
- detach_cleanup_cleanup is not changed
|
2018-11-05 01:25:11 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-03-05 17:09:00 +01:00
|
|
|
- "'Cannot retrieve result as auto_remove is enabled' == detach_auto_remove.container.Output"
|
2018-10-23 08:51:24 +02:00
|
|
|
- detach_auto_remove_cleanup is not changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.1.0', '>=')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## devices #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: devices
|
|
|
|
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: devices_1
|
|
|
|
|
|
|
|
- name: devices (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/urandom:/dev/virt-urandom:rwm"
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
register: devices_2
|
|
|
|
|
|
|
|
- name: devices (less)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
devices:
|
|
|
|
- "/dev/random:/dev/virt-random:rwm"
|
|
|
|
register: devices_3
|
|
|
|
|
|
|
|
- name: devices (changed)
|
|
|
|
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-24 11:40:05 +02:00
|
|
|
register: devices_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- devices_1 is changed
|
|
|
|
- devices_2 is not changed
|
|
|
|
- devices_3 is not changed
|
|
|
|
- devices_4 is changed
|
|
|
|
|
2018-11-01 23:58:06 +01:00
|
|
|
####################################################################
|
|
|
|
## device_read_bps #################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: device_read_bps
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_bps:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 20M
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 10K
|
|
|
|
register: device_read_bps_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_read_bps (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_bps:
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 10K
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 20M
|
|
|
|
register: device_read_bps_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_read_bps (lesser entries)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_bps:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 20M
|
|
|
|
register: device_read_bps_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_read_bps (changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_bps:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 10M
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 5K
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
register: device_read_bps_4
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- 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-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- device_read_bps_1 is changed
|
|
|
|
- device_read_bps_2 is not changed
|
|
|
|
- device_read_bps_3 is not changed
|
|
|
|
- device_read_bps_4 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.9.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- device_read_bps_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.9.0') in device_read_bps_1.msg"
|
|
|
|
when: docker_py_version is version('1.9.0', '<')
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## device_read_iops ################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: device_read_iops
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_iops:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 10
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 20
|
|
|
|
register: device_read_iops_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_read_iops (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_iops:
|
|
|
|
- path: /dev/urandom
|
2018-11-12 12:33:42 +01:00
|
|
|
rate: "20"
|
2018-11-01 23:58:06 +01:00
|
|
|
- path: /dev/random
|
|
|
|
rate: 10
|
|
|
|
register: device_read_iops_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_read_iops (less)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_iops:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 10
|
|
|
|
register: device_read_iops_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_read_iops (changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_read_iops:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 30
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 50
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
register: device_read_iops_4
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- 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-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- device_read_iops_1 is changed
|
|
|
|
- device_read_iops_2 is not changed
|
|
|
|
- device_read_iops_3 is not changed
|
|
|
|
- device_read_iops_4 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.9.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- device_read_iops_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.9.0') in device_read_iops_1.msg"
|
|
|
|
when: docker_py_version is version('1.9.0', '<')
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## device_write_bps and device_write_iops ##########################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: device_write_bps and device_write_iops
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_write_bps:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 10M
|
|
|
|
device_write_iops:
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 30
|
|
|
|
register: device_write_limit_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_write_bps and device_write_iops (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_write_bps:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 10M
|
|
|
|
device_write_iops:
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 30
|
|
|
|
register: device_write_limit_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- name: device_write_bps device_write_iops (changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
device_write_bps:
|
|
|
|
- path: /dev/random
|
|
|
|
rate: 20K
|
|
|
|
device_write_iops:
|
|
|
|
- path: /dev/urandom
|
|
|
|
rate: 100
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
register: device_write_limit_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- 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-11-01 23:58:06 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- device_write_limit_1 is changed
|
|
|
|
- device_write_limit_2 is not changed
|
|
|
|
- device_write_limit_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.9.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- device_write_limit_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.9.0') in device_write_limit_1.msg"
|
|
|
|
when: docker_py_version is version('1.9.0', '<')
|
2018-11-01 23:58:06 +01:00
|
|
|
|
2018-09-24 11:40:05 +02:00
|
|
|
####################################################################
|
|
|
|
## dns_opts ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: dns_opts
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_opts:
|
|
|
|
- "timeout:10"
|
|
|
|
- rotate
|
|
|
|
register: dns_opts_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: dns_opts (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_opts:
|
|
|
|
- rotate
|
|
|
|
- "timeout:10"
|
|
|
|
register: dns_opts_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: dns_opts (less resolv.conf options)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_opts:
|
|
|
|
- "timeout:10"
|
|
|
|
register: dns_opts_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: dns_opts (more resolv.conf options)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_opts:
|
|
|
|
- "timeout:10"
|
|
|
|
- no-check-names
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: dns_opts_4
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- dns_opts_1 is changed
|
|
|
|
- dns_opts_2 is not changed
|
|
|
|
- dns_opts_3 is not changed
|
|
|
|
- dns_opts_4 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- dns_opts_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.10.0') in dns_opts_1.msg"
|
|
|
|
when: docker_py_version is version('1.10.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## dns_search_domains ##############################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: dns_search_domains
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_search_domains:
|
|
|
|
- example.com
|
|
|
|
- example.org
|
|
|
|
register: dns_search_domains_1
|
|
|
|
|
|
|
|
- name: dns_search_domains (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_search_domains:
|
|
|
|
- example.com
|
|
|
|
- example.org
|
|
|
|
register: dns_search_domains_2
|
|
|
|
|
|
|
|
- name: dns_search_domains (different order)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_search_domains:
|
|
|
|
- example.org
|
|
|
|
- example.com
|
|
|
|
register: dns_search_domains_3
|
|
|
|
|
|
|
|
- name: dns_search_domains (changed elements)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_search_domains:
|
|
|
|
- ansible.com
|
|
|
|
- example.com
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: dns_search_domains_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- dns_search_domains_1 is changed
|
|
|
|
- dns_search_domains_2 is not changed
|
|
|
|
- dns_search_domains_3 is changed
|
|
|
|
- dns_search_domains_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## dns_servers #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: dns_servers
|
|
|
|
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: dns_servers_1
|
|
|
|
|
|
|
|
- name: dns_servers (idempotency)
|
|
|
|
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: dns_servers_2
|
|
|
|
|
|
|
|
- name: dns_servers (changed order)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_servers:
|
|
|
|
- 8.8.8.8
|
|
|
|
- 1.1.1.1
|
|
|
|
register: dns_servers_3
|
|
|
|
|
|
|
|
- name: dns_servers (changed elements)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
dns_servers:
|
|
|
|
- 8.8.8.8
|
|
|
|
- 9.9.9.9
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: dns_servers_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- dns_servers_1 is changed
|
|
|
|
- dns_servers_2 is not changed
|
|
|
|
- dns_servers_3 is changed
|
|
|
|
- dns_servers_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## domainname ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: domainname
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
domainname: example.com
|
|
|
|
state: started
|
|
|
|
register: domainname_1
|
|
|
|
|
|
|
|
- name: domainname (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
domainname: example.com
|
|
|
|
state: started
|
|
|
|
register: domainname_2
|
|
|
|
|
|
|
|
- name: domainname (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
domainname: example.org
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: domainname_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- domainname_1 is changed
|
|
|
|
- domainname_2 is not changed
|
|
|
|
- domainname_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## entrypoint ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: entrypoint
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
entrypoint:
|
|
|
|
- /bin/sh
|
|
|
|
- "-v"
|
|
|
|
- "-c"
|
|
|
|
- "'sleep 10m'"
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: entrypoint_1
|
|
|
|
|
|
|
|
- name: entrypoint (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
entrypoint:
|
|
|
|
- /bin/sh
|
|
|
|
- "-v"
|
|
|
|
- "-c"
|
|
|
|
- "'sleep 10m'"
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: entrypoint_2
|
|
|
|
|
|
|
|
- name: entrypoint (change order idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
entrypoint:
|
|
|
|
- /bin/sh
|
|
|
|
- "-c"
|
|
|
|
- "'sleep 10m'"
|
|
|
|
- "-v"
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: entrypoint_3
|
|
|
|
|
|
|
|
- name: entrypoint (less parameters)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
entrypoint:
|
|
|
|
- /bin/sh
|
|
|
|
- "-c"
|
|
|
|
- "'sleep 10m'"
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: entrypoint_4
|
|
|
|
|
|
|
|
- name: entrypoint (other parameters)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
entrypoint:
|
|
|
|
- /bin/sh
|
|
|
|
- "-c"
|
|
|
|
- "'sleep 5m'"
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: entrypoint_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- entrypoint_1 is changed
|
|
|
|
- entrypoint_2 is not changed
|
|
|
|
- entrypoint_3 is changed
|
|
|
|
- entrypoint_4 is changed
|
|
|
|
- entrypoint_5 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## env #############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: env
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env:
|
|
|
|
TEST1: val1
|
|
|
|
TEST2: val2
|
2018-12-14 20:21:54 +01:00
|
|
|
TEST3: "False"
|
|
|
|
TEST4: "true"
|
|
|
|
TEST5: "yes"
|
2018-09-24 11:40:05 +02:00
|
|
|
register: env_1
|
|
|
|
|
|
|
|
- name: env (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env:
|
|
|
|
TEST2: val2
|
|
|
|
TEST1: val1
|
2018-12-14 20:21:54 +01:00
|
|
|
TEST5: "yes"
|
|
|
|
TEST3: "False"
|
|
|
|
TEST4: "true"
|
2018-09-24 11:40:05 +02:00
|
|
|
register: env_2
|
|
|
|
|
|
|
|
- name: env (less environment variables)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env:
|
|
|
|
TEST1: val1
|
|
|
|
register: env_3
|
|
|
|
|
|
|
|
- name: env (more environment variables)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env:
|
|
|
|
TEST1: val1
|
|
|
|
TEST3: val3
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: env_4
|
|
|
|
|
2018-12-14 20:21:54 +01:00
|
|
|
- name: env (fail unwrapped values)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env:
|
|
|
|
TEST1: true
|
|
|
|
force_kill: yes
|
|
|
|
register: env_5
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2018-09-24 11:40:05 +02:00
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- env_1 is changed
|
|
|
|
- env_2 is not changed
|
|
|
|
- env_3 is not changed
|
|
|
|
- env_4 is changed
|
2018-12-14 20:21:54 +01:00
|
|
|
- env_5 is failed
|
|
|
|
- "('Non-string value found for env option.') in env_5.msg"
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## env_file #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: env_file
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env_file: "{{ role_path }}/files/env-file"
|
|
|
|
register: env_file_1
|
|
|
|
|
|
|
|
- name: env_file (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
env_file: "{{ role_path }}/files/env-file"
|
|
|
|
register: env_file_2
|
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- env_file_1 is changed
|
|
|
|
- env_file_2 is not changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## etc_hosts #######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: etc_hosts
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
etc_hosts:
|
|
|
|
example.com: 1.2.3.4
|
|
|
|
example.org: 4.3.2.1
|
|
|
|
register: etc_hosts_1
|
|
|
|
|
|
|
|
- name: etc_hosts (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
etc_hosts:
|
|
|
|
example.org: 4.3.2.1
|
|
|
|
example.com: 1.2.3.4
|
|
|
|
register: etc_hosts_2
|
|
|
|
|
|
|
|
- name: etc_hosts (less hosts)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
etc_hosts:
|
|
|
|
example.com: 1.2.3.4
|
|
|
|
register: etc_hosts_3
|
|
|
|
|
|
|
|
- name: etc_hosts (more hosts)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
etc_hosts:
|
|
|
|
example.com: 1.2.3.4
|
|
|
|
example.us: 1.2.3.5
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: etc_hosts_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- etc_hosts_1 is changed
|
|
|
|
- etc_hosts_2 is not changed
|
|
|
|
- etc_hosts_3 is not changed
|
|
|
|
- etc_hosts_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## exposed_ports ###################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: exposed_ports
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
|
|
|
- 1234
|
|
|
|
- 5678
|
|
|
|
register: exposed_ports_1
|
|
|
|
|
|
|
|
- name: exposed_ports (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
|
|
|
- 5678
|
|
|
|
- 1234
|
|
|
|
register: exposed_ports_2
|
|
|
|
|
|
|
|
- name: exposed_ports (less ports)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
|
|
|
- 1234
|
|
|
|
register: exposed_ports_3
|
|
|
|
|
|
|
|
- name: exposed_ports (more ports)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
exposed_ports:
|
|
|
|
- 1234
|
|
|
|
- 1235
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: exposed_ports_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- exposed_ports_1 is changed
|
|
|
|
- exposed_ports_2 is not changed
|
|
|
|
- exposed_ports_3 is not changed
|
|
|
|
- exposed_ports_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## force_kill ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# TODO: - force_kill
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## groups ##########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: groups
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
|
|
|
- 1234
|
|
|
|
- 5678
|
|
|
|
register: groups_1
|
|
|
|
|
|
|
|
- name: groups (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
|
|
|
- 5678
|
|
|
|
- 1234
|
|
|
|
register: groups_2
|
|
|
|
|
|
|
|
- name: groups (less groups)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
|
|
|
- 1234
|
|
|
|
register: groups_3
|
|
|
|
|
|
|
|
- name: groups (more groups)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
groups:
|
|
|
|
- 1234
|
|
|
|
- 2345
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: groups_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- groups_1 is changed
|
|
|
|
- groups_2 is not changed
|
|
|
|
- groups_3 is not changed
|
|
|
|
- groups_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
2018-10-24 12:49:56 +02:00
|
|
|
## healthcheck #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: healthcheck
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test:
|
|
|
|
- CMD
|
|
|
|
- sleep
|
|
|
|
- 1
|
|
|
|
timeout: 2s
|
|
|
|
interval: 0h0m2s3ms4us
|
|
|
|
retries: 2
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test:
|
|
|
|
- CMD
|
|
|
|
- sleep
|
|
|
|
- 1
|
|
|
|
timeout: 2s
|
|
|
|
interval: 0h0m2s3ms4us
|
|
|
|
retries: 2
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test:
|
|
|
|
- CMD
|
|
|
|
- sleep
|
|
|
|
- 1
|
|
|
|
timeout: 3s
|
|
|
|
interval: 0h1m2s3ms4us
|
|
|
|
retries: 3
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (no change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_4
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (disabled)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test:
|
|
|
|
- NONE
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_5
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (disabled, idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test:
|
|
|
|
- NONE
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_6
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (string in healthcheck test, changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test: "sleep 1"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_7
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- name: healthcheck (string in healthcheck test, idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
healthcheck:
|
|
|
|
test: "sleep 1"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
register: healthcheck_8
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
- 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-24 12:49:56 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- healthcheck_1 is changed
|
|
|
|
- healthcheck_2 is not changed
|
|
|
|
- healthcheck_3 is changed
|
|
|
|
- healthcheck_4 is not changed
|
|
|
|
- healthcheck_5 is changed
|
|
|
|
- healthcheck_6 is not changed
|
|
|
|
- healthcheck_7 is changed
|
|
|
|
- healthcheck_8 is not changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.0.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- healthcheck_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.0.0') in healthcheck_1.msg"
|
|
|
|
when: docker_py_version is version('2.0.0', '<')
|
2018-10-24 12:49:56 +02:00
|
|
|
|
|
|
|
####################################################################
|
2018-09-24 11:40:05 +02:00
|
|
|
## hostname ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: hostname
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
hostname: me.example.com
|
|
|
|
state: started
|
|
|
|
register: hostname_1
|
|
|
|
|
|
|
|
- name: hostname (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
hostname: me.example.com
|
|
|
|
state: started
|
|
|
|
register: hostname_2
|
|
|
|
|
|
|
|
- name: hostname (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
hostname: me.example.org
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: hostname_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- hostname_1 is changed
|
|
|
|
- hostname_2 is not changed
|
|
|
|
- hostname_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## init ############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: init
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
init: yes
|
|
|
|
state: started
|
|
|
|
register: init_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: init (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
init: yes
|
|
|
|
state: started
|
|
|
|
register: init_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: init (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
init: no
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: init_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- init_1 is changed
|
|
|
|
- init_2 is not changed
|
|
|
|
- init_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.2.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- init_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.2.0') in init_1.msg"
|
|
|
|
when: docker_py_version is version('2.2.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## interactive #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: interactive
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
interactive: yes
|
|
|
|
state: started
|
|
|
|
register: interactive_1
|
|
|
|
|
|
|
|
- name: interactive (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
interactive: yes
|
|
|
|
state: started
|
|
|
|
register: interactive_2
|
|
|
|
|
|
|
|
- name: interactive (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
interactive: no
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: interactive_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- interactive_1 is changed
|
|
|
|
- interactive_2 is not changed
|
|
|
|
- interactive_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## image / ignore_image ############################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: Pull hello-world image to make sure ignore_image test succeeds
|
|
|
|
# If the image isn't there, it will pull it and return 'changed'.
|
|
|
|
docker_image:
|
|
|
|
name: hello-world
|
|
|
|
pull: true
|
|
|
|
|
|
|
|
- name: image
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: image_1
|
|
|
|
|
|
|
|
- name: image (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: image_2
|
|
|
|
|
|
|
|
- name: ignore_image
|
|
|
|
docker_container:
|
|
|
|
image: hello-world
|
|
|
|
ignore_image: yes
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
register: ignore_image
|
|
|
|
|
|
|
|
- name: image change
|
|
|
|
docker_container:
|
|
|
|
image: hello-world
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: image_change
|
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- image_1 is changed
|
|
|
|
- image_2 is not changed
|
|
|
|
- ignore_image is not changed
|
|
|
|
- image_change is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## ipc_mode ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: start helpers
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: started
|
|
|
|
loop:
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
|
|
|
|
|
|
|
- name: ipc_mode
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-05 01:26:13 +01:00
|
|
|
ipc_mode: "container:{{ cname_h1 }}"
|
|
|
|
# ipc_mode: shareable
|
2018-09-24 11:40:05 +02:00
|
|
|
register: ipc_mode_1
|
|
|
|
|
|
|
|
- name: ipc_mode (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-05 01:26:13 +01:00
|
|
|
ipc_mode: "container:{{ cname_h1 }}"
|
|
|
|
# ipc_mode: shareable
|
2018-09-24 11:40:05 +02:00
|
|
|
register: ipc_mode_2
|
|
|
|
|
|
|
|
- name: ipc_mode (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
ipc_mode: private
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: ipc_mode_3
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
loop:
|
|
|
|
- "{{ cname }}"
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- ipc_mode_1 is changed
|
|
|
|
- ipc_mode_2 is not changed
|
|
|
|
- ipc_mode_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## kernel_memory ###################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: kernel_memory
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
kernel_memory: 8M
|
|
|
|
state: started
|
|
|
|
register: kernel_memory_1
|
2019-03-01 12:04:39 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: kernel_memory (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
kernel_memory: 8M
|
|
|
|
state: started
|
|
|
|
register: kernel_memory_2
|
2019-03-01 12:04:39 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: kernel_memory (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
kernel_memory: 6M
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: kernel_memory_3
|
2019-03-01 12:04:39 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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
|
2019-03-01 12:04:39 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- kernel_memory_1 is changed
|
|
|
|
- kernel_memory_2 is not changed
|
|
|
|
- kernel_memory_3 is changed
|
2019-03-01 12:04:39 +01:00
|
|
|
when: kernel_memory_1 is not failed or 'kernel memory accounting disabled in this runc build' not in kernel_memory_1.msg
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## kill_signal #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# TODO: - kill_signal
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## labels ##########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: labels
|
|
|
|
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: labels_1
|
|
|
|
|
|
|
|
- name: labels (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.2: world
|
|
|
|
ansible.test.1: hello
|
|
|
|
register: labels_2
|
|
|
|
|
|
|
|
- name: labels (less labels)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
labels:
|
|
|
|
ansible.test.1: hello
|
|
|
|
register: labels_3
|
|
|
|
|
|
|
|
- name: labels (more labels)
|
|
|
|
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-24 11:40:05 +02:00
|
|
|
register: labels_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- labels_1 is changed
|
|
|
|
- labels_2 is not changed
|
|
|
|
- labels_3 is not changed
|
|
|
|
- labels_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## links ###########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: start helpers
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: started
|
|
|
|
loop:
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
- "{{ cname_h2 }}"
|
|
|
|
- "{{ cname_h3 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
|
|
|
|
|
|
|
- name: links
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
links:
|
|
|
|
- "{{ cname_h1 }}:test1"
|
|
|
|
- "{{ cname_h2 }}:test2"
|
|
|
|
register: links_1
|
|
|
|
|
|
|
|
- name: links (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
links:
|
|
|
|
- "{{ cname_h2 }}:test2"
|
|
|
|
- "{{ cname_h1 }}:test1"
|
|
|
|
register: links_2
|
|
|
|
|
|
|
|
- name: links (less links)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
links:
|
|
|
|
- "{{ cname_h1 }}:test1"
|
|
|
|
register: links_3
|
|
|
|
|
|
|
|
- name: links (more links)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
links:
|
|
|
|
- "{{ cname_h1 }}:test1"
|
|
|
|
- "{{ cname_h3 }}:test3"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: links_4
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
loop:
|
|
|
|
- "{{ cname }}"
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
- "{{ cname_h2 }}"
|
|
|
|
- "{{ cname_h3 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- links_1 is changed
|
|
|
|
- links_2 is not changed
|
|
|
|
- links_3 is not changed
|
|
|
|
- links_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## log_driver ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: log_driver
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: json-file
|
|
|
|
register: log_driver_1
|
|
|
|
|
|
|
|
- name: log_driver (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: json-file
|
|
|
|
register: log_driver_2
|
|
|
|
|
|
|
|
- name: log_driver (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: syslog
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: log_driver_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- log_driver_1 is changed
|
|
|
|
- log_driver_2 is not changed
|
|
|
|
- log_driver_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## log_options #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: log_options
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: json-file
|
|
|
|
log_options:
|
|
|
|
labels: production_status
|
|
|
|
env: os,customer
|
|
|
|
register: log_options_1
|
|
|
|
|
|
|
|
- name: log_options (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: json-file
|
|
|
|
log_options:
|
|
|
|
env: os,customer
|
|
|
|
labels: production_status
|
|
|
|
register: log_options_2
|
|
|
|
|
|
|
|
- name: log_options (less log options)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: json-file
|
|
|
|
log_options:
|
|
|
|
labels: production_status
|
|
|
|
register: log_options_3
|
|
|
|
|
|
|
|
- name: log_options (more log options)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
log_driver: json-file
|
|
|
|
log_options:
|
|
|
|
labels: production_status
|
|
|
|
max-file: 1
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: log_options_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- log_options_1 is changed
|
|
|
|
- log_options_2 is not changed
|
|
|
|
- log_options_3 is not changed
|
|
|
|
- log_options_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## mac_address #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: mac_address
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
mac_address: 92:d0:c6:0a:29:33
|
|
|
|
state: started
|
|
|
|
register: mac_address_1
|
|
|
|
|
|
|
|
- name: mac_address (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
mac_address: 92:d0:c6:0a:29:33
|
|
|
|
state: started
|
|
|
|
register: mac_address_2
|
|
|
|
|
|
|
|
- name: mac_address (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
mac_address: 92:d0:c6:0a:29:44
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: mac_address_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- mac_address_1 is changed
|
|
|
|
- mac_address_2 is not changed
|
|
|
|
- mac_address_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## memory ##########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: memory
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
memory: 64M
|
|
|
|
state: started
|
|
|
|
register: memory_1
|
|
|
|
|
|
|
|
- name: memory (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
memory: 64M
|
|
|
|
state: started
|
|
|
|
register: memory_2
|
|
|
|
|
|
|
|
- name: memory (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
memory: 48M
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: memory_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- memory_1 is changed
|
|
|
|
- memory_2 is not changed
|
|
|
|
- memory_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## memory_reservation ##############################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: memory_reservation
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
memory_reservation: 64M
|
|
|
|
state: started
|
|
|
|
register: memory_reservation_1
|
|
|
|
|
|
|
|
- name: memory_reservation (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
memory_reservation: 64M
|
|
|
|
state: started
|
|
|
|
register: memory_reservation_2
|
|
|
|
|
|
|
|
- name: memory_reservation (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
memory_reservation: 48M
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: memory_reservation_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- memory_reservation_1 is changed
|
|
|
|
- memory_reservation_2 is not changed
|
|
|
|
- memory_reservation_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## memory_swap #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: memory_swap
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
# Docker daemon does not accept memory_swap if memory is not specified
|
|
|
|
memory: 32M
|
|
|
|
memory_swap: 64M
|
|
|
|
state: started
|
|
|
|
debug: yes
|
|
|
|
register: memory_swap_1
|
|
|
|
|
|
|
|
- name: memory_swap (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
# Docker daemon does not accept memory_swap if memory is not specified
|
|
|
|
memory: 32M
|
|
|
|
memory_swap: 64M
|
|
|
|
state: started
|
|
|
|
debug: yes
|
|
|
|
register: memory_swap_2
|
|
|
|
|
|
|
|
- name: memory_swap (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
# Docker daemon does not accept memory_swap if memory is not specified
|
|
|
|
memory: 32M
|
|
|
|
memory_swap: 48M
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
debug: yes
|
|
|
|
register: memory_swap_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- memory_swap_1 is changed
|
|
|
|
# Sometimes (in particular during integration tests, maybe when not running
|
|
|
|
# on a proper VM), memory_swap cannot be set and will be -1 afterwards.
|
2019-03-05 17:09:00 +01:00
|
|
|
- memory_swap_2 is not changed or memory_swap_2.container.HostConfig.MemorySwap == -1
|
2018-09-24 11:40:05 +02:00
|
|
|
- memory_swap_3 is changed
|
|
|
|
|
|
|
|
- debug: var=memory_swap_1
|
|
|
|
when: memory_swap_2 is changed
|
|
|
|
- debug: var=memory_swap_2
|
|
|
|
when: memory_swap_2 is changed
|
|
|
|
- debug: var=memory_swap_3
|
|
|
|
when: memory_swap_2 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## memory_swappiness ###############################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: memory_swappiness
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
memory_swappiness: 40
|
|
|
|
state: started
|
|
|
|
register: memory_swappiness_1
|
|
|
|
|
|
|
|
- name: memory_swappiness (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
memory_swappiness: 40
|
|
|
|
state: started
|
|
|
|
register: memory_swappiness_2
|
|
|
|
|
|
|
|
- name: memory_swappiness (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
memory_swappiness: 60
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: memory_swappiness_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- memory_swappiness_1 is changed
|
|
|
|
- memory_swappiness_2 is not changed
|
|
|
|
- memory_swappiness_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## network_mode ####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: network_mode
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
network_mode: host
|
|
|
|
register: network_mode_1
|
|
|
|
|
|
|
|
- name: network_mode (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
network_mode: host
|
|
|
|
register: network_mode_2
|
|
|
|
|
|
|
|
- name: network_mode (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
network_mode: none
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: network_mode_3
|
|
|
|
|
2018-12-12 10:04:24 +01:00
|
|
|
- name: network_mode (container mode setup)
|
2018-09-24 11:40:05 +02:00
|
|
|
docker_container:
|
2018-12-12 10:04:24 +01:00
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname_h1 }}"
|
|
|
|
state: started
|
|
|
|
|
|
|
|
- name: network_mode (container mode)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
2018-12-12 10:04:24 +01:00
|
|
|
state: started
|
|
|
|
network_mode: "container:{{ cname_h1 }}"
|
|
|
|
force_kill: yes
|
|
|
|
register: network_mode_4
|
|
|
|
|
|
|
|
- name: network_mode (container mode idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
network_mode: "container:{{ cname_h1 }}"
|
|
|
|
register: network_mode_5
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ container_name }}"
|
2018-09-24 11:40:05 +02:00
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-12-12 10:04:24 +01:00
|
|
|
loop:
|
|
|
|
- "{{ cname }}"
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- network_mode_1 is changed
|
|
|
|
- network_mode_2 is not changed
|
|
|
|
- network_mode_3 is changed
|
2018-12-12 10:04:24 +01:00
|
|
|
- network_mode_4 is changed
|
|
|
|
- network_mode_5 is not changed
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## networks, purge_networks ########################################
|
|
|
|
####################################################################
|
|
|
|
|
2018-11-05 01:25:11 +01:00
|
|
|
- block:
|
|
|
|
- name: networks, purge_networks
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
purge_networks: yes
|
|
|
|
networks:
|
|
|
|
- name: bridge
|
|
|
|
- name: "{{ nname_1 }}"
|
|
|
|
register: networks_1
|
|
|
|
|
|
|
|
- name: networks, purge_networks (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
purge_networks: yes
|
|
|
|
networks:
|
|
|
|
- name: "{{ nname_1 }}"
|
|
|
|
- name: bridge
|
|
|
|
register: networks_2
|
|
|
|
|
|
|
|
- name: networks (less networks)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
networks:
|
|
|
|
- name: bridge
|
|
|
|
register: networks_3
|
|
|
|
|
|
|
|
- name: networks, purge_networks (less networks)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
purge_networks: yes
|
|
|
|
networks:
|
|
|
|
- name: bridge
|
|
|
|
register: networks_4
|
|
|
|
|
|
|
|
- name: networks, purge_networks (more networks)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
purge_networks: yes
|
|
|
|
networks:
|
|
|
|
- name: bridge
|
|
|
|
- name: "{{ nname_2 }}"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-05 01:25:11 +01:00
|
|
|
register: networks_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-11-05 01:25:11 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- networks_1 is changed
|
|
|
|
- networks_2 is not changed
|
|
|
|
- networks_3 is not changed
|
|
|
|
- networks_4 is changed
|
|
|
|
- networks_5 is changed
|
|
|
|
|
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## oom_killer ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: oom_killer
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
oom_killer: yes
|
|
|
|
state: started
|
|
|
|
register: oom_killer_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: oom_killer (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
oom_killer: yes
|
|
|
|
state: started
|
|
|
|
register: oom_killer_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: oom_killer (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
oom_killer: no
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: oom_killer_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- oom_killer_1 is changed
|
|
|
|
- oom_killer_2 is not changed
|
|
|
|
- oom_killer_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.0.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- oom_killer_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.0.0') in oom_killer_1.msg"
|
|
|
|
when: docker_py_version is version('2.0.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## oom_score_adj ###################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: oom_score_adj
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
oom_score_adj: 5
|
|
|
|
state: started
|
|
|
|
register: oom_score_adj_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: oom_score_adj (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
oom_score_adj: 5
|
|
|
|
state: started
|
|
|
|
register: oom_score_adj_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: oom_score_adj (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
oom_score_adj: 7
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: oom_score_adj_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- oom_score_adj_1 is changed
|
|
|
|
- oom_score_adj_2 is not changed
|
|
|
|
- oom_score_adj_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.0.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- oom_score_adj_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.0.0') in oom_score_adj_1.msg"
|
|
|
|
when: docker_py_version is version('2.0.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## output_logs #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# TODO: - output_logs
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## paused ##########################################################
|
|
|
|
####################################################################
|
|
|
|
|
2018-11-01 09:08:43 +01:00
|
|
|
- name: paused
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-05 12:34:23 +01:00
|
|
|
command: "/bin/sh -c 'sleep 10m'"
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
paused: yes
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: paused_1
|
|
|
|
|
2018-11-05 12:34:23 +01:00
|
|
|
- name: inspect paused
|
|
|
|
command: "docker inspect -f {% raw %}'{{.State.Status}} {{.State.Paused}}'{% endraw %} {{ cname }}"
|
2018-11-01 09:08:43 +01:00
|
|
|
register: paused_2
|
|
|
|
|
|
|
|
- name: paused (idempotent)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-05 12:34:23 +01:00
|
|
|
command: "/bin/sh -c 'sleep 10m'"
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
paused: yes
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: paused_3
|
|
|
|
|
|
|
|
- name: paused (continue)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: "/bin/sh -c 'sleep 10m'"
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
paused: no
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: paused_4
|
|
|
|
|
2018-11-05 12:34:23 +01:00
|
|
|
- name: inspect paused
|
|
|
|
command: "docker inspect -f {% raw %}'{{.State.Status}} {{.State.Paused}}'{% endraw %} {{ cname }}"
|
2018-11-01 09:08:43 +01:00
|
|
|
register: paused_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-11-01 09:08:43 +01:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- paused_1 is changed
|
2018-11-05 12:34:23 +01:00
|
|
|
- 'paused_2.stdout == "paused true"'
|
2018-11-01 09:08:43 +01:00
|
|
|
- paused_3 is not changed
|
|
|
|
- paused_4 is changed
|
2018-11-05 12:34:23 +01:00
|
|
|
- 'paused_5.stdout == "running false"'
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## pid_mode ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: start helpers
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname_h1 }}"
|
|
|
|
state: started
|
|
|
|
register: pid_mode_helper
|
|
|
|
|
|
|
|
- name: pid_mode
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2019-03-05 17:09:00 +01:00
|
|
|
pid_mode: "container:{{ pid_mode_helper.container.Id }}"
|
2018-09-24 11:40:05 +02:00
|
|
|
register: pid_mode_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
|
|
|
# docker-py < 2.0 does not support "arbitrary" pid_mode values
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: pid_mode (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-05 01:26:13 +01:00
|
|
|
pid_mode: "container:{{ cname_h1 }}"
|
2018-09-24 11:40:05 +02:00
|
|
|
register: pid_mode_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
|
|
|
# docker-py < 2.0 does not support "arbitrary" pid_mode values
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: pid_mode (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
pid_mode: host
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: pid_mode_3
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
loop:
|
|
|
|
- "{{ cname }}"
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- pid_mode_1 is changed
|
|
|
|
- pid_mode_2 is not changed
|
|
|
|
- pid_mode_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.0.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- pid_mode_1 is failed
|
|
|
|
- pid_mode_2 is failed
|
|
|
|
- pid_mode_3 is changed
|
|
|
|
when: docker_py_version is version('2.0.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
2018-12-03 12:22:43 +01:00
|
|
|
####################################################################
|
|
|
|
## pids_limit ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: pids_limit
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
pids_limit: 10
|
|
|
|
register: pids_limit_1
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: pids_limit (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
pids_limit: 10
|
|
|
|
register: pids_limit_2
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: pids_limit (changed)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
pids_limit: 20
|
|
|
|
force_kill: yes
|
|
|
|
register: pids_limit_3
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: absent
|
|
|
|
force_kill: yes
|
|
|
|
diff: no
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- pids_limit_1 is changed
|
|
|
|
- pids_limit_2 is not changed
|
|
|
|
- pids_limit_3 is changed
|
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- pids_limit_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.10.0') in pids_limit_1.msg"
|
|
|
|
when: docker_py_version is version('1.10.0', '<')
|
|
|
|
|
2018-09-24 11:40:05 +02:00
|
|
|
####################################################################
|
|
|
|
## privileged ######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: privileged
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
privileged: yes
|
|
|
|
state: started
|
|
|
|
register: privileged_1
|
|
|
|
|
|
|
|
- name: privileged (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
privileged: yes
|
|
|
|
state: started
|
|
|
|
register: privileged_2
|
|
|
|
|
|
|
|
- name: privileged (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
privileged: no
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: privileged_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- privileged_1 is changed
|
|
|
|
- privileged_2 is not changed
|
|
|
|
- privileged_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## published_ports #################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: published_ports
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
|
|
|
- 1234
|
|
|
|
- 5678
|
|
|
|
register: published_ports_1
|
|
|
|
|
|
|
|
- name: published_ports (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
|
|
|
- 5678
|
|
|
|
- 1234
|
|
|
|
register: published_ports_2
|
|
|
|
|
|
|
|
- name: published_ports (less published_ports)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
|
|
|
- 1234
|
|
|
|
register: published_ports_3
|
|
|
|
|
|
|
|
- name: published_ports (more published_ports)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
published_ports:
|
|
|
|
- 1234
|
|
|
|
- 2345
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: published_ports_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- published_ports_1 is changed
|
|
|
|
- published_ports_2 is not changed
|
|
|
|
- published_ports_3 is not changed
|
|
|
|
- published_ports_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## pull ############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# TODO: - pull
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## read_only #######################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: read_only
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
read_only: yes
|
|
|
|
state: started
|
|
|
|
register: read_only_1
|
|
|
|
|
|
|
|
- name: read_only (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
read_only: yes
|
|
|
|
state: started
|
|
|
|
register: read_only_2
|
|
|
|
|
|
|
|
- name: read_only (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
read_only: no
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: read_only_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- read_only_1 is changed
|
|
|
|
- read_only_2 is not changed
|
|
|
|
- read_only_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## recreate ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
2018-11-01 09:08:43 +01:00
|
|
|
- name: recreate (created)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
state: present
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: recreate_1
|
|
|
|
|
|
|
|
- name: recreate (created, recreate)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
recreate: yes
|
|
|
|
state: present
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: recreate_2
|
|
|
|
|
|
|
|
- name: recreate (started)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: recreate_3
|
|
|
|
|
|
|
|
- name: recreate (started, recreate)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
recreate: yes
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: recreate_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-11-01 09:08:43 +01:00
|
|
|
|
|
|
|
- debug: var=recreate_1
|
|
|
|
- debug: var=recreate_2
|
|
|
|
- debug: var=recreate_3
|
|
|
|
- debug: var=recreate_4
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- recreate_1 is changed
|
|
|
|
- recreate_2 is changed
|
|
|
|
- recreate_3 is changed
|
|
|
|
- recreate_4 is changed
|
2019-03-05 17:09:00 +01:00
|
|
|
- recreate_1.container.Id != recreate_2.container.Id
|
|
|
|
- recreate_2.container.Id == recreate_3.container.Id
|
|
|
|
- recreate_3.container.Id != recreate_4.container.Id
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## restart #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
2018-11-01 09:08:43 +01:00
|
|
|
- name: restart
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: restart_1
|
|
|
|
|
|
|
|
- name: restart (restart)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-11-01 09:08:43 +01:00
|
|
|
name: "{{ cname }}"
|
|
|
|
restart: yes
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-11-01 09:08:43 +01:00
|
|
|
register: restart_2
|
|
|
|
|
|
|
|
- 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-11-01 09:08:43 +01:00
|
|
|
|
|
|
|
- debug: var=restart_1
|
|
|
|
- debug: var=restart_2
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- restart_1 is changed
|
|
|
|
- restart_2 is changed
|
2019-03-05 17:09:00 +01:00
|
|
|
- restart_1.container.Id == restart_2.container.Id
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## restart_policy ##################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: restart_policy
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
restart_policy: always
|
|
|
|
state: started
|
|
|
|
register: restart_policy_1
|
|
|
|
|
|
|
|
- name: restart_policy (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
restart_policy: always
|
|
|
|
state: started
|
|
|
|
register: restart_policy_2
|
|
|
|
|
|
|
|
- name: restart_policy (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
restart_policy: unless-stopped
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: restart_policy_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- restart_policy_1 is changed
|
|
|
|
- restart_policy_2 is not changed
|
|
|
|
- restart_policy_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## restart_retries #################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: restart_retries
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
restart_policy: on-failure
|
|
|
|
restart_retries: 5
|
|
|
|
state: started
|
|
|
|
register: restart_retries_1
|
|
|
|
|
|
|
|
- name: restart_retries (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
restart_policy: on-failure
|
|
|
|
restart_retries: 5
|
|
|
|
state: started
|
|
|
|
register: restart_retries_2
|
|
|
|
|
|
|
|
- name: restart_retries (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
restart_policy: on-failure
|
|
|
|
restart_retries: 2
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: restart_retries_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- restart_retries_1 is changed
|
|
|
|
- restart_retries_2 is not changed
|
|
|
|
- restart_retries_3 is changed
|
|
|
|
|
2018-10-19 10:04:17 +02:00
|
|
|
####################################################################
|
|
|
|
## runtime #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: runtime
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-10-19 10:04:17 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
runtime: runc
|
|
|
|
state: started
|
|
|
|
register: runtime_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-19 10:04:17 +02:00
|
|
|
|
|
|
|
- name: runtime (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-10-19 10:04:17 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
runtime: runc
|
|
|
|
state: started
|
|
|
|
register: runtime_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-10-19 10:04:17 +02:00
|
|
|
|
|
|
|
- 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-19 10:04:17 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- runtime_1 is changed
|
|
|
|
- runtime_2 is not changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('2.4.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- runtime_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 2.4.0') in runtime_1.msg"
|
|
|
|
when: docker_py_version is version('2.4.0', '<')
|
2018-10-19 10:04:17 +02:00
|
|
|
|
2018-09-24 11:40:05 +02:00
|
|
|
####################################################################
|
|
|
|
## security_opts ###################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# In case some of the options stop working, here are some more
|
|
|
|
# options which *currently* work with all integration test targets:
|
|
|
|
# no-new-privileges
|
|
|
|
# label:disable
|
|
|
|
# label=disable
|
|
|
|
# label:level:s0:c100,c200
|
|
|
|
# label=level:s0:c100,c200
|
|
|
|
# label:type:svirt_apache_t
|
|
|
|
# label=type:svirt_apache_t
|
|
|
|
# label:user:root
|
|
|
|
# label=user:root
|
|
|
|
# seccomp:unconfined
|
|
|
|
# seccomp=unconfined
|
|
|
|
# apparmor:docker-default
|
|
|
|
# apparmor=docker-default
|
|
|
|
|
|
|
|
- name: security_opts
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
security_opts:
|
|
|
|
- "label:level:s0:c100,c200"
|
|
|
|
- "no-new-privileges"
|
|
|
|
register: security_opts_1
|
|
|
|
|
|
|
|
- name: security_opts (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
security_opts:
|
|
|
|
- "no-new-privileges"
|
|
|
|
- "label:level:s0:c100,c200"
|
|
|
|
register: security_opts_2
|
|
|
|
|
|
|
|
- name: security_opts (less security options)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
security_opts:
|
|
|
|
- "no-new-privileges"
|
|
|
|
register: security_opts_3
|
|
|
|
|
|
|
|
- name: security_opts (more security options)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
security_opts:
|
|
|
|
- "label:disable"
|
|
|
|
- "no-new-privileges"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: security_opts_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- security_opts_1 is changed
|
|
|
|
- security_opts_2 is not changed
|
|
|
|
- security_opts_3 is not changed
|
|
|
|
- security_opts_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## shm_size ########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: shm_size
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
shm_size: 96M
|
|
|
|
state: started
|
|
|
|
register: shm_size_1
|
|
|
|
|
|
|
|
- name: shm_size (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
shm_size: 96M
|
|
|
|
state: started
|
|
|
|
register: shm_size_2
|
|
|
|
|
|
|
|
- name: shm_size (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
shm_size: 75M
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: shm_size_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- shm_size_1 is changed
|
|
|
|
- shm_size_2 is not changed
|
|
|
|
- shm_size_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## stop_signal #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: stop_signal
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
stop_signal: 30
|
|
|
|
state: started
|
|
|
|
register: stop_signal_1
|
|
|
|
|
|
|
|
- name: stop_signal (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
stop_signal: 30
|
|
|
|
state: started
|
|
|
|
register: stop_signal_2
|
|
|
|
|
|
|
|
- name: stop_signal (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
stop_signal: 9
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: stop_signal_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- stop_signal_1 is changed
|
|
|
|
- stop_signal_2 is not changed
|
|
|
|
- stop_signal_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## stop_timeout ####################################################
|
|
|
|
####################################################################
|
|
|
|
|
2018-09-30 13:03:53 +02:00
|
|
|
- name: stop_timeout
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
stop_timeout: 2
|
|
|
|
state: started
|
|
|
|
register: stop_timeout_1
|
|
|
|
|
|
|
|
- name: stop_timeout (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
stop_timeout: 2
|
|
|
|
state: started
|
|
|
|
register: stop_timeout_2
|
|
|
|
|
|
|
|
- name: stop_timeout (no change)
|
|
|
|
# stop_timeout changes are ignored by default
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
stop_timeout: 1
|
|
|
|
state: started
|
|
|
|
register: stop_timeout_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-30 13:03:53 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- stop_timeout_1 is changed
|
|
|
|
- stop_timeout_2 is not changed
|
|
|
|
- stop_timeout_3 is not changed
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## sysctls #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# In case some of the options stop working, here are some more
|
|
|
|
# options which *currently* work with all integration test targets:
|
|
|
|
# net.ipv4.conf.default.log_martians: 1
|
|
|
|
# net.ipv4.conf.default.secure_redirects: 0
|
|
|
|
# net.ipv4.conf.default.send_redirects: 0
|
|
|
|
# net.ipv4.conf.all.log_martians: 1
|
|
|
|
# net.ipv4.conf.all.accept_redirects: 0
|
|
|
|
# net.ipv4.conf.all.secure_redirects: 0
|
|
|
|
# net.ipv4.conf.all.send_redirects: 0
|
|
|
|
|
|
|
|
- name: sysctls
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
sysctls:
|
|
|
|
net.ipv4.icmp_echo_ignore_all: 1
|
|
|
|
net.ipv4.ip_forward: 1
|
|
|
|
register: sysctls_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: sysctls (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
sysctls:
|
|
|
|
net.ipv4.ip_forward: 1
|
|
|
|
net.ipv4.icmp_echo_ignore_all: 1
|
|
|
|
register: sysctls_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: sysctls (less sysctls)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
sysctls:
|
|
|
|
net.ipv4.icmp_echo_ignore_all: 1
|
|
|
|
register: sysctls_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: sysctls (more sysctls)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
sysctls:
|
|
|
|
net.ipv4.icmp_echo_ignore_all: 1
|
|
|
|
net.ipv6.conf.default.accept_redirects: 0
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: sysctls_4
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- sysctls_1 is changed
|
|
|
|
- sysctls_2 is not changed
|
|
|
|
- sysctls_3 is not changed
|
|
|
|
- sysctls_4 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- sysctls_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.10.0') in sysctls_1.msg"
|
|
|
|
when: docker_py_version is version('1.10.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## tmpfs ###########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: tmpfs
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
tmpfs:
|
|
|
|
- "/test1:rw,noexec,nosuid,size=65536k"
|
|
|
|
- "/test2:rw,noexec,nosuid,size=65536k"
|
|
|
|
register: tmpfs_1
|
|
|
|
|
|
|
|
- name: tmpfs (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
tmpfs:
|
|
|
|
- "/test2:rw,noexec,nosuid,size=65536k"
|
|
|
|
- "/test1:rw,noexec,nosuid,size=65536k"
|
|
|
|
register: tmpfs_2
|
|
|
|
|
|
|
|
- name: tmpfs (less tmpfs)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
tmpfs:
|
|
|
|
- "/test1:rw,noexec,nosuid,size=65536k"
|
|
|
|
register: tmpfs_3
|
|
|
|
|
|
|
|
- name: tmpfs (more tmpfs)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
tmpfs:
|
|
|
|
- "/test1:rw,noexec,nosuid,size=65536k"
|
|
|
|
- "/test3:rw,noexec,nosuid,size=65536k"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: tmpfs_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- tmpfs_1 is changed
|
|
|
|
- tmpfs_2 is not changed
|
|
|
|
- tmpfs_3 is not changed
|
|
|
|
- tmpfs_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## trust_image_content #############################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# TODO: - trust_image_content
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## tty #############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: tty
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
tty: yes
|
|
|
|
state: started
|
|
|
|
register: tty_1
|
|
|
|
|
|
|
|
- name: tty (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
tty: yes
|
|
|
|
state: started
|
|
|
|
register: tty_2
|
|
|
|
|
|
|
|
- name: tty (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
tty: no
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: tty_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- tty_1 is changed
|
|
|
|
- tty_2 is not changed
|
|
|
|
- tty_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## ulimits #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: ulimits
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
ulimits:
|
|
|
|
- "nofile:1234:1234"
|
|
|
|
- "nproc:3:6"
|
|
|
|
register: ulimits_1
|
|
|
|
|
|
|
|
- name: ulimits (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
ulimits:
|
|
|
|
- "nproc:3:6"
|
|
|
|
- "nofile:1234:1234"
|
|
|
|
register: ulimits_2
|
|
|
|
|
|
|
|
- name: ulimits (less ulimits)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
ulimits:
|
|
|
|
- "nofile:1234:1234"
|
|
|
|
register: ulimits_3
|
|
|
|
|
|
|
|
- name: ulimits (more ulimits)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
ulimits:
|
|
|
|
- "nofile:1234:1234"
|
|
|
|
- "sigpending:100:200"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: ulimits_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- ulimits_1 is changed
|
|
|
|
- ulimits_2 is not changed
|
|
|
|
- ulimits_3 is not changed
|
|
|
|
- ulimits_4 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## user ############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: user
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
user: nobody
|
|
|
|
state: started
|
|
|
|
register: user_1
|
|
|
|
|
|
|
|
- name: user (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
user: nobody
|
|
|
|
state: started
|
|
|
|
register: user_2
|
|
|
|
|
|
|
|
- name: user (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
user: root
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: user_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- user_1 is changed
|
|
|
|
- user_2 is not changed
|
|
|
|
- user_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## userns_mode #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: userns_mode
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
userns_mode: host
|
|
|
|
state: started
|
|
|
|
register: userns_mode_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: userns_mode (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
userns_mode: host
|
|
|
|
state: started
|
|
|
|
register: userns_mode_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: userns_mode (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
userns_mode: ""
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: userns_mode_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- userns_mode_1 is changed
|
|
|
|
- userns_mode_2 is not changed
|
|
|
|
- userns_mode_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- userns_mode_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 1.10.0') in userns_mode_1.msg"
|
|
|
|
when: docker_py_version is version('1.10.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## uts #############################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: uts
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
uts: host
|
|
|
|
state: started
|
|
|
|
register: uts_1
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: uts (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
uts: host
|
|
|
|
state: started
|
|
|
|
register: uts_2
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- name: uts (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
uts: ""
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: uts_3
|
2018-11-05 01:25:11 +01:00
|
|
|
ignore_errors: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- uts_1 is changed
|
|
|
|
- uts_2 is not changed
|
|
|
|
- uts_3 is changed
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('3.5.0', '>=')
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- uts_1 is failed
|
|
|
|
- "('version is ' ~ docker_py_version ~'. Minimum version required is 3.5.0') in uts_1.msg"
|
|
|
|
when: docker_py_version is version('3.5.0', '<')
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## keep_volumes ####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
# TODO: - keep_volumes
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## volume_driver ###################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: volume_driver
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
volume_driver: local
|
|
|
|
state: started
|
|
|
|
register: volume_driver_1
|
|
|
|
|
|
|
|
- name: volume_driver (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
volume_driver: local
|
|
|
|
state: started
|
|
|
|
register: volume_driver_2
|
|
|
|
|
|
|
|
- name: volume_driver (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
volume_driver: /
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: volume_driver_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- volume_driver_1 is changed
|
|
|
|
- volume_driver_2 is not changed
|
|
|
|
- volume_driver_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## volumes #########################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: volumes
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes:
|
|
|
|
- "/tmp:/tmp"
|
2018-10-08 11:11:03 +02:00
|
|
|
- "/:/whatever:rw,z"
|
2018-09-24 11:40:05 +02:00
|
|
|
register: volumes_1
|
|
|
|
|
|
|
|
- name: volumes (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes:
|
2018-10-08 11:11:03 +02:00
|
|
|
- "/:/whatever:rw,z"
|
2018-09-24 11:40:05 +02:00
|
|
|
- "/tmp:/tmp"
|
|
|
|
register: volumes_2
|
|
|
|
|
|
|
|
- name: volumes (less volumes)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes:
|
|
|
|
- "/tmp:/tmp"
|
|
|
|
register: volumes_3
|
|
|
|
|
|
|
|
- name: volumes (more volumes)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes:
|
|
|
|
- "/tmp:/tmp"
|
2018-10-08 11:11:03 +02:00
|
|
|
- "/tmp:/somewhereelse:ro,Z"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: volumes_4
|
|
|
|
|
2018-10-08 11:11:03 +02:00
|
|
|
- name: volumes (different modes)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes:
|
|
|
|
- "/tmp:/tmp"
|
|
|
|
- "/tmp:/somewhereelse:ro"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-10-08 11:11:03 +02:00
|
|
|
register: volumes_5
|
|
|
|
|
2018-09-24 11:40:05 +02:00
|
|
|
- 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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- volumes_1 is changed
|
|
|
|
- volumes_2 is not changed
|
|
|
|
- volumes_3 is not changed
|
|
|
|
- volumes_4 is changed
|
2018-10-08 11:11:03 +02:00
|
|
|
- volumes_5 is changed
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## volumes_from ####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: start helpers
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: started
|
|
|
|
volumes:
|
|
|
|
- "{{ '/tmp:/tmp' if container_name == cname_h1 else '/:/whatever:ro' }}"
|
|
|
|
loop:
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
- "{{ cname_h2 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
|
|
|
|
|
|
|
- name: volumes_from
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes_from: "{{ cname_h1 }}"
|
|
|
|
register: volumes_from_1
|
|
|
|
|
|
|
|
- name: volumes_from (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes_from: "{{ cname_h1 }}"
|
|
|
|
register: volumes_from_2
|
|
|
|
|
|
|
|
- name: volumes_from (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
state: started
|
|
|
|
volumes_from: "{{ cname_h2 }}"
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: volumes_from_3
|
|
|
|
|
|
|
|
- name: cleanup
|
|
|
|
docker_container:
|
|
|
|
name: "{{ container_name }}"
|
|
|
|
state: absent
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
loop:
|
|
|
|
- "{{ cname }}"
|
|
|
|
- "{{ cname_h1 }}"
|
|
|
|
- "{{ cname_h2 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: container_name
|
2018-11-19 10:59:54 +01:00
|
|
|
diff: no
|
2018-09-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- volumes_from_1 is changed
|
|
|
|
- volumes_from_2 is not changed
|
|
|
|
- volumes_from_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
## working_dir #####################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: working_dir
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
working_dir: /tmp
|
|
|
|
state: started
|
|
|
|
register: working_dir_1
|
|
|
|
|
|
|
|
- name: working_dir (idempotency)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
2018-11-13 14:07:36 +01:00
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
2018-09-24 11:40:05 +02:00
|
|
|
name: "{{ cname }}"
|
|
|
|
working_dir: /tmp
|
|
|
|
state: started
|
|
|
|
register: working_dir_2
|
|
|
|
|
|
|
|
- name: working_dir (change)
|
|
|
|
docker_container:
|
|
|
|
image: alpine:3.8
|
|
|
|
command: '/bin/sh -c "sleep 10m"'
|
|
|
|
name: "{{ cname }}"
|
|
|
|
working_dir: /
|
|
|
|
state: started
|
2018-11-16 13:37:12 +01:00
|
|
|
force_kill: yes
|
2018-09-24 11:40:05 +02:00
|
|
|
register: working_dir_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-24 11:40:05 +02:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- working_dir_1 is changed
|
|
|
|
- working_dir_2 is not changed
|
|
|
|
- working_dir_3 is changed
|
|
|
|
|
|
|
|
####################################################################
|
|
|
|
####################################################################
|
|
|
|
####################################################################
|
|
|
|
|
|
|
|
- name: Delete networks
|
|
|
|
docker_network:
|
|
|
|
name: "{{ network_name }}"
|
|
|
|
state: absent
|
|
|
|
force: yes
|
|
|
|
loop:
|
|
|
|
- "{{ nname_1 }}"
|
|
|
|
- "{{ nname_2 }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: network_name
|
2018-11-05 01:25:11 +01:00
|
|
|
when: docker_py_version is version('1.10.0', '>=')
|