forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker_container, docker_image_facts: allow to use image IDs (ansible…
…#46324) * Allow to specify images by hash for docker_container and docker_image_facts. * flake8 * More sanity checks. * Added changelog. * Added test. * Make compatible with Python < 3.4. * Remove out-commented imports.
- Loading branch information
1 parent
895019c
commit a520ca3
Showing
7 changed files
with
143 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
minor_changes: | ||
- "docker_container - Allow to use image ID instead of image name." | ||
- "docker_image_facts - Allow to use image ID instead of image name." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
test/integration/targets/docker_container/tasks/tests/image-ids.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
- name: Registering container name | ||
set_fact: | ||
cname: "{{ cname_prefix ~ '-iid' }}" | ||
- name: Registering container name | ||
set_fact: | ||
cnames: "{{ cnames }} + [cname]" | ||
|
||
- name: Pull images | ||
docker_image: | ||
name: "{{ item }}" | ||
pull: true | ||
loop: | ||
- "hello-world:latest" | ||
- "alpine:3.8" | ||
|
||
- name: Get image ID of hello-world and alpine images | ||
docker_image_facts: | ||
name: | ||
- "hello-world:latest" | ||
- "alpine:3.8" | ||
register: image_facts | ||
|
||
- assert: | ||
that: | ||
- image_facts.images | length == 2 | ||
|
||
- name: Print image IDs | ||
debug: | ||
msg: "hello-world: {{ image_facts.images[0].Id }}; alpine: {{ image_facts.images[1].Id }}" | ||
|
||
- name: Create container with hello-world image via ID | ||
docker_container: | ||
image: "{{ image_facts.images[0].Id }}" | ||
name: "{{ cname }}" | ||
state: present | ||
register: create_1 | ||
|
||
- name: Create container with hello-world image via ID (idempotent) | ||
docker_container: | ||
image: "{{ image_facts.images[0].Id }}" | ||
name: "{{ cname }}" | ||
state: present | ||
register: create_2 | ||
|
||
- name: Create container with alpine image via ID | ||
docker_container: | ||
image: "{{ image_facts.images[1].Id }}" | ||
name: "{{ cname }}" | ||
state: present | ||
register: create_3 | ||
|
||
- name: Create container with alpine image via ID (idempotent) | ||
docker_container: | ||
image: "{{ image_facts.images[1].Id }}" | ||
name: "{{ cname }}" | ||
state: present | ||
register: create_4 | ||
|
||
- name: Cleanup | ||
docker_container: | ||
name: "{{ cname }}" | ||
state: absent | ||
stop_timeout: 1 | ||
|
||
- assert: | ||
that: | ||
- create_1 is changed | ||
- create_2 is not changed | ||
- create_3 is changed | ||
- create_4 is not changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters