Fix 'container_default_behavior: no_defaults'. (#66601)
This commit is contained in:
parent
2a9ec8975f
commit
f1a30164c5
2 changed files with 119 additions and 1 deletions
|
@ -2736,7 +2736,7 @@ class ContainerManager(DockerBaseClass):
|
||||||
self.container_stop(container.Id)
|
self.container_stop(container.Id)
|
||||||
container = self._get_container(container.Id)
|
container = self._get_container(container.Id)
|
||||||
|
|
||||||
if state == 'started' and container.paused is not None and container.paused != self.parameters.paused:
|
if state == 'started' and self.parameters.paused is not None and container.paused != self.parameters.paused:
|
||||||
self.diff_tracker.add('paused', parameter=self.parameters.paused, active=was_paused)
|
self.diff_tracker.add('paused', parameter=self.parameters.paused, active=was_paused)
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
---
|
||||||
|
- name: Registering container name
|
||||||
|
set_fact:
|
||||||
|
cname: "{{ cname_prefix ~ '-hi' }}"
|
||||||
|
- name: Registering container name
|
||||||
|
set_fact:
|
||||||
|
cnames: "{{ cnames + [cname] }}"
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
## container_default_behavior: compatibility #######################
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
- name: Start container (check)
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: compatibility
|
||||||
|
check_mode: yes
|
||||||
|
register: start_1
|
||||||
|
|
||||||
|
- name: Start container
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: compatibility
|
||||||
|
register: start_2
|
||||||
|
|
||||||
|
- name: Start container (idempotent)
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: compatibility
|
||||||
|
register: start_3
|
||||||
|
|
||||||
|
- name: Start container (idempotent check)
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
state: started
|
||||||
|
container_default_behavior: compatibility
|
||||||
|
check_mode: yes
|
||||||
|
register: start_4
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: absent
|
||||||
|
force_kill: yes
|
||||||
|
diff: no
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- start_1 is changed
|
||||||
|
- start_2 is changed
|
||||||
|
- start_3 is not changed
|
||||||
|
- start_4 is not changed
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
## container_default_behavior: no_defaults #########################
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
- name: Start container (check)
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: no_defaults
|
||||||
|
check_mode: yes
|
||||||
|
register: start_1
|
||||||
|
|
||||||
|
- name: Start container
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: no_defaults
|
||||||
|
register: start_2
|
||||||
|
|
||||||
|
- name: Start container (idempotent)
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: no_defaults
|
||||||
|
register: start_3
|
||||||
|
|
||||||
|
- name: Start container (idempotent check)
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
image: alpine:3.8
|
||||||
|
command: '/bin/sh -c "sleep 10m"'
|
||||||
|
state: started
|
||||||
|
container_default_behavior: no_defaults
|
||||||
|
check_mode: yes
|
||||||
|
register: start_4
|
||||||
|
|
||||||
|
- name: cleanup
|
||||||
|
docker_container:
|
||||||
|
name: "{{ cname }}"
|
||||||
|
state: absent
|
||||||
|
force_kill: yes
|
||||||
|
diff: no
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- start_1 is changed
|
||||||
|
- start_2 is changed
|
||||||
|
- start_3 is not changed
|
||||||
|
- start_4 is not changed
|
Loading…
Reference in a new issue