Fix linting errors.

This commit is contained in:
Felix Fontein
2025-04-26 11:20:32 +02:00
parent 795e6b23dc
commit 2487d1a0bf
125 changed files with 5778 additions and 5662 deletions
+5 -5
View File
@@ -4,8 +4,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
collections:
- ansible.posix
- community.crypto
- community.general
- community.internal_test_tools
- community.library_inventory_filtering_v1
- ansible.posix
- community.crypto
- community.general
- community.internal_test_tools
- community.library_inventory_filtering_v1
@@ -8,41 +8,41 @@
serial: 1
tasks:
### raw with unicode arg and output
### raw with unicode arg and output
- name: raw with unicode arg and output
raw: echo 汉语
register: command
- name: check output of raw with unicode arg and output
assert:
that:
- "'汉语' in command.stdout"
- command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
- name: raw with unicode arg and output
raw: echo 汉语
register: command
- name: check output of raw with unicode arg and output
assert:
that:
- "'汉语' in command.stdout"
- command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
### copy local file with unicode filename and content
### copy local file with unicode filename and content
- name: create local file with unicode filename and content
local_action: lineinfile dest={{ local_tmp }}-汉语/汉语.txt create=true line=汉语
- name: remove remote file with unicode filename and content
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/汉语.txt state=absent"
- name: create remote directory with unicode name
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
- name: copy local file with unicode filename and content
action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/汉语.txt dest={{ remote_tmp }}-汉语/汉语.txt"
- name: create local file with unicode filename and content
local_action: lineinfile dest={{ local_tmp }}-汉语/汉语.txt create=true line=汉语
- name: remove remote file with unicode filename and content
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/汉语.txt state=absent"
- name: create remote directory with unicode name
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
- name: copy local file with unicode filename and content
action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/汉语.txt dest={{ remote_tmp }}-汉语/汉语.txt"
### fetch remote file with unicode filename and content
### fetch remote file with unicode filename and content
- name: remove local file with unicode filename and content
local_action: file path={{ local_tmp }}-汉语/汉语.txt state=absent
- name: fetch remote file with unicode filename and content
fetch: src={{ remote_tmp }}-汉语/汉语.txt dest={{ local_tmp }}-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
- name: remove local file with unicode filename and content
local_action: file path={{ local_tmp }}-汉语/汉语.txt state=absent
- name: fetch remote file with unicode filename and content
fetch: src={{ remote_tmp }}-汉语/汉语.txt dest={{ local_tmp }}-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
### remove local and remote temp files
### remove local and remote temp files
- name: remove local temp file
local_action: file path={{ local_tmp }}-汉语 state=absent
- name: remove remote temp file
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
- name: remove local temp file
local_action: file path={{ local_tmp }}-汉语 state=absent
- name: remove remote temp file
action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
### test wait_for_connection plugin
- ansible.builtin.wait_for_connection:
### test wait_for_connection plugin
- ansible.builtin.wait_for_connection:
@@ -67,4 +67,4 @@
- present_1.images[0].Tag == (docker_test_image_alpine | split(':') | last)
- present_1.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- >-
("container " ~ pname ~ '-' ~ cname ~ "-1 exited (0)") in present_1.msg
("container " ~ pname ~ '-' ~ cname ~ "-1 exited (0)") in present_1.msg
@@ -4,313 +4,131 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
- shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
- shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
- name: Create a Swarm cluster
docker_swarm:
name: default
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Parameter name should be required
docker_config:
state: present
ignore_errors: true
register: output
- name: Assert failure when called with no name
assert:
that:
- 'output is failed'
- 'output.msg == "missing required arguments: name"'
- name: Test parameters
docker_config:
name: foo
state: present
ignore_errors: true
register: output
- name: Assert failure when called with no data
assert:
that:
- 'output is failed'
- 'output.msg == "state is present but any of the following are missing: data, data_src"'
- name: Create config
docker_config:
name: db_password
data: opensesame!
state: present
register: output
- name: Create variable config_id
set_fact:
config_id: "{{ output.config_id }}"
- name: Inspect config
command: "docker config inspect {{ config_id }}"
register: inspect
ignore_errors: true
- debug:
var: inspect
- name: Assert config creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: Create config again
docker_config:
name: db_password
data: opensesame!
state: present
register: output
- name: Assert create config is idempotent
assert:
that:
- output is not changed
- name: Write config into file
copy:
dest: "{{ remote_tmp_dir }}/data"
content: |-
opensesame!
- name: Create config again (from file)
docker_config:
name: db_password
data_src: "{{ remote_tmp_dir }}/data"
state: present
register: output
- name: Assert create config is idempotent
assert:
that:
- output is not changed
- name: Create config again (base64)
docker_config:
name: db_password
data: b3BlbnNlc2FtZSE=
data_is_b64: true
state: present
register: output
- name: Assert create config (base64) is idempotent
assert:
that:
- output is not changed
- name: Update config
docker_config:
name: db_password
data: newpassword!
state: present
register: output
- name: Assert config was updated
assert:
that:
- output is changed
- output.config_id != config_id
- name: Remove config
docker_config:
name: db_password
state: absent
- name: Check that config is removed
command: "docker config inspect {{ config_id }}"
register: output
ignore_errors: true
- name: Assert config was removed
assert:
that:
- output is failed
- name: Remove config
docker_config:
name: db_password
state: absent
register: output
- name: Assert remove config is idempotent
assert:
that:
- output is not changed
# Rolling update
- name: Create rolling config
docker_config:
name: rolling_password
data: opensesame!
rolling_versions: true
state: present
register: original_output
- name: Create variable config_id
set_fact:
config_id: "{{ original_output.config_id }}"
- name: Inspect config
command: "docker config inspect {{ config_id }}"
register: inspect
ignore_errors: true
- debug:
var: inspect
- name: Assert config creation succeeded
assert:
that:
- "'rolling_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
- "'ansible_version' in inspect.stdout"
- original_output.config_name == 'rolling_password_v1'
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: Create config again
docker_config:
name: rolling_password
data: newpassword!
rolling_versions: true
state: present
register: new_output
- name: Assert that new version is created
assert:
that:
- new_output is changed
- new_output.config_id != original_output.config_id
- new_output.config_name != original_output.config_name
- new_output.config_name == 'rolling_password_v2'
- name: Remove rolling configs
docker_config:
name: rolling_password
rolling_versions: true
state: absent
- name: Check that config is removed
command: "docker config inspect {{ original_output.config_id }}"
register: output
ignore_errors: true
- name: Assert config was removed
assert:
that:
- output is failed
- name: Check that config is removed
command: "docker config inspect {{ new_output.config_id }}"
register: output
ignore_errors: true
- name: Assert config was removed
assert:
that:
- output is failed
# template_driver tests
- when: docker_py_version is version('5.0.3', '>=') and docker_api_version is version('1.37', '>=')
block:
- name: Create regular config
docker_config:
name: db_password
data: opensesame!
- name: Create a Swarm cluster
docker_swarm:
name: default
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Update config with template_driver
- name: Parameter name should be required
docker_config:
name: db_password
data: opensesame!
template_driver: golang
state: present
register: output
- name: Assert config was updated
assert:
that:
- output is changed
- name: Invalid template_driver
docker_config:
name: db_password
data: opensesame!
template_driver: "not a template driver"
state: present
ignore_errors: true
register: output
- name: Assert failure when called with invalid template_driver
- name: Assert failure when called with no name
assert:
that:
- 'output is failed'
- 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"'
- 'output is failed'
- 'output.msg == "missing required arguments: name"'
- name: Test parameters
docker_config:
name: foo
state: present
ignore_errors: true
register: output
- name: Assert failure when called with no data
assert:
that:
- 'output is failed'
- 'output.msg == "state is present but any of the following are missing: data, data_src"'
- name: Create config
docker_config:
name: db_password
data: opensesame!
state: present
register: output
- name: Create variable config_id
set_fact:
config_id: "{{ output.config_id }}"
- name: Inspect config
command: "docker config inspect {{ config_id }}"
register: inspect
ignore_errors: true
- debug:
var: inspect
- name: Assert config creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: Create config again
docker_config:
name: db_password
data: opensesame!
template_driver: golang
state: present
register: output
- name: Assert create config is idempotent
assert:
that:
- output is not changed
- output is not changed
# data is the docker swarm's name
- name: Update config with template data
- name: Write config into file
copy:
dest: "{{ remote_tmp_dir }}/data"
content: |-
opensesame!
- name: Create config again (from file)
docker_config:
name: db_password
data: "{{ '{{' }} .Service.Name {{ '}}' }}"
template_driver: golang
data_src: "{{ remote_tmp_dir }}/data"
state: present
register: output
- name: Inspect config
command: "docker config inspect {{ output.config_id }}"
register: inspect
- name: Show inspection result
debug:
var: inspect
- name: Assert config creation succeeded
- name: Assert create config is idempotent
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
# According to the API docs, 'Data' is "Base64-url-safe-encoded (RFC 4648) config data."
- "'\"Data\": \"e3sgLlNlcnZpY2UuTmFtZSB9fQ==\"' in inspect.stdout"
- "'Templating' in inspect.stdout"
- "'\"Name\": \"golang\"' in inspect.stdout"
- output is not changed
- name: Create config again (base64)
docker_config:
name: db_password
data: b3BlbnNlc2FtZSE=
data_is_b64: true
state: present
register: output
- name: Assert create config (base64) is idempotent
assert:
that:
- output is not changed
- name: Update config
docker_config:
name: db_password
data: newpassword!
state: present
register: output
- name: Assert config was updated
assert:
that:
- output is changed
- output.config_id != config_id
- name: Remove config
docker_config:
@@ -318,7 +136,7 @@
state: absent
- name: Check that config is removed
command: "docker config inspect {{ output.config_id }}"
command: "docker config inspect {{ config_id }}"
register: output
ignore_errors: true
@@ -327,8 +145,190 @@
that:
- output is failed
- name: Remove config
docker_config:
name: db_password
state: absent
register: output
- name: Assert remove config is idempotent
assert:
that:
- output is not changed
# Rolling update
- name: Create rolling config
docker_config:
name: rolling_password
data: opensesame!
rolling_versions: true
state: present
register: original_output
- name: Create variable config_id
set_fact:
config_id: "{{ original_output.config_id }}"
- name: Inspect config
command: "docker config inspect {{ config_id }}"
register: inspect
ignore_errors: true
- debug:
var: inspect
- name: Assert config creation succeeded
assert:
that:
- "'rolling_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
- "'ansible_version' in inspect.stdout"
- original_output.config_name == 'rolling_password_v1'
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: Create config again
docker_config:
name: rolling_password
data: newpassword!
rolling_versions: true
state: present
register: new_output
- name: Assert that new version is created
assert:
that:
- new_output is changed
- new_output.config_id != original_output.config_id
- new_output.config_name != original_output.config_name
- new_output.config_name == 'rolling_password_v2'
- name: Remove rolling configs
docker_config:
name: rolling_password
rolling_versions: true
state: absent
- name: Check that config is removed
command: "docker config inspect {{ original_output.config_id }}"
register: output
ignore_errors: true
- name: Assert config was removed
assert:
that:
- output is failed
- name: Check that config is removed
command: "docker config inspect {{ new_output.config_id }}"
register: output
ignore_errors: true
- name: Assert config was removed
assert:
that:
- output is failed
# template_driver tests
- when: docker_py_version is version('5.0.3', '>=') and docker_api_version is version('1.37', '>=')
block:
- name: Create regular config
docker_config:
name: db_password
data: opensesame!
state: present
- name: Update config with template_driver
docker_config:
name: db_password
data: opensesame!
template_driver: golang
state: present
register: output
- name: Assert config was updated
assert:
that:
- output is changed
- name: Invalid template_driver
docker_config:
name: db_password
data: opensesame!
template_driver: "not a template driver"
state: present
ignore_errors: true
register: output
- name: Assert failure when called with invalid template_driver
assert:
that:
- 'output is failed'
- 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"'
- name: Create config again
docker_config:
name: db_password
data: opensesame!
template_driver: golang
state: present
register: output
- name: Assert create config is idempotent
assert:
that:
- output is not changed
# data is the docker swarm's name
- name: Update config with template data
docker_config:
name: db_password
data: "{{ '{{' }} .Service.Name {{ '}}' }}"
template_driver: golang
state: present
register: output
- name: Inspect config
command: "docker config inspect {{ output.config_id }}"
register: inspect
- name: Show inspection result
debug:
var: inspect
- name: Assert config creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
# According to the API docs, 'Data' is "Base64-url-safe-encoded (RFC 4648) config data."
- "'\"Data\": \"e3sgLlNlcnZpY2UuTmFtZSB9fQ==\"' in inspect.stdout"
- "'Templating' in inspect.stdout"
- "'\"Name\": \"golang\"' in inspect.stdout"
- name: Remove config
docker_config:
name: db_password
state: absent
- name: Check that config is removed
command: "docker config inspect {{ output.config_id }}"
register: output
ignore_errors: true
- name: Assert config was removed
assert:
that:
- output is failed
always:
- name: Remove a Swarm cluster
docker_swarm:
state: absent
force: true
- name: Remove a Swarm cluster
docker_swarm:
state: absent
force: true
@@ -56,9 +56,9 @@
- assert:
that:
- value_1 is changed
- value_2 is not changed
- value_3 is changed
- value_1 is changed
- value_2 is not changed
- value_3 is changed
####################################################################
## list ############################################################
@@ -71,8 +71,8 @@
name: "{{ cname }}"
state: started
dns_servers:
- 1.1.1.1
- 8.8.8.8
- 1.1.1.1
- 8.8.8.8
register: list_1
- name: list (change, ignore)
@@ -82,7 +82,7 @@
name: "{{ cname }}"
state: started
dns_servers:
- 9.9.9.9
- 9.9.9.9
force_kill: true
comparisons:
dns_servers: ignore
@@ -95,7 +95,7 @@
name: "{{ cname }}"
state: started
dns_servers:
- 9.9.9.9
- 9.9.9.9
force_kill: true
comparisons:
dns_servers: strict
@@ -110,9 +110,9 @@
- assert:
that:
- list_1 is changed
- list_2 is not changed
- list_3 is changed
- list_1 is changed
- list_2 is not changed
- list_3 is changed
####################################################################
## set #############################################################
@@ -125,8 +125,8 @@
name: "{{ cname }}"
state: started
groups:
- "1010"
- "1011"
- "1010"
- "1011"
register: set_1
- name: set (change, ignore)
@@ -136,9 +136,9 @@
name: "{{ cname }}"
state: started
groups:
- "1010"
- "1011"
- "1012"
- "1010"
- "1011"
- "1012"
force_kill: true
comparisons:
groups: ignore
@@ -151,9 +151,9 @@
name: "{{ cname }}"
state: started
groups:
- "1010"
- "1011"
- "1012"
- "1010"
- "1011"
- "1012"
force_kill: true
comparisons:
groups: allow_more_present
@@ -166,8 +166,8 @@
name: "{{ cname }}"
state: started
groups:
- "1010"
- "1012"
- "1010"
- "1012"
force_kill: true
comparisons:
groups: allow_more_present
@@ -180,8 +180,8 @@
name: "{{ cname }}"
state: started
groups:
- "1010"
- "1012"
- "1010"
- "1012"
force_kill: true
comparisons:
groups: strict
@@ -196,11 +196,11 @@
- assert:
that:
- set_1 is changed
- set_2 is not changed
- set_3 is changed
- set_4 is not changed
- set_5 is changed
- set_1 is changed
- set_2 is not changed
- set_3 is changed
- set_4 is not changed
- set_5 is changed
####################################################################
## set(dict) #######################################################
@@ -213,8 +213,8 @@
name: "{{ cname }}"
state: started
devices:
- "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm"
register: set_dict_1
- name: set(dict) (change, ignore)
@@ -224,9 +224,9 @@
name: "{{ cname }}"
state: started
devices:
- "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/null:/dev/virt-null:rwm"
- "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/null:/dev/virt-null:rwm"
force_kill: true
comparisons:
devices: ignore
@@ -239,9 +239,9 @@
name: "{{ cname }}"
state: started
devices:
- "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/null:/dev/virt-null:rwm"
- "/dev/random:/dev/virt-random:rwm"
- "/dev/urandom:/dev/virt-urandom:rwm"
- "/dev/null:/dev/virt-null:rwm"
force_kill: true
comparisons:
devices: allow_more_present
@@ -254,8 +254,8 @@
name: "{{ cname }}"
state: started
devices:
- "/dev/random:/dev/virt-random:rwm"
- "/dev/null:/dev/virt-null:rwm"
- "/dev/random:/dev/virt-random:rwm"
- "/dev/null:/dev/virt-null:rwm"
force_kill: true
comparisons:
devices: allow_more_present
@@ -268,8 +268,8 @@
name: "{{ cname }}"
state: started
devices:
- "/dev/random:/dev/virt-random:rwm"
- "/dev/null:/dev/virt-null:rwm"
- "/dev/random:/dev/virt-random:rwm"
- "/dev/null:/dev/virt-null:rwm"
force_kill: true
comparisons:
devices: strict
@@ -284,11 +284,11 @@
- assert:
that:
- set_dict_1 is changed
- set_dict_2 is not changed
- set_dict_3 is changed
- set_dict_4 is not changed
- set_dict_5 is changed
- set_dict_1 is changed
- set_dict_2 is not changed
- set_dict_3 is changed
- set_dict_4 is not changed
- set_dict_5 is changed
####################################################################
## dict ############################################################
@@ -372,11 +372,11 @@
- assert:
that:
- dict_1 is changed
- dict_2 is not changed
- dict_3 is changed
- dict_4 is not changed
- dict_5 is changed
- dict_1 is changed
- dict_2 is not changed
- dict_3 is changed
- dict_4 is not changed
- dict_5 is changed
####################################################################
## wildcard ########################################################
@@ -460,7 +460,7 @@
- assert:
that:
- wildcard_1 is changed
- wildcard_2 is not changed
- wildcard_3 is changed
- wildcard_4 is not changed
- wildcard_1 is changed
- wildcard_2 is not changed
- wildcard_3 is changed
- wildcard_4 is not changed
@@ -60,10 +60,10 @@
- assert:
that:
- start_1 is changed
- start_2 is changed
- start_3 is not changed
- start_4 is not changed
- start_1 is changed
- start_2 is changed
- start_3 is not changed
- start_4 is not changed
####################################################################
## container_default_behavior: no_defaults #########################
@@ -116,7 +116,7 @@
- assert:
that:
- start_1 is changed
- start_2 is changed
- start_3 is not changed
- start_4 is not changed
- start_1 is changed
- start_2 is changed
- start_3 is not changed
- start_4 is not changed
@@ -22,8 +22,8 @@
- name: Get image ID of {{ docker_test_image_hello_world }} and {{ docker_test_image_alpine }} images
docker_image_info:
name:
- "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}"
- "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}"
register: image_info
- assert:
@@ -29,13 +29,13 @@
name: "{{ cname }}"
state: started
mounts:
- source: /tmp
target: /tmp
type: bind
- source: /
target: /whatever
type: bind
read_only: false
- source: /tmp
target: /tmp
type: bind
- source: /
target: /whatever
type: bind
read_only: false
register: mounts_1
- name: mounts (idempotency)
@@ -45,13 +45,13 @@
name: "{{ cname }}"
state: started
mounts:
- source: /
target: /whatever
type: bind
read_only: false
- source: /tmp
target: /tmp
type: bind
- source: /
target: /whatever
type: bind
read_only: false
- source: /tmp
target: /tmp
type: bind
register: mounts_2
- name: mounts (less mounts)
@@ -61,9 +61,9 @@
name: "{{ cname }}"
state: started
mounts:
- source: /tmp
target: /tmp
type: bind
- source: /tmp
target: /tmp
type: bind
register: mounts_3
- name: mounts (more mounts)
@@ -73,13 +73,13 @@
name: "{{ cname }}"
state: started
mounts:
- source: /tmp
target: /tmp
type: bind
- source: /tmp
target: /somewhereelse
type: bind
read_only: true
- source: /tmp
target: /tmp
type: bind
- source: /tmp
target: /somewhereelse
type: bind
read_only: true
force_kill: true
register: mounts_4
@@ -90,13 +90,13 @@
name: "{{ cname }}"
state: started
mounts:
- source: /tmp
target: /tmp
type: bind
- source: /tmp
target: /somewhereelse
type: bind
read_only: false
- source: /tmp
target: /tmp
type: bind
- source: /tmp
target: /somewhereelse
type: bind
read_only: false
force_kill: true
register: mounts_5
@@ -107,13 +107,13 @@
name: "{{ cname }}"
state: started
mounts:
- source: /home
target: /x
type: bind
- source: /etc
target: /x
type: bind
read_only: false
- source: /home
target: /x
type: bind
- source: /etc
target: /x
type: bind
read_only: false
force_kill: true
register: mounts_6
ignore_errors: true
@@ -151,15 +151,15 @@
- assert:
that:
- mounts_1 is changed
- mounts_2 is not changed
- mounts_3 is not changed
- mounts_4 is changed
- mounts_5 is changed
- mounts_6 is failed
- "'The mount point \"/x\" appears twice in the mounts option' == mounts_6.msg"
- mounts_7 is changed
- mounts_8 is not changed
- mounts_1 is changed
- mounts_2 is not changed
- mounts_3 is not changed
- mounts_4 is changed
- mounts_5 is changed
- mounts_6 is failed
- "'The mount point \"/x\" appears twice in the mounts option' == mounts_6.msg"
- mounts_7 is changed
- mounts_8 is not changed
####################################################################
## tmpfs ###########################################################
@@ -172,14 +172,14 @@
name: "{{ cname }}"
state: started
mounts:
- target: /cache1
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache2
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache1
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache2
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
force_kill: true
register: tmpfs_1
@@ -190,14 +190,14 @@
name: "{{ cname }}"
state: started
mounts:
- target: /cache2
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache1
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache2
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache1
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
force_kill: true
register: tmpfs_2
@@ -208,18 +208,18 @@
name: "{{ cname }}"
state: started
mounts:
- target: /cache1
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache2
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache3
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache1
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache2
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
- target: /cache3
type: tmpfs
tmpfs_mode: "1777"
tmpfs_size: "1GB"
force_kill: true
register: tmpfs_3
@@ -230,10 +230,10 @@
name: "{{ cname }}"
state: started
mounts:
- target: /cache1
type: tmpfs
tmpfs_mode: "1700"
tmpfs_size: "1GB"
- target: /cache1
type: tmpfs
tmpfs_mode: "1700"
tmpfs_size: "1GB"
force_kill: true
register: tmpfs_4
@@ -244,10 +244,10 @@
name: "{{ cname }}"
state: started
mounts:
- target: /cache1
type: tmpfs
tmpfs_mode: "1700"
tmpfs_size: "2GB"
- target: /cache1
type: tmpfs
tmpfs_mode: "1700"
tmpfs_size: "2GB"
force_kill: true
register: tmpfs_5
@@ -260,11 +260,11 @@
- assert:
that:
- tmpfs_1 is changed
- tmpfs_2 is not changed
- tmpfs_3 is changed
- tmpfs_4 is changed
- tmpfs_5 is changed
- tmpfs_1 is changed
- tmpfs_2 is not changed
- tmpfs_3 is changed
- tmpfs_4 is changed
- tmpfs_5 is changed
####################################################################
## mounts + volumes ################################################
@@ -277,12 +277,12 @@
name: "{{ cname }}"
state: started
mounts:
- source: /
target: /whatever
type: bind
read_only: true
- source: /
target: /whatever
type: bind
read_only: true
volumes:
- /tmp:/tmp
- /tmp:/tmp
register: mounts_volumes_1
- name: mounts + volumes (idempotency)
@@ -292,12 +292,12 @@
name: "{{ cname }}"
state: started
mounts:
- source: /
target: /whatever
type: bind
read_only: true
- source: /
target: /whatever
type: bind
read_only: true
volumes:
- /tmp:/tmp
- /tmp:/tmp
register: mounts_volumes_2
- name: mounts + volumes (switching)
@@ -307,12 +307,12 @@
name: "{{ cname }}"
state: started
mounts:
- source: /tmp
target: /tmp
type: bind
read_only: false
- source: /tmp
target: /tmp
type: bind
read_only: false
volumes:
- /:/whatever:ro
- /:/whatever:ro
force_kill: true
register: mounts_volumes_3
@@ -323,12 +323,12 @@
name: "{{ cname }}"
state: started
mounts:
- source: /tmp
target: /tmp
type: bind
read_only: false
- source: /tmp
target: /tmp
type: bind
read_only: false
volumes:
- /tmp:/tmp
- /tmp:/tmp
force_kill: true
register: mounts_volumes_4
ignore_errors: true
@@ -342,11 +342,11 @@
- assert:
that:
- mounts_volumes_1 is changed
- mounts_volumes_2 is not changed
- mounts_volumes_3 is changed
- mounts_volumes_4 is failed
- "'The mount point \"/tmp\" appears both in the volumes and mounts option' in mounts_volumes_4.msg"
- mounts_volumes_1 is changed
- mounts_volumes_2 is not changed
- mounts_volumes_3 is changed
- mounts_volumes_4 is failed
- "'The mount point \"/tmp\" appears both in the volumes and mounts option' in mounts_volumes_4.msg"
####################################################################
## volume_driver ###################################################
@@ -389,9 +389,9 @@
- assert:
that:
- volume_driver_1 is changed
- volume_driver_2 is not changed
- volume_driver_3 is changed
- volume_driver_1 is changed
- volume_driver_2 is not changed
- volume_driver_3 is changed
####################################################################
## volumes #########################################################
@@ -404,9 +404,9 @@
name: "{{ cname }}"
state: started
volumes:
- "/tmp:/tmp"
- "/:/whatever:rw,z"
- "/anon:rw"
- "/tmp:/tmp"
- "/:/whatever:rw,z"
- "/anon:rw"
register: volumes_1
- name: volumes (idempotency)
@@ -416,9 +416,9 @@
name: "{{ cname }}"
state: started
volumes:
- "/:/whatever:rw,z"
- "/tmp:/tmp"
- "/anon:rw"
- "/:/whatever:rw,z"
- "/tmp:/tmp"
- "/anon:rw"
register: volumes_2
- name: volumes (less volumes)
@@ -428,7 +428,7 @@
name: "{{ cname }}"
state: started
volumes:
- "/tmp:/tmp"
- "/tmp:/tmp"
register: volumes_3
- name: volumes (more volumes)
@@ -438,8 +438,8 @@
name: "{{ cname }}"
state: started
volumes:
- "/tmp:/tmp"
- "/tmp:/somewhereelse:ro,Z"
- "/tmp:/tmp"
- "/tmp:/somewhereelse:ro,Z"
force_kill: true
register: volumes_4
@@ -450,8 +450,8 @@
name: "{{ cname }}"
state: started
volumes:
- "/tmp:/tmp"
- "/tmp:/somewhereelse:ro"
- "/tmp:/tmp"
- "/tmp:/somewhereelse:ro"
force_kill: true
register: volumes_5
@@ -462,8 +462,8 @@
name: "{{ cname }}"
state: started
volumes:
- "/etc:/tmp"
- "/home:/tmp:ro"
- "/etc:/tmp"
- "/home:/tmp:ro"
force_kill: true
register: volumes_6
ignore_errors: true
@@ -477,16 +477,16 @@
- assert:
that:
- volumes_1 is changed
- volumes_1.container.Config.Volumes | length == 1
- volumes_1.container.Config.Volumes['/anon:rw'] | length == 0
- volumes_2 is not changed
- volumes_3 is not changed
- volumes_4 is changed
- not volumes_4.container.Config.Volumes
- volumes_5 is changed
- volumes_6 is failed
- "'The mount point \"/tmp\" appears twice in the volumes option' in volumes_6.msg"
- volumes_1 is changed
- volumes_1.container.Config.Volumes | length == 1
- volumes_1.container.Config.Volumes['/anon:rw'] | length == 0
- volumes_2 is not changed
- volumes_3 is not changed
- volumes_4 is changed
- not volumes_4.container.Config.Volumes
- volumes_5 is changed
- volumes_6 is failed
- "'The mount point \"/tmp\" appears twice in the volumes option' in volumes_6.msg"
####################################################################
## volumes_from ####################################################
@@ -499,10 +499,10 @@
name: "{{ container_name }}"
state: started
volumes:
- "{{ '/tmp:/tmp' if container_name == cname_h1 else '/:/whatever:ro' }}"
- "{{ '/tmp:/tmp' if container_name == cname_h1 else '/:/whatever:ro' }}"
loop:
- "{{ cname_h1 }}"
- "{{ cname_h2 }}"
- "{{ cname_h1 }}"
- "{{ cname_h2 }}"
loop_control:
loop_var: container_name
@@ -540,18 +540,18 @@
state: absent
force_kill: true
loop:
- "{{ cname }}"
- "{{ cname_h1 }}"
- "{{ cname_h2 }}"
- "{{ cname }}"
- "{{ cname_h1 }}"
- "{{ cname_h2 }}"
loop_control:
loop_var: container_name
diff: false
- assert:
that:
- volumes_from_1 is changed
- volumes_from_2 is not changed
- volumes_from_3 is changed
- volumes_from_1 is changed
- volumes_from_2 is not changed
- volumes_from_3 is changed
####################################################################
####################################################################
@@ -20,8 +20,8 @@
name: "{{ network_name }}"
state: present
loop:
- "{{ nname_1 }}"
- "{{ nname_2 }}"
- "{{ nname_1 }}"
- "{{ nname_2 }}"
loop_control:
loop_var: network_name
@@ -126,24 +126,24 @@
state: absent
force_kill: true
loop:
- "{{ cname }}"
- "{{ cname_h1 }}"
- "{{ cname }}"
- "{{ cname_h1 }}"
loop_control:
loop_var: container_name
diff: false
- assert:
that:
- network_mode_1 is changed
- network_mode_1.container.HostConfig.NetworkMode == 'host'
- network_mode_2 is not changed
- network_mode_2.container.HostConfig.NetworkMode == 'host'
- network_mode_3 is changed
- network_mode_3.container.HostConfig.NetworkMode == 'none'
- network_mode_4 is changed
- network_mode_4.container.HostConfig.NetworkMode == ('container:' ~ cname_h1_id.container.Id)
- network_mode_5 is not changed
- network_mode_5.container.HostConfig.NetworkMode == ('container:' ~ cname_h1_id.container.Id)
- network_mode_1 is changed
- network_mode_1.container.HostConfig.NetworkMode == 'host'
- network_mode_2 is not changed
- network_mode_2.container.HostConfig.NetworkMode == 'host'
- network_mode_3 is changed
- network_mode_3.container.HostConfig.NetworkMode == 'none'
- network_mode_4 is changed
- network_mode_4.container.HostConfig.NetworkMode == ('container:' ~ cname_h1_id.container.Id)
- network_mode_5 is not changed
- network_mode_5.container.HostConfig.NetworkMode == ('container:' ~ cname_h1_id.container.Id)
####################################################################
## networks, purge_networks for networks_cli_compatible=no #########
@@ -156,8 +156,8 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_1 }}"
- name: "{{ nname_2 }}"
- name: "{{ nname_1 }}"
- name: "{{ nname_2 }}"
networks_cli_compatible: false
register: networks_1
@@ -168,8 +168,8 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_1 }}"
- name: "{{ nname_2 }}"
- name: "{{ nname_1 }}"
- name: "{{ nname_2 }}"
networks_cli_compatible: false
register: networks_2
@@ -182,8 +182,8 @@
comparisons:
networks: strict
networks:
- name: bridge
- name: "{{ nname_1 }}"
- name: bridge
- name: "{{ nname_1 }}"
networks_cli_compatible: false
force_kill: true
register: networks_3
@@ -197,8 +197,8 @@
comparisons:
networks: strict
networks:
- name: "{{ nname_1 }}"
- name: bridge
- name: "{{ nname_1 }}"
- name: bridge
networks_cli_compatible: false
register: networks_4
@@ -209,7 +209,7 @@
name: "{{ cname }}"
state: started
networks:
- name: bridge
- name: bridge
networks_cli_compatible: false
register: networks_5
@@ -222,7 +222,7 @@
comparisons:
networks: strict
networks:
- name: bridge
- name: bridge
networks_cli_compatible: false
force_kill: true
register: networks_6
@@ -236,8 +236,8 @@
comparisons:
networks: strict
networks:
- name: bridge
- name: "{{ nname_2 }}"
- name: bridge
- name: "{{ nname_2 }}"
networks_cli_compatible: false
force_kill: true
register: networks_7
@@ -251,42 +251,42 @@
- assert:
that:
# networks_1 has networks default, 'bridge', nname_1
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks | length == 3
- nname_1 in networks_1.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
- "'default' in networks_1.container.NetworkSettings.Networks or 'bridge' in networks_1.container.NetworkSettings.Networks"
# networks_2 has networks default, 'bridge', nname_1
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks | length == 3
- nname_1 in networks_2.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
- "'default' in networks_1.container.NetworkSettings.Networks or 'bridge' in networks_1.container.NetworkSettings.Networks"
# networks_3 has networks 'bridge', nname_1
- networks_3 is changed
- networks_3.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_3.container.NetworkSettings.Networks
- "'default' in networks_3.container.NetworkSettings.Networks or 'bridge' in networks_3.container.NetworkSettings.Networks"
# networks_4 has networks 'bridge', nname_1
- networks_4 is not changed
- networks_4.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_4.container.NetworkSettings.Networks
- "'default' in networks_4.container.NetworkSettings.Networks or 'bridge' in networks_4.container.NetworkSettings.Networks"
# networks_5 has networks 'bridge', nname_1
- networks_5 is not changed
- networks_5.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_5.container.NetworkSettings.Networks
- "'default' in networks_5.container.NetworkSettings.Networks or 'bridge' in networks_5.container.NetworkSettings.Networks"
# networks_6 has networks 'bridge'
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks | length == 1
- "'default' in networks_6.container.NetworkSettings.Networks or 'bridge' in networks_6.container.NetworkSettings.Networks"
# networks_7 has networks 'bridge', nname_2
- networks_7 is changed
- networks_7.container.NetworkSettings.Networks | length == 2
- nname_2 in networks_7.container.NetworkSettings.Networks
- "'default' in networks_7.container.NetworkSettings.Networks or 'bridge' in networks_7.container.NetworkSettings.Networks"
# networks_1 has networks default, 'bridge', nname_1
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks | length == 3
- nname_1 in networks_1.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
- "'default' in networks_1.container.NetworkSettings.Networks or 'bridge' in networks_1.container.NetworkSettings.Networks"
# networks_2 has networks default, 'bridge', nname_1
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks | length == 3
- nname_1 in networks_2.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
- "'default' in networks_1.container.NetworkSettings.Networks or 'bridge' in networks_1.container.NetworkSettings.Networks"
# networks_3 has networks 'bridge', nname_1
- networks_3 is changed
- networks_3.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_3.container.NetworkSettings.Networks
- "'default' in networks_3.container.NetworkSettings.Networks or 'bridge' in networks_3.container.NetworkSettings.Networks"
# networks_4 has networks 'bridge', nname_1
- networks_4 is not changed
- networks_4.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_4.container.NetworkSettings.Networks
- "'default' in networks_4.container.NetworkSettings.Networks or 'bridge' in networks_4.container.NetworkSettings.Networks"
# networks_5 has networks 'bridge', nname_1
- networks_5 is not changed
- networks_5.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_5.container.NetworkSettings.Networks
- "'default' in networks_5.container.NetworkSettings.Networks or 'bridge' in networks_5.container.NetworkSettings.Networks"
# networks_6 has networks 'bridge'
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks | length == 1
- "'default' in networks_6.container.NetworkSettings.Networks or 'bridge' in networks_6.container.NetworkSettings.Networks"
# networks_7 has networks 'bridge', nname_2
- networks_7 is changed
- networks_7.container.NetworkSettings.Networks | length == 2
- nname_2 in networks_7.container.NetworkSettings.Networks
- "'default' in networks_7.container.NetworkSettings.Networks or 'bridge' in networks_7.container.NetworkSettings.Networks"
####################################################################
## networks for networks_cli_compatible=yes ########################
@@ -299,11 +299,11 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_1 }}"
aliases:
- alias1
- alias2
- name: "{{ nname_2 }}"
- name: "{{ nname_1 }}"
aliases:
- alias1
- alias2
- name: "{{ nname_2 }}"
networks_cli_compatible: true
register: networks_1
@@ -314,8 +314,8 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_1 }}"
- name: "{{ nname_2 }}"
- name: "{{ nname_1 }}"
- name: "{{ nname_2 }}"
networks_cli_compatible: true
register: networks_2
@@ -409,38 +409,38 @@
- assert:
that:
# networks_1 has networks nname_1, nname_2
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_1.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
# networks_2 has networks nname_1, nname_2
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_2.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
# networks_3 has networks 'bridge'
- networks_3 is changed
- networks_3.container.NetworkSettings.Networks | length == 1
- "'default' in networks_3.container.NetworkSettings.Networks or 'bridge' in networks_3.container.NetworkSettings.Networks"
# networks_4 has networks 'bridge'
- networks_4 is not changed
- networks_4.container.NetworkSettings.Networks | length == 1
- "'default' in networks_4.container.NetworkSettings.Networks or 'bridge' in networks_4.container.NetworkSettings.Networks"
# networks_5 has no networks
- networks_5 is changed
- networks_5.container.NetworkSettings.Networks | length == 0
# networks_6 has networks 'bridge'
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks | length == 1
- "'default' in networks_6.container.NetworkSettings.Networks or 'bridge' in networks_6.container.NetworkSettings.Networks"
# networks_7 has networks 'bridge'
- networks_7 is not changed
- networks_7.container.NetworkSettings.Networks | length == 1
- "'default' in networks_7.container.NetworkSettings.Networks or 'bridge' in networks_7.container.NetworkSettings.Networks"
# networks_8 has no networks
- networks_8 is changed
- networks_8.container.NetworkSettings.Networks | length == 0
# networks_1 has networks nname_1, nname_2
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_1.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
# networks_2 has networks nname_1, nname_2
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_2.container.NetworkSettings.Networks
- nname_2 in networks_1.container.NetworkSettings.Networks
# networks_3 has networks 'bridge'
- networks_3 is changed
- networks_3.container.NetworkSettings.Networks | length == 1
- "'default' in networks_3.container.NetworkSettings.Networks or 'bridge' in networks_3.container.NetworkSettings.Networks"
# networks_4 has networks 'bridge'
- networks_4 is not changed
- networks_4.container.NetworkSettings.Networks | length == 1
- "'default' in networks_4.container.NetworkSettings.Networks or 'bridge' in networks_4.container.NetworkSettings.Networks"
# networks_5 has no networks
- networks_5 is changed
- networks_5.container.NetworkSettings.Networks | length == 0
# networks_6 has networks 'bridge'
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks | length == 1
- "'default' in networks_6.container.NetworkSettings.Networks or 'bridge' in networks_6.container.NetworkSettings.Networks"
# networks_7 has networks 'bridge'
- networks_7 is not changed
- networks_7.container.NetworkSettings.Networks | length == 1
- "'default' in networks_7.container.NetworkSettings.Networks or 'bridge' in networks_7.container.NetworkSettings.Networks"
# networks_8 has no networks
- networks_8 is changed
- networks_8.container.NetworkSettings.Networks | length == 0
####################################################################
## networks with comparisons #######################################
@@ -453,7 +453,7 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_1 }}"
- name: "{{ nname_1 }}"
networks_cli_compatible: true
register: networks_1
@@ -464,7 +464,7 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_2 }}"
- name: "{{ nname_2 }}"
networks_cli_compatible: true
comparisons:
network_mode: ignore # otherwise we'd have to set network_mode to nname_1
@@ -502,7 +502,7 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_2 }}"
- name: "{{ nname_2 }}"
networks_cli_compatible: true
comparisons:
network_mode: ignore # otherwise we'd have to set network_mode to nname_1
@@ -517,7 +517,7 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_2 }}"
- name: "{{ nname_2 }}"
networks_cli_compatible: true
comparisons:
networks: strict
@@ -546,34 +546,34 @@
- assert:
that:
# networks_1 has networks nname_1
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_1.container.NetworkSettings.Networks
# networks_2 has networks nname_1
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_2.container.NetworkSettings.Networks
# networks_3 has networks nname_1
- networks_3 is not changed
- networks_3.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_3.container.NetworkSettings.Networks
# networks_4 has networks nname_1
- networks_4 is not changed
- networks_4.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_4.container.NetworkSettings.Networks
# networks_5 has networks nname_1, nname_2
- networks_5 is changed
- networks_5.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_5.container.NetworkSettings.Networks
- nname_2 in networks_5.container.NetworkSettings.Networks
# networks_6 has networks nname_2
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks | length == 1
- nname_2 in networks_6.container.NetworkSettings.Networks
# networks_7 has no networks
- networks_7 is changed
- networks_7.container.NetworkSettings.Networks | length == 0
# networks_1 has networks nname_1
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_1.container.NetworkSettings.Networks
# networks_2 has networks nname_1
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_2.container.NetworkSettings.Networks
# networks_3 has networks nname_1
- networks_3 is not changed
- networks_3.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_3.container.NetworkSettings.Networks
# networks_4 has networks nname_1
- networks_4 is not changed
- networks_4.container.NetworkSettings.Networks | length == 1
- nname_1 in networks_4.container.NetworkSettings.Networks
# networks_5 has networks nname_1, nname_2
- networks_5 is changed
- networks_5.container.NetworkSettings.Networks | length == 2
- nname_1 in networks_5.container.NetworkSettings.Networks
- nname_2 in networks_5.container.NetworkSettings.Networks
# networks_6 has networks nname_2
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks | length == 1
- nname_2 in networks_6.container.NetworkSettings.Networks
# networks_7 has no networks
- networks_7 is changed
- networks_7.container.NetworkSettings.Networks | length == 0
####################################################################
## networks with IP address ########################################
@@ -586,9 +586,9 @@
name: "{{ cname }}"
state: stopped
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_2 }}"
ipv6_address: "{{ nname_3_ipv6_2 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_2 }}"
ipv6_address: "{{ nname_3_ipv6_2 }}"
networks_cli_compatible: true
register: networks_1
@@ -599,9 +599,9 @@
name: "{{ cname }}"
state: stopped
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_2 }}"
ipv6_address: "{{ nname_3_ipv6_2 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_2 }}"
ipv6_address: "{{ nname_3_ipv6_2 }}"
networks_cli_compatible: true
register: networks_2
@@ -612,9 +612,9 @@
name: "{{ cname }}"
state: stopped
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_3 }}"
ipv6_address: "{{ nname_3_ipv6_2 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_3 }}"
ipv6_address: "{{ nname_3_ipv6_2 }}"
networks_cli_compatible: true
register: networks_3
@@ -625,9 +625,9 @@
name: "{{ cname }}"
state: stopped
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_3 }}"
ipv6_address: "{{ nname_3_ipv6_3 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_3 }}"
ipv6_address: "{{ nname_3_ipv6_3 }}"
networks_cli_compatible: true
register: networks_4
@@ -644,9 +644,9 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_4 }}"
ipv6_address: "{{ nname_3_ipv6_3 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_4 }}"
ipv6_address: "{{ nname_3_ipv6_3 }}"
networks_cli_compatible: true
force_kill: true
register: networks_6
@@ -658,9 +658,9 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_4 }}"
ipv6_address: "{{ nname_3_ipv6_4 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_4 }}"
ipv6_address: "{{ nname_3_ipv6_4 }}"
networks_cli_compatible: true
force_kill: true
register: networks_7
@@ -672,9 +672,9 @@
name: "{{ cname }}"
state: started
networks:
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_4 }}"
ipv6_address: "{{ nname_3_ipv6_4 }}"
- name: "{{ nname_3 }}"
ipv4_address: "{{ nname_3_ipv4_4 }}"
ipv6_address: "{{ nname_3_ipv6_4 }}"
networks_cli_compatible: true
register: networks_8
@@ -687,46 +687,46 @@
- assert:
that:
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_2
- networks_1.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_2 | normalize_ipaddr
- networks_1.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_1.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_2
- networks_2.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_2 | normalize_ipaddr
- networks_2.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_2.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_3 is changed
- networks_3.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- networks_3.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_2 | normalize_ipaddr
- networks_3.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_3.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_4 is changed
- networks_4.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- networks_4.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_4.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_4.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_5 is changed
- networks_5.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- networks_5.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_5.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_3
- networks_5.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- networks_6.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_6.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- networks_6.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_7 is changed
- networks_7.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- networks_7.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_7.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- networks_7.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_8 is not changed
- networks_8.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- networks_8.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_8.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- networks_8.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_1 is changed
- networks_1.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_2
- networks_1.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_2 | normalize_ipaddr
- networks_1.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_1.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_2 is not changed
- networks_2.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_2
- networks_2.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_2 | normalize_ipaddr
- networks_2.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_2.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_3 is changed
- networks_3.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- networks_3.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_2 | normalize_ipaddr
- networks_3.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_3.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_4 is changed
- networks_4.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- networks_4.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_4.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- networks_4.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- networks_5 is changed
- networks_5.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- networks_5.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_5.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_3
- networks_5.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_6 is changed
- networks_6.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- networks_6.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_6.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- networks_6.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
- networks_7 is changed
- networks_7.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- networks_7.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_7.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- networks_7.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_8 is not changed
- networks_8.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- networks_8.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
- networks_8.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- networks_8.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
####################################################################
####################################################################
@@ -738,8 +738,8 @@
state: absent
force: true
loop:
- "{{ nname_1 }}"
- "{{ nname_2 }}"
- "{{ nname_3 }}"
- "{{ nname_1 }}"
- "{{ nname_2 }}"
- "{{ nname_3 }}"
loop_control:
loop_var: network_name
File diff suppressed because it is too large Load Diff
@@ -22,7 +22,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "[::1:2000:3000"
- "[::1:2000:3000"
register: published_ports_1
ignore_errors: true
@@ -33,7 +33,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "::1:2000:3000"
- "::1:2000:3000"
register: published_ports_2
ignore_errors: true
@@ -44,7 +44,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "foo:2000:3000"
- "foo:2000:3000"
register: published_ports_3
ignore_errors: true
@@ -68,11 +68,11 @@
name: "{{ cname }}"
state: started
exposed_ports:
- "9001"
- "9010-9050"
- "9001"
- "9010-9050"
published_ports:
- "9001:9001"
- "9010-9050:9010-9050"
- "9001:9001"
- "9010-9050:9010-9050"
force_kill: true
register: published_ports_1
@@ -83,11 +83,11 @@
name: "{{ cname }}"
state: started
exposed_ports:
- "9001"
- "9010-9050"
- "9001"
- "9010-9050"
published_ports:
- "9001:9001"
- "9010-9050:9010-9050"
- "9001:9001"
- "9010-9050:9010-9050"
force_kill: true
register: published_ports_2
@@ -98,11 +98,11 @@
name: "{{ cname }}"
state: started
exposed_ports:
- "9001"
- "9010-9050"
- "9001"
- "9010-9050"
published_ports:
- "9001:9001"
- "9020-9060:9020-9060"
- "9001:9001"
- "9020-9060:9020-9060"
force_kill: true
register: published_ports_3
@@ -115,9 +115,9 @@
- assert:
that:
- published_ports_1 is changed
- published_ports_2 is not changed
- published_ports_3 is changed
- published_ports_1 is changed
- published_ports_2 is not changed
- published_ports_3 is changed
####################################################################
## published_ports: one-element container port range ###############
@@ -130,7 +130,7 @@
name: "{{ item }}"
state: started
published_ports:
- "9010-9050:9010"
- "9010-9050:9010"
force_kill: true
loop:
- '{{ cname }}'
@@ -144,7 +144,7 @@
name: "{{ item }}"
state: started
published_ports:
- "9010-9050:9010"
- "9010-9050:9010"
force_kill: true
loop:
- '{{ cname }}'
@@ -158,7 +158,7 @@
name: "{{ item }}"
state: started
published_ports:
- "9010-9051:9010"
- "9010-9051:9010"
force_kill: true
loop:
- '{{ cname }}'
@@ -177,9 +177,9 @@
- assert:
that:
- published_ports_1 is changed
- published_ports_2 is not changed
- published_ports_3 is changed
- published_ports_1 is changed
- published_ports_2 is not changed
- published_ports_3 is changed
####################################################################
## published_ports: IPv6 addresses #################################
@@ -194,7 +194,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "[::1]:9001:9001"
- "[::1]:9001:9001"
force_kill: true
register: published_ports_1
@@ -205,7 +205,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "[::1]:9001:9001"
- "[::1]:9001:9001"
force_kill: true
register: published_ports_2
@@ -216,7 +216,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "127.0.0.1:9001:9001"
- "127.0.0.1:9001:9001"
force_kill: true
register: published_ports_3
@@ -227,7 +227,7 @@
name: "{{ cname }}"
state: started
published_ports:
- "localhost:9001:9001"
- "localhost:9001:9001"
force_kill: true
register: published_ports_4
ignore_errors: true
@@ -241,10 +241,10 @@
- assert:
that:
- published_ports_1 is changed
- published_ports_2 is not changed
- published_ports_3 is changed
- published_ports_4 is failed
- published_ports_1 is changed
- published_ports_2 is not changed
- published_ports_3 is changed
- published_ports_4 is failed
####################################################################
## publish_all_ports ###############################################
@@ -29,10 +29,10 @@
# before the container is stopped (see
# https://github.com/ansible/ansible/issues/45486).
networks:
- name: "nonexistant-network-{{ (2**32) | random }}"
- name: "nonexistant-network-{{ (2**32) | random }}"
published_ports:
- '1:2'
- '3'
- '1:2'
- '3'
links:
- "nonexistant-container-{{ (2**32) | random }}:test"
- "nonexistant-container-{{ (2**32) | random }}:test"
state: absent
@@ -50,10 +50,10 @@
- assert:
that:
- create_1 is changed
- create_2 is changed
- create_3 is not changed
- create_4 is not changed
- create_1 is changed
- create_2 is changed
- create_3 is not changed
- create_4 is not changed
####################################################################
## Starting (after creation) #######################################
@@ -87,10 +87,10 @@
- assert:
that:
- start_1 is changed
- start_2 is changed
- start_3 is not changed
- start_4 is not changed
- start_1 is changed
- start_2 is changed
- start_3 is not changed
- start_4 is not changed
####################################################################
## Present check for running container #############################
@@ -115,8 +115,8 @@
- assert:
that:
- present_check_1 is not changed
- present_check_2 is not changed
- present_check_1 is not changed
- present_check_2 is not changed
####################################################################
## Starting (from scratch) #########################################
@@ -168,10 +168,10 @@
- assert:
that:
- start_scratch_1 is changed
- start_scratch_2 is changed
- start_scratch_3 is not changed
- start_scratch_4 is not changed
- start_scratch_1 is changed
- start_scratch_2 is changed
- start_scratch_3 is not changed
- start_scratch_4 is not changed
####################################################################
## Recreating ######################################################
@@ -253,16 +253,16 @@
- assert:
that:
- recreate_2 is changed
- recreate_3 is changed
- recreate_4 is changed
- recreate_5 is changed
- recreate_6 is changed
- recreate_1.container.Id == recreate_2.container.Id
- recreate_1.container.Id != recreate_3.container.Id
- recreate_3.container.Id == recreate_4.container.Id
- recreate_4.container.Id == recreate_5.container.Id
- recreate_4.container.Id != recreate_6.container.Id
- recreate_2 is changed
- recreate_3 is changed
- recreate_4 is changed
- recreate_5 is changed
- recreate_6 is changed
- recreate_1.container.Id == recreate_2.container.Id
- recreate_1.container.Id != recreate_3.container.Id
- recreate_3.container.Id == recreate_4.container.Id
- recreate_4.container.Id == recreate_5.container.Id
- recreate_4.container.Id != recreate_6.container.Id
####################################################################
## Restarting ######################################################
@@ -276,7 +276,7 @@
state: started
stop_timeout: 1
volumes:
- /tmp/tmp
- /tmp/tmp
register: restart_1
- name: Restarting (restart, check mode)
@@ -310,7 +310,7 @@
state: started
stop_timeout: 1
volumes:
- /tmp/tmp
- /tmp/tmp
register: restart_4
- name: cleanup
@@ -322,11 +322,11 @@
- assert:
that:
- restart_1 is changed
- restart_2 is changed
- restart_3 is changed
- restart_1.container.Id == restart_3.container.Id
- restart_4 is not changed
- restart_1 is changed
- restart_2 is changed
- restart_3 is changed
- restart_1.container.Id == restart_3.container.Id
- restart_4 is not changed
####################################################################
## Stopping ########################################################
@@ -368,10 +368,10 @@
- assert:
that:
- stop_1 is changed
- stop_2 is changed
- stop_3 is not changed
- stop_4 is not changed
- stop_1 is changed
- stop_2 is changed
- stop_3 is not changed
- stop_4 is not changed
####################################################################
## Removing ########################################################
@@ -405,10 +405,10 @@
- assert:
that:
- remove_1 is changed
- remove_2 is changed
- remove_3 is not changed
- remove_4 is not changed
- remove_1 is changed
- remove_2 is changed
- remove_3 is not changed
- remove_4 is not changed
####################################################################
## Removing (from running) #########################################
@@ -453,7 +453,7 @@
- assert:
that:
- remove_from_running_1 is changed
- remove_from_running_2 is changed
- remove_from_running_3 is not changed
- remove_from_running_4 is not changed
- remove_from_running_1 is changed
- remove_from_running_2 is changed
- remove_from_running_3 is not changed
- remove_from_running_4 is not changed
@@ -131,91 +131,91 @@
- name: Check general things
assert:
that:
- create is changed
- update is changed
- update2 is changed
- recreate is changed
- create is changed
- update is changed
- update2 is changed
- recreate is changed
# Make sure the container was *not* recreated when it should not be
- create.container.Id == update.container.Id
- create.container.Id == update2.container.Id
# Make sure the container was *not* recreated when it should not be
- create.container.Id == update.container.Id
- create.container.Id == update2.container.Id
# Make sure that the container was recreated when it should be
- create.container.Id != recreate.container.Id
# Make sure that the container was recreated when it should be
- create.container.Id != recreate.container.Id
- name: Check diff for first update
assert:
that:
# blkio_weight sometimes cannot be set, then we end up with 0 instead of the value we had
- >-
not has_blkio_weight or update.diff.before.blkio_weight == 123 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([])))
- not has_blkio_weight or update.diff.after.blkio_weight == 234
- update.diff.before.cpu_period == 90000
- update.diff.after.cpu_period == 50000
- update.diff.before.cpu_quota == 150000
- update.diff.after.cpu_quota == 50000
- update.diff.before.cpu_shares == 900
- update.diff.after.cpu_shares == 1100
- update.diff.before.memory == 67108864
- update.diff.after.memory == 50331648
- update.diff.before.memory_reservation == 67108864
- update.diff.after.memory_reservation == 50331648
- >-
(update.diff.before.memory_swap | default(0)) == 67108864 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- >-
(update.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- "'restart_policy' not in update.diff.before"
- update.diff.before.restart_retries == 5
- update.diff.after.restart_retries == 2
# blkio_weight sometimes cannot be set, then we end up with 0 instead of the value we had
- >-
not has_blkio_weight or update.diff.before.blkio_weight == 123 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([])))
- not has_blkio_weight or update.diff.after.blkio_weight == 234
- update.diff.before.cpu_period == 90000
- update.diff.after.cpu_period == 50000
- update.diff.before.cpu_quota == 150000
- update.diff.after.cpu_quota == 50000
- update.diff.before.cpu_shares == 900
- update.diff.after.cpu_shares == 1100
- update.diff.before.memory == 67108864
- update.diff.after.memory == 50331648
- update.diff.before.memory_reservation == 67108864
- update.diff.after.memory_reservation == 50331648
- >-
(update.diff.before.memory_swap | default(0)) == 67108864 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- >-
(update.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- "'restart_policy' not in update.diff.before"
- update.diff.before.restart_retries == 5
- update.diff.after.restart_retries == 2
- name: Check diff for second update
assert:
that:
- >-
not has_blkio_weight or update2.diff.before.blkio_weight == 234 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([])))
- not has_blkio_weight or update2.diff.after.blkio_weight == 135
- update2.diff.before.cpu_period == 50000
- update2.diff.after.cpu_period == 30000
- update2.diff.before.cpu_quota == 50000
- update2.diff.after.cpu_quota == 40000
- update2.diff.before.cpu_shares == 1100
- update2.diff.after.cpu_shares == 1000
- update2.diff.before.memory == 50331648
- update2.diff.after.memory == 33554432
- update2.diff.before.memory_reservation == 50331648
- update2.diff.after.memory_reservation == 31457280
- >-
(update2.diff.before.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- >-
(update2.diff.after.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- update2.diff.before.restart_policy == 'on-failure'
- update2.diff.after.restart_policy == 'always'
- update2.diff.before.restart_retries == 2
- update2.diff.after.restart_retries == 0
- >-
not has_blkio_weight or update2.diff.before.blkio_weight == 234 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([])))
- not has_blkio_weight or update2.diff.after.blkio_weight == 135
- update2.diff.before.cpu_period == 50000
- update2.diff.after.cpu_period == 30000
- update2.diff.before.cpu_quota == 50000
- update2.diff.after.cpu_quota == 40000
- update2.diff.before.cpu_shares == 1100
- update2.diff.after.cpu_shares == 1000
- update2.diff.before.memory == 50331648
- update2.diff.after.memory == 33554432
- update2.diff.before.memory_reservation == 50331648
- update2.diff.after.memory_reservation == 31457280
- >-
(update2.diff.before.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- >-
(update2.diff.after.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- update2.diff.before.restart_policy == 'on-failure'
- update2.diff.after.restart_policy == 'always'
- update2.diff.before.restart_retries == 2
- update2.diff.after.restart_retries == 0
- name: Check diff for recreation
assert:
that:
- >-
not has_blkio_weight or recreate.diff.before.blkio_weight == 135 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([])))
- not has_blkio_weight or recreate.diff.after.blkio_weight == 234
- recreate.diff.before.cpu_period == 30000
- recreate.diff.after.cpu_period == 50000
- recreate.diff.before.cpu_quota == 40000
- recreate.diff.after.cpu_quota == 50000
- recreate.diff.before.cpu_shares == 1000
- recreate.diff.after.cpu_shares == 1100
- recreate.diff.before.memory == 33554432
- recreate.diff.after.memory == 50331648
- recreate.diff.before.memory_reservation == 31457280
- recreate.diff.after.memory_reservation == 50331648
- >-
(recreate.diff.before.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- >-
(recreate.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- recreate.diff.before.restart_policy == 'always'
- recreate.diff.after.restart_policy == 'on-failure'
- recreate.diff.before.restart_retries == 0
- recreate.diff.after.restart_retries == 2
- recreate.diff.before.command == ['/bin/sh', '-c', 'sleep 10m']
- recreate.diff.after.command == ['/bin/sh', '-c', 'sleep 20m']
- >-
not has_blkio_weight or recreate.diff.before.blkio_weight == 135 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([])))
- not has_blkio_weight or recreate.diff.after.blkio_weight == 234
- recreate.diff.before.cpu_period == 30000
- recreate.diff.after.cpu_period == 50000
- recreate.diff.before.cpu_quota == 40000
- recreate.diff.after.cpu_quota == 50000
- recreate.diff.before.cpu_shares == 1000
- recreate.diff.after.cpu_shares == 1100
- recreate.diff.before.memory == 33554432
- recreate.diff.after.memory == 50331648
- recreate.diff.before.memory_reservation == 31457280
- recreate.diff.after.memory_reservation == 50331648
- >-
(recreate.diff.before.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- >-
(recreate.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([])))
- recreate.diff.before.restart_policy == 'always'
- recreate.diff.after.restart_policy == 'on-failure'
- recreate.diff.before.restart_retries == 0
- recreate.diff.after.restart_retries == 2
- recreate.diff.before.command == ['/bin/sh', '-c', 'sleep 10m']
- recreate.diff.after.command == ['/bin/sh', '-c', 'sleep 20m']
@@ -9,218 +9,218 @@
####################################################################
- block:
- name: Create random container name
set_fact:
cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Create random container name
set_fact:
cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Make sure container is not there
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
- name: Make sure container is not there
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
- name: Execute in a non-present container
docker_container_exec:
container: "{{ cname }}"
command: "/bin/bash -c 'ls -a'"
register: result
ignore_errors: true
- name: Execute in a non-present container
docker_container_exec:
container: "{{ cname }}"
command: "/bin/bash -c 'ls -a'"
register: result
ignore_errors: true
- assert:
that:
- result is failed
- "'Could not find container' in result.msg"
- assert:
that:
- result is failed
- "'Could not find container' in result.msg"
- name: Make sure container exists
docker_container:
name: "{{ cname }}"
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
state: started
force_kill: true
- name: Make sure container exists
docker_container:
name: "{{ cname }}"
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
state: started
force_kill: true
- name: Execute in a present container (command)
docker_container_exec:
container: "{{ cname }}"
command: "/bin/sh -c 'ls -a'"
register: result_cmd
- name: Execute in a present container (command)
docker_container_exec:
container: "{{ cname }}"
command: "/bin/sh -c 'ls -a'"
register: result_cmd
- assert:
that:
- result_cmd.rc == 0
- "'stdout' in result_cmd"
- "'stdout_lines' in result_cmd"
- "'stderr' in result_cmd"
- "'stderr_lines' in result_cmd"
- assert:
that:
- result_cmd.rc == 0
- "'stdout' in result_cmd"
- "'stdout_lines' in result_cmd"
- "'stderr' in result_cmd"
- "'stderr_lines' in result_cmd"
- name: Execute in a present container (argv)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- ls -a
register: result_argv
- name: Execute in a present container (argv)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- ls -a
register: result_argv
- assert:
that:
- result_argv.rc == 0
- "'stdout' in result_argv"
- "'stdout_lines' in result_argv"
- "'stderr' in result_argv"
- "'stderr_lines' in result_argv"
- result_cmd.stdout == result_argv.stdout
- assert:
that:
- result_argv.rc == 0
- "'stdout' in result_argv"
- "'stdout_lines' in result_argv"
- "'stderr' in result_argv"
- "'stderr_lines' in result_argv"
- result_cmd.stdout == result_argv.stdout
- name: Execute in a present container (cat without stdin)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
register: result
- name: Execute in a present container (cat without stdin)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
register: result
- assert:
that:
- result.rc == 0
- result.stdout == ''
- result.stdout_lines == []
- result.stderr == ''
- result.stderr_lines == []
- assert:
that:
- result.rc == 0
- result.stdout == ''
- result.stdout_lines == []
- result.stderr == ''
- result.stderr_lines == []
- name: Execute in a present container (cat with stdin)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: Hello world!
strip_empty_ends: false
register: result
- name: Execute in a present container (cat with stdin)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: Hello world!
strip_empty_ends: false
register: result
- assert:
that:
- result.rc == 0
- result.stdout == 'Hello world!\n'
- result.stdout_lines == ['Hello world!']
- result.stderr == ''
- result.stderr_lines == []
- assert:
that:
- result.rc == 0
- result.stdout == 'Hello world!\n'
- result.stdout_lines == ['Hello world!']
- result.stderr == ''
- result.stderr_lines == []
- name: Execute in a present container (cat with stdin, no newline)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: Hello world!
stdin_add_newline: false
strip_empty_ends: false
register: result
- name: Execute in a present container (cat with stdin, no newline)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: Hello world!
stdin_add_newline: false
strip_empty_ends: false
register: result
- assert:
that:
- result.rc == 0
- result.stdout == 'Hello world!'
- result.stdout_lines == ['Hello world!']
- result.stderr == ''
- result.stderr_lines == []
- assert:
that:
- result.rc == 0
- result.stdout == 'Hello world!'
- result.stdout_lines == ['Hello world!']
- result.stderr == ''
- result.stderr_lines == []
- name: Execute in a present container (cat with stdin, newline but stripping)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: Hello world!
stdin_add_newline: true
strip_empty_ends: true
register: result
- name: Execute in a present container (cat with stdin, newline but stripping)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: Hello world!
stdin_add_newline: true
strip_empty_ends: true
register: result
- assert:
that:
- result.rc == 0
- result.stdout == 'Hello world!'
- result.stdout_lines == ['Hello world!']
- result.stderr == ''
- result.stderr_lines == []
- assert:
that:
- result.rc == 0
- result.stdout == 'Hello world!'
- result.stdout_lines == ['Hello world!']
- result.stderr == ''
- result.stderr_lines == []
- name: Prepare long string
set_fact:
very_long_string: "{{ 'something long ' * 10000 }}"
very_long_string2: "{{ 'something else ' * 5000 }}"
- name: Prepare long string
set_fact:
very_long_string: "{{ 'something long ' * 10000 }}"
very_long_string2: "{{ 'something else ' * 5000 }}"
- name: Execute in a present container (long stdin)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: |-
{{ very_long_string }}
{{ very_long_string2 }}
register: result
- name: Execute in a present container (long stdin)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- cat
stdin: |-
{{ very_long_string }}
{{ very_long_string2 }}
register: result
- assert:
that:
- result is changed
- result.rc == 0
- result.stdout == (very_long_string ~ '\n' ~ very_long_string2)
- result.stdout_lines == [very_long_string, very_long_string2]
- result.stderr == ''
- result.stderr_lines == []
- "'exec_id' not in result"
- assert:
that:
- result is changed
- result.rc == 0
- result.stdout == (very_long_string ~ '\n' ~ very_long_string2)
- result.stdout_lines == [very_long_string, very_long_string2]
- result.stderr == ''
- result.stderr_lines == []
- "'exec_id' not in result"
- name: Execute in a present container (detached)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- sleep 1m
detach: true
register: result
- name: Execute in a present container (detached)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- sleep 1m
detach: true
register: result
- debug: var=result
- debug: var=result
- assert:
that:
- result is changed
- "'rc' not in result"
- "'stdout' not in result"
- "'stderr' not in result"
- result.exec_id is string
- assert:
that:
- result is changed
- "'rc' not in result"
- "'stdout' not in result"
- "'stderr' not in result"
- result.exec_id is string
- name: Execute in a present container (environment variable)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- 'echo "$FOO" ; echo $FOO > /dev/stderr'
env:
FOO: |-
bar
baz
register: result
- name: Execute in a present container (environment variable)
docker_container_exec:
container: "{{ cname }}"
argv:
- /bin/sh
- '-c'
- 'echo "$FOO" ; echo $FOO > /dev/stderr'
env:
FOO: |-
bar
baz
register: result
- assert:
that:
- result.rc == 0
- result.stdout == 'bar\nbaz'
- result.stdout_lines == ['bar', 'baz']
- result.stderr == 'bar baz'
- result.stderr_lines == ['bar baz']
- assert:
that:
- result.rc == 0
- result.stdout == 'bar\nbaz'
- result.stdout_lines == ['bar', 'baz']
- result.stderr == 'bar baz'
- result.stderr_lines == ['bar baz']
always:
- name: Cleanup
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
- name: Cleanup
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
when: docker_api_version is version('1.25', '>=')
@@ -9,74 +9,74 @@
####################################################################
- block:
- name: Create random container name
set_fact:
cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Create random container name
set_fact:
cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Make sure container is not there
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
- name: Make sure container is not there
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
- name: Inspect a non-present container
docker_container_info:
name: "{{ cname }}"
register: result
- name: Inspect a non-present container
docker_container_info:
name: "{{ cname }}"
register: result
- assert:
that:
- "not result.exists"
- "'container' in result"
- "result.container is none"
- assert:
that:
- "not result.exists"
- "'container' in result"
- "result.container is none"
- name: Make sure container exists
docker_container:
name: "{{ cname }}"
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
state: started
force_kill: true
- name: Make sure container exists
docker_container:
name: "{{ cname }}"
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
state: started
force_kill: true
- name: Inspect a present container
docker_container_info:
name: "{{ cname }}"
register: result
- name: Dump docker_container_info result
debug: var=result
- name: Inspect a present container
docker_container_info:
name: "{{ cname }}"
register: result
- name: Dump docker_container_info result
debug: var=result
- name: "Comparison: use 'docker inspect'"
command: docker inspect "{{ cname }}"
register: docker_inspect
ignore_errors: true
- block:
- set_fact:
docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
- name: Dump docker inspect result
debug: var=docker_inspect_result
when: docker_inspect is not failed
- name: "Comparison: use 'docker inspect'"
command: docker inspect "{{ cname }}"
register: docker_inspect
ignore_errors: true
- block:
- set_fact:
docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
- name: Dump docker inspect result
debug: var=docker_inspect_result
when: docker_inspect is not failed
- assert:
that:
- result.exists
- "'container' in result"
- "result.container is truthy"
- assert:
that:
- result.exists
- "'container' in result"
- "result.container is truthy"
- assert:
that:
- "result.container == docker_inspect_result[0]"
when: docker_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_inspect.stderr"
when: docker_inspect is failed
- assert:
that:
- "result.container == docker_inspect_result[0]"
when: docker_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_inspect.stderr"
when: docker_inspect is failed
always:
- name: Cleanup
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
- name: Cleanup
docker_container:
name: "{{ cname }}"
state: absent
force_kill: true
when: docker_api_version is version('1.25', '>=')
@@ -51,8 +51,8 @@
- assert:
that:
- create_1 is changed
- create_2 is not changed
- create_1 is changed
- create_2 is not changed
- name: Inspect container with CLI tool
ansible.builtin.command:
@@ -78,8 +78,8 @@
- assert:
that:
- start_1 is changed
- start_2 is not changed
- start_1 is changed
- start_2 is not changed
- name: Inspect container with CLI tool
ansible.builtin.command:
@@ -107,8 +107,8 @@
- assert:
that:
- remove_1 is changed
- remove_2 is not changed
- remove_1 is changed
- remove_2 is not changed
- name: Inspect container with CLI tool
ansible.builtin.command:
@@ -13,379 +13,379 @@
msg: "Using container names '{{ cname }}' and '{{ cname2 }}', and volume name '{{ vname }}'"
- block:
- name: Get info on Docker host
docker_host_info:
register: output
- name: Get info on Docker host
docker_host_info:
register: output
- name: assert reading docker host facts when docker is running
assert:
that:
- output.host_info.Name is string
- output.containers is not defined
- output.networks is not defined
- output.volumes is not defined
- output.images is not defined
- output.disk_usage is not defined
- output.can_talk_to_docker is true
- name: assert reading docker host facts when docker is running
assert:
that:
- output.host_info.Name is string
- output.containers is not defined
- output.networks is not defined
- output.volumes is not defined
- output.images is not defined
- output.disk_usage is not defined
- output.can_talk_to_docker is true
- block:
- name: Get info on Docker host with invalid api_version
docker_host_info:
api_version: 1.999.999
register: output
ignore_errors: true
- name: Get info on Docker host with invalid api_version
docker_host_info:
api_version: 1.999.999
register: output
ignore_errors: true
- name: assert can_talk_is_docker is false
assert:
that:
- output is failed
- output.can_talk_to_docker is false
- name: assert can_talk_is_docker is false
assert:
that:
- output is failed
- output.can_talk_to_docker is false
- block:
- name: Get info on Docker host with invalid docker_host
docker_host_info:
docker_host: tcp://127.0.0.1:80
register: output
ignore_errors: true
- name: Get info on Docker host with invalid docker_host
docker_host_info:
docker_host: tcp://127.0.0.1:80
register: output
ignore_errors: true
- name: assert can_talk_is_docker is false
assert:
that:
- output is failed
- output.can_talk_to_docker is false
- name: assert can_talk_is_docker is false
assert:
that:
- output is failed
- output.can_talk_to_docker is false
# Container and volume are created so that all lists are non-empty:
# * container and volume lists are non-emtpy because of the created objects;
# * image list is non-empty because the image of the container is there;
# * network list is always non-empty (default networks).
- name: Create running container
docker_container:
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
name: "{{ cname }}"
labels:
key1: value1
key2: value2
state: started
register: container_output
# Container and volume are created so that all lists are non-empty:
# * container and volume lists are non-emtpy because of the created objects;
# * image list is non-empty because the image of the container is there;
# * network list is always non-empty (default networks).
- name: Create running container
docker_container:
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
name: "{{ cname }}"
labels:
key1: value1
key2: value2
state: started
register: container_output
- name: Create running container
docker_container:
image: "{{ docker_test_image_alpine }}"
name: "{{ cname2 }}"
labels:
key2: value2
key3: value3
state: stopped
register: container2_output
- name: Create running container
docker_container:
image: "{{ docker_test_image_alpine }}"
name: "{{ cname2 }}"
labels:
key2: value2
key3: value3
state: stopped
register: container2_output
- assert:
that:
- container_output is changed
- container2_output is changed
- assert:
that:
- container_output is changed
- container2_output is changed
- name: Create a volume
docker_volume:
name: "{{ vname }}"
register: volume_output
- name: Create a volume
docker_volume:
name: "{{ vname }}"
register: volume_output
- assert:
that:
- volume_output is changed
- assert:
that:
- volume_output is changed
- name: Get info on Docker host and list containers
docker_host_info:
containers: true
register: output
- name: Get info on Docker host and list containers
docker_host_info:
containers: true
register: output
- name: assert reading docker host facts when docker is running and list containers
assert:
that:
- 'output.host_info.Name is string'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is not defined'
- name: assert reading docker host facts when docker is running and list containers
assert:
that:
- 'output.host_info.Name is string'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is not defined'
- name: Get info on Docker host and list containers matching filters (single label)
docker_host_info:
containers: true
containers_filters:
label: key1=value1
register: output
- name: Get info on Docker host and list containers matching filters (single label)
docker_host_info:
containers: true
containers_filters:
label: key1=value1
register: output
- name: assert container is returned when filters are matched (single label)
assert:
that: "output.containers | length == 1"
- name: assert container is returned when filters are matched (single label)
assert:
that: "output.containers | length == 1"
- name: Get info on Docker host and list containers matching filters (multiple labels)
docker_host_info:
containers: true
containers_filters:
label:
- key1=value1
- key2=value2
register: output
- name: Get info on Docker host and list containers matching filters (multiple labels)
docker_host_info:
containers: true
containers_filters:
label:
- key1=value1
- key2=value2
register: output
- name: assert container is returned when filters are matched (multiple labels)
assert:
that: "output.containers | length == 1"
- name: assert container is returned when filters are matched (multiple labels)
assert:
that: "output.containers | length == 1"
- name: Get info on Docker host and do not list containers which do not match filters
docker_host_info:
containers: true
containers_filters:
label:
- key1=value1
- key2=value2
- key3=value3
register: output
- name: Get info on Docker host and do not list containers which do not match filters
docker_host_info:
containers: true
containers_filters:
label:
- key1=value1
- key2=value2
- key3=value3
register: output
- name: assert no container is returned when filters are not matched
assert:
that: "output.containers | length == 0"
- name: assert no container is returned when filters are not matched
assert:
that: "output.containers | length == 0"
- name: Get info on Docker host and list containers matching filters (single label, not all containers)
docker_host_info:
containers: true
containers_all: false
containers_filters:
label: key2=value2
register: output
- name: Get info on Docker host and list containers matching filters (single label, not all containers)
docker_host_info:
containers: true
containers_all: false
containers_filters:
label: key2=value2
register: output
- name: Get info on Docker host and list containers matching filters (single label, all containers)
docker_host_info:
containers: true
containers_all: true
containers_filters:
label: key2=value2
register: output_all
- name: Get info on Docker host and list containers matching filters (single label, all containers)
docker_host_info:
containers: true
containers_all: true
containers_filters:
label: key2=value2
register: output_all
- name: assert one resp. two container is returned
assert:
that:
- "output.containers | length == 1"
- "output_all.containers | length == 2"
- name: assert one resp. two container is returned
assert:
that:
- "output.containers | length == 1"
- "output_all.containers | length == 2"
- name: Get info on Docker host and list containers with verbose output
docker_host_info:
containers: true
verbose_output: true
register: output
- name: Get info on Docker host and list containers with verbose output
docker_host_info:
containers: true
verbose_output: true
register: output
- name: assert reading docker host facts when docker is running and list containers with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is string'
- name: assert reading docker host facts when docker is running and list containers with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is string'
- name: Get info on Docker host and list images
docker_host_info:
images: true
register: output
- name: Get info on Docker host and list images
docker_host_info:
images: true
register: output
- name: assert reading docker host facts when docker is running and list images
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is not defined'
- 'output.disk_usage is not defined'
- name: assert reading docker host facts when docker is running and list images
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is not defined'
- 'output.disk_usage is not defined'
- name: Get info on Docker host and list images with verbose output
docker_host_info:
images: true
verbose_output: true
register: output
- name: Get info on Docker host and list images with verbose output
docker_host_info:
images: true
verbose_output: true
register: output
- name: assert reading docker host facts when docker is running and list images with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is string'
- 'output.disk_usage is not defined'
- name: assert reading docker host facts when docker is running and list images with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is string'
- 'output.disk_usage is not defined'
- name: Get info on Docker host and list networks
docker_host_info:
networks: true
register: output
- name: Get info on Docker host and list networks
docker_host_info:
networks: true
register: output
- name: assert reading docker host facts when docker is running and list networks
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: assert reading docker host facts when docker is running and list networks
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: Get info on Docker host and list networks with verbose output
docker_host_info:
networks: true
verbose_output: true
register: output
- name: Get info on Docker host and list networks with verbose output
docker_host_info:
networks: true
verbose_output: true
register: output
- name: assert reading docker host facts when docker is running and list networks with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is string'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: assert reading docker host facts when docker is running and list networks with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is string'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: Get info on Docker host and list volumes
docker_host_info:
volumes: true
register: output
- name: Get info on Docker host and list volumes
docker_host_info:
volumes: true
register: output
- name: assert reading docker host facts when docker is running and list volumes
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: assert reading docker host facts when docker is running and list volumes
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is not defined'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: Get info on Docker host and list volumes with verbose output
docker_host_info:
volumes: true
verbose_output: true
register: output
- name: Get info on Docker host and list volumes with verbose output
docker_host_info:
volumes: true
verbose_output: true
register: output
- name: assert reading docker host facts when docker is running and list volumes with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is string'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: assert reading docker host facts when docker is running and list volumes with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is string'
- 'output.images is not defined'
- 'output.disk_usage is not defined'
- name: Get info on Docker host and get disk usage
docker_host_info:
disk_usage: true
register: output
- name: Get info on Docker host and get disk usage
docker_host_info:
disk_usage: true
register: output
- name: assert reading docker host facts when docker is running and get disk usage
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is not defined'
- 'output.disk_usage.Containers is not defined'
- 'output.disk_usage.Volumes is not defined'
- name: assert reading docker host facts when docker is running and get disk usage
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is not defined'
- 'output.disk_usage.Containers is not defined'
- 'output.disk_usage.Volumes is not defined'
- name: Get info on Docker host and get disk usage with verbose output
docker_host_info:
disk_usage: true
verbose_output: true
register: output
- name: Get info on Docker host and get disk usage with verbose output
docker_host_info:
disk_usage: true
verbose_output: true
register: output
- name: assert reading docker host facts when docker is running and get disk usage with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is sequence'
- 'output.disk_usage.Containers is sequence'
- 'output.disk_usage.Volumes is sequence'
- name: assert reading docker host facts when docker is running and get disk usage with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers is not defined'
- 'output.networks is not defined'
- 'output.volumes is not defined'
- 'output.images is not defined'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is sequence'
- 'output.disk_usage.Containers is sequence'
- 'output.disk_usage.Volumes is sequence'
- name: Get info on Docker host, disk usage and get all lists together
docker_host_info:
volumes: true
containers: true
networks: true
images: true
disk_usage: true
register: output
- name: Get info on Docker host, disk usage and get all lists together
docker_host_info:
volumes: true
containers: true
networks: true
images: true
disk_usage: true
register: output
- name: assert reading docker host facts when docker is running, disk usage and get lists together
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is not defined'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is not defined'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is not defined'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is not defined'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is not defined'
- 'output.disk_usage.Containers is not defined'
- 'output.disk_usage.Volumes is not defined'
- name: assert reading docker host facts when docker is running, disk usage and get lists together
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is not defined'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is not defined'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is not defined'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is not defined'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is not defined'
- 'output.disk_usage.Containers is not defined'
- 'output.disk_usage.Volumes is not defined'
- name: Get info on Docker host, disk usage and get all lists together with verbose output
docker_host_info:
volumes: true
containers: true
networks: true
images: true
disk_usage: true
verbose_output: true
register: output
- name: Get info on Docker host, disk usage and get all lists together with verbose output
docker_host_info:
volumes: true
containers: true
networks: true
images: true
disk_usage: true
verbose_output: true
register: output
- name: assert reading docker host facts when docker is running and get disk usage with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is string'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is string'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is string'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is string'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is sequence'
- 'output.disk_usage.Containers is sequence'
- 'output.disk_usage.Volumes is sequence'
- name: assert reading docker host facts when docker is running and get disk usage with verbose output
assert:
that:
- 'output.host_info.Name is string'
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is string'
- 'output.networks[0].Id is string'
- 'output.networks[0].Created is string'
- 'output.volumes[0].Name is string'
- 'output.volumes[0].Mountpoint is string'
- 'output.images[0].Id is string'
- 'output.images[0].ParentId is string'
- 'output.disk_usage.LayersSize is number'
- 'output.disk_usage.Images is sequence'
- 'output.disk_usage.Containers is sequence'
- 'output.disk_usage.Volumes is sequence'
always:
- name: Delete containers
docker_container:
name: "{{ item }}"
state: absent
force_kill: true
loop:
- "{{ cname }}"
- "{{ cname2 }}"
- name: Delete containers
docker_container:
name: "{{ item }}"
state: absent
force_kill: true
loop:
- "{{ cname }}"
- "{{ cname2 }}"
- name: Delete volume
docker_volume:
name: "{{ vname }}"
state: absent
- name: Delete volume
docker_volume:
name: "{{ vname }}"
state: absent
@@ -22,7 +22,7 @@
- assert:
that:
- absent_2 is not changed
- absent_2 is not changed
- name: Make sure image is there
docker_image:
@@ -44,8 +44,8 @@
- assert:
that:
- present_1 is changed
- present_2 is not changed
- present_1 is changed
- present_2 is not changed
- name: Make sure tag is not there
docker_image:
@@ -83,10 +83,10 @@
- assert:
that:
- tag_1 is changed
- tag_2 is not changed
- tag_3 is not changed
- tag_4 is not changed
- tag_1 is changed
- tag_2 is not changed
- tag_3 is not changed
- tag_4 is not changed
- name: Cleanup alias tag
docker_image:
@@ -129,11 +129,11 @@
- assert:
that:
- fail_1 is failed
- "'`repository` must not be an image ID' in fail_1.msg"
- fail_2 is failed
- "'Cannot push an image by ID' in fail_2.msg"
- fail_3 is failed
- "'Image name must not be an image ID for source=pull' in fail_3.msg"
- fail_4 is failed
- "'Image name must not be an image ID for source=build' in fail_4.msg"
- fail_1 is failed
- "'`repository` must not be an image ID' in fail_1.msg"
- fail_2 is failed
- "'Cannot push an image by ID' in fail_2.msg"
- fail_3 is failed
- "'Image name must not be an image ID for source=pull' in fail_3.msg"
- fail_4 is failed
- "'Image name must not be an image ID for source=build' in fail_4.msg"
@@ -61,9 +61,9 @@
- assert:
that:
- push_1 is changed
- push_2 is not changed
- push_3 is not changed
- push_1 is changed
- push_2 is not changed
- push_3 is not changed
- name: Get facts of local image
docker_image_info:
@@ -102,11 +102,11 @@
- assert:
that:
- pull_1 is changed
- pull_2 is not changed
- facts_1.images | length == 1
- facts_2.images | length == 0
- facts_3.images | length == 1
- pull_1 is changed
- pull_2 is not changed
- facts_1.images | length == 1
- facts_2.images | length == 0
- facts_3.images | length == 1
- name: Pull image from test registry (with digest)
docker_image:
@@ -148,8 +148,8 @@
- assert:
that:
- push_1_different is changed
- push_2_different is not changed
- push_1_different is changed
- push_2_different is not changed
- name: Tag same image with new tag
docker_image:
@@ -178,24 +178,24 @@
- assert:
that:
# NOTE: This should be:
# - push_1_same is changed
# Unfortunately docker does *NOT* report whether the tag already existed or not.
# Here are the logs returned by client.push() for both tasks (which are exactly the same):
# push_1_same:
# {"status": "The push refers to repository [localhost:32796/test/hello-world]"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Preparing"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Layer already exists"},
# {"status": "newtag2: digest: sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b size: 528"},
# {"aux": {"Digest": "sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b", "Size": 528, "Tag": "newtag2"}, "progressDetail": {}}
# push_2_same:
# {"status": "The push refers to repository [localhost:32796/test/hello-world]"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Preparing"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Layer already exists"},
# {"status": "newtag2: digest: sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b size: 528"},
# {"aux": {"Digest": "sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b", "Size": 528, "Tag": "newtag2"}, "progressDetail": {}}
- push_1_same is not changed
- push_2_same is not changed
# NOTE: This should be:
# - push_1_same is changed
# Unfortunately docker does *NOT* report whether the tag already existed or not.
# Here are the logs returned by client.push() for both tasks (which are exactly the same):
# push_1_same:
# {"status": "The push refers to repository [localhost:32796/test/hello-world]"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Preparing"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Layer already exists"},
# {"status": "newtag2: digest: sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b size: 528"},
# {"aux": {"Digest": "sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b", "Size": 528, "Tag": "newtag2"}, "progressDetail": {}}
# push_2_same:
# {"status": "The push refers to repository [localhost:32796/test/hello-world]"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Preparing"},
# {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Layer already exists"},
# {"status": "newtag2: digest: sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b size: 528"},
# {"aux": {"Digest": "sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b", "Size": 528, "Tag": "newtag2"}, "progressDetail": {}}
- push_1_same is not changed
- push_2_same is not changed
####################################################################
## repository ######################################################
@@ -241,10 +241,10 @@
- assert:
that:
- repository_1 is changed
- repository_2 is not changed
- repository_3 is changed
- repository_4 is not changed
- repository_1 is changed
- repository_2 is not changed
- repository_3 is changed
- repository_4 is not changed
- name: Get facts of image
docker_image_info:
@@ -259,4 +259,4 @@
- assert:
that:
- facts_1.images | length == 1
- facts_1.images | length == 1
@@ -63,8 +63,8 @@
- assert:
that:
- buildargs_1 is changed
- buildargs_2 is not failed and buildargs_2 is not changed
- buildargs_1 is changed
- buildargs_2 is not failed and buildargs_2 is not changed
####################################################################
## build.container_limits ##########################################
@@ -102,14 +102,14 @@
- assert:
that:
# It *sometimes* happens that the first task does not fail.
# For now, we work around this by
# a) requiring that if it fails, the message must
# contain 'Minimum memory limit allowed is (4|6)MB', and
# b) requiring that either the first task, or the second
# task is changed, but not both.
- "not container_limits_1 is failed or ('Minimum memory limit allowed is ') in container_limits_1.msg"
- "container_limits_1 is changed or container_limits_2 is changed and not (container_limits_1 is changed and container_limits_2 is changed)"
# It *sometimes* happens that the first task does not fail.
# For now, we work around this by
# a) requiring that if it fails, the message must
# contain 'Minimum memory limit allowed is (4|6)MB', and
# b) requiring that either the first task, or the second
# task is changed, but not both.
- "not container_limits_1 is failed or ('Minimum memory limit allowed is ') in container_limits_1.msg"
- "container_limits_1 is changed or container_limits_2 is changed and not (container_limits_1 is changed and container_limits_2 is changed)"
####################################################################
## build.dockerfile ################################################
@@ -133,9 +133,9 @@
- assert:
that:
- dockerfile_1 is changed
- "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout"
- dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
- dockerfile_1 is changed
- "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout"
- dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
####################################################################
## build.platform ##################################################
@@ -177,8 +177,8 @@
- assert:
that:
- platform_1 is changed
- platform_2 is not failed and platform_2 is not changed
- platform_1 is changed
- platform_2 is not failed and platform_2 is not changed
####################################################################
## force ###########################################################
@@ -222,8 +222,8 @@
- assert:
that:
- force_1 is changed
- force_2 is not changed
- force_1 is changed
- force_2 is not changed
####################################################################
## load path #######################################################
@@ -350,15 +350,15 @@
- assert:
that:
- load_image is changed
- archive_image['image']['Id'] == load_image['image']['Id']
- load_image_1 is not changed
- load_image_2 is failed
- >-
("The archive did not contain image 'foo:bar'. Instead, found '" ~ docker_test_image_hello_world ~ "'.") == load_image_2.msg
- load_image_3 is failed
- '"Detected no loaded images. Archive potentially corrupt?" == load_image_3.msg'
- load_image_4 is not changed
- load_image is changed
- archive_image['image']['Id'] == load_image['image']['Id']
- load_image_1 is not changed
- load_image_2 is failed
- >-
("The archive did not contain image 'foo:bar'. Instead, found '" ~ docker_test_image_hello_world ~ "'.") == load_image_2.msg
- load_image_3 is failed
- '"Detected no loaded images. Archive potentially corrupt?" == load_image_3.msg'
- load_image_4 is not changed
####################################################################
## build.path ######################################################
@@ -416,8 +416,8 @@
- assert:
that:
- dockerfile_2 is changed
- dockerfile_2.image.Config.WorkingDir == '/first'
- dockerfile_2 is changed
- dockerfile_2.image.Config.WorkingDir == '/first'
####################################################################
## build.etc_hosts #################################################
@@ -51,8 +51,8 @@
- assert:
that:
- buildargs_1 is changed
- buildargs_2 is not changed
- buildargs_1 is changed
- buildargs_2 is not changed
####################################################################
## dockerfile ######################################################
@@ -72,9 +72,9 @@
- assert:
that:
- dockerfile_1 is changed
- "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stderr"
- dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
- dockerfile_1 is changed
- "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stderr"
- dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
####################################################################
## platform ########################################################
@@ -106,8 +106,8 @@
- assert:
that:
- platform_1 is changed
- platform_2 is not changed
- platform_1 is changed
- platform_2 is not changed
####################################################################
## target ##########################################################
@@ -128,8 +128,8 @@
- assert:
that:
- dockerfile_2 is changed
- dockerfile_2.image.Config.WorkingDir == '/first'
- dockerfile_2 is changed
- dockerfile_2.image.Config.WorkingDir == '/first'
####################################################################
## etc_hosts #######################################################
@@ -9,50 +9,50 @@
####################################################################
- block:
- name: Make sure image is not there
docker_image_remove:
name: "{{ docker_test_image_alpine_different }}"
- name: Make sure image is not there
docker_image_remove:
name: "{{ docker_test_image_alpine_different }}"
- name: Inspect a non-available image
docker_image_info:
name: "{{ docker_test_image_alpine_different }}"
register: result
- name: Inspect a non-available image
docker_image_info:
name: "{{ docker_test_image_alpine_different }}"
register: result
- assert:
that:
- "result.images|length == 0"
- assert:
that:
- "result.images|length == 0"
- name: Make sure images are there
docker_image_pull:
name: "{{ item }}"
loop:
- "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}"
- name: Make sure images are there
docker_image_pull:
name: "{{ item }}"
loop:
- "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}"
- name: Inspect an available image
docker_image_info:
name: "{{ docker_test_image_hello_world }}"
register: result
- name: Inspect an available image
docker_image_info:
name: "{{ docker_test_image_hello_world }}"
register: result
- assert:
that:
- "result.images|length == 1"
- "docker_test_image_hello_world in result.images[0].RepoTags"
- assert:
that:
- "result.images|length == 1"
- "docker_test_image_hello_world in result.images[0].RepoTags"
- name: Inspect multiple images
docker_image_info:
name:
- "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}"
register: result
- name: Inspect multiple images
docker_image_info:
name:
- "{{ docker_test_image_hello_world }}"
- "{{ docker_test_image_alpine }}"
register: result
- debug: var=result
- debug: var=result
- assert:
that:
- "result.images|length == 2"
- "docker_test_image_hello_world in result.images[0].RepoTags"
- "docker_test_image_alpine in result.images[1].RepoTags"
- assert:
that:
- "result.images|length == 2"
- "docker_test_image_hello_world in result.images[0].RepoTags"
- "docker_test_image_alpine in result.images[1].RepoTags"
when: docker_api_version is version('1.25', '>=')
@@ -117,55 +117,55 @@
- assert:
that:
- present_1_check is changed
- present_1_check.actions | length == 1
- present_1_check.actions[0] == ('Pulled image ' ~ image_name)
- present_1_check.diff.before.exists is false
- present_1_check.diff.after.id == 'unknown'
- present_1 is changed
- present_1.actions | length == 1
- present_1.actions[0] == ('Pulled image ' ~ image_name)
- present_1.diff.before.exists is false
- present_1.diff.after.id is string
- present_2_check is changed
- present_2_check.actions | length == 1
- present_2_check.actions[0] == ('Pulled image ' ~ image_name)
- present_2_check.diff.before.id == present_1.diff.after.id
- present_2_check.diff.after.id == 'unknown'
- present_2 is not changed
- present_2.actions | length == 1
- present_2.actions[0] == ('Pulled image ' ~ image_name)
- present_2.diff.before.id == present_1.diff.after.id
- present_2.diff.after.id == present_1.diff.after.id
- present_3_check is changed
- present_3_check.actions | length == 1
- present_3_check.actions[0] == ('Pulled image ' ~ image_name)
- present_3_check.diff.before.id == present_1.diff.after.id
- present_3_check.diff.after.id == 'unknown'
- present_3 is changed
- present_3.actions | length == 1
- present_3.actions[0] == ('Pulled image ' ~ image_name)
- present_3.diff.before.id == present_1.diff.after.id
- present_3.diff.after.id != present_1.diff.after.id
- present_3.diff.after.id is string
- present_4_check is not changed
- present_4_check.actions | length == 0
- present_4_check.diff.before.id == present_3.diff.after.id
- present_4_check.diff.after.id == present_3.diff.after.id
- present_4 is not changed
- present_4.actions | length == 0
- present_4.diff.before.id == present_3.diff.after.id
- present_4.diff.after.id == present_3.diff.after.id
- present_5_check is changed
- present_5_check.actions | length == 1
- present_5_check.actions[0] == ('Pulled image ' ~ image_name)
- present_5_check.diff.before.id == present_3.diff.after.id
- present_5_check.diff.after.id == 'unknown'
- present_5 is changed
- present_5.actions | length == 1
- present_5.actions[0] == ('Pulled image ' ~ image_name)
- present_5.diff.before.id == present_3.diff.after.id
- present_5.diff.after.id == present_1.diff.after.id
- present_1_check is changed
- present_1_check.actions | length == 1
- present_1_check.actions[0] == ('Pulled image ' ~ image_name)
- present_1_check.diff.before.exists is false
- present_1_check.diff.after.id == 'unknown'
- present_1 is changed
- present_1.actions | length == 1
- present_1.actions[0] == ('Pulled image ' ~ image_name)
- present_1.diff.before.exists is false
- present_1.diff.after.id is string
- present_2_check is changed
- present_2_check.actions | length == 1
- present_2_check.actions[0] == ('Pulled image ' ~ image_name)
- present_2_check.diff.before.id == present_1.diff.after.id
- present_2_check.diff.after.id == 'unknown'
- present_2 is not changed
- present_2.actions | length == 1
- present_2.actions[0] == ('Pulled image ' ~ image_name)
- present_2.diff.before.id == present_1.diff.after.id
- present_2.diff.after.id == present_1.diff.after.id
- present_3_check is changed
- present_3_check.actions | length == 1
- present_3_check.actions[0] == ('Pulled image ' ~ image_name)
- present_3_check.diff.before.id == present_1.diff.after.id
- present_3_check.diff.after.id == 'unknown'
- present_3 is changed
- present_3.actions | length == 1
- present_3.actions[0] == ('Pulled image ' ~ image_name)
- present_3.diff.before.id == present_1.diff.after.id
- present_3.diff.after.id != present_1.diff.after.id
- present_3.diff.after.id is string
- present_4_check is not changed
- present_4_check.actions | length == 0
- present_4_check.diff.before.id == present_3.diff.after.id
- present_4_check.diff.after.id == present_3.diff.after.id
- present_4 is not changed
- present_4.actions | length == 0
- present_4.diff.before.id == present_3.diff.after.id
- present_4.diff.after.id == present_3.diff.after.id
- present_5_check is changed
- present_5_check.actions | length == 1
- present_5_check.actions[0] == ('Pulled image ' ~ image_name)
- present_5_check.diff.before.id == present_3.diff.after.id
- present_5_check.diff.after.id == 'unknown'
- present_5 is changed
- present_5.actions | length == 1
- present_5.actions[0] == ('Pulled image ' ~ image_name)
- present_5.diff.before.id == present_3.diff.after.id
- present_5.diff.after.id == present_1.diff.after.id
always:
- name: cleanup
@@ -188,9 +188,9 @@
- assert:
that:
- fail_1 is failed
- >-
'Cannot pull an image by ID' == fail_1.msg
- fail_2 is failed
- >-
'"foo/bar" is not a valid docker tag!' == fail_2.msg
- fail_1 is failed
- >-
'Cannot pull an image by ID' == fail_1.msg
- fail_2 is failed
- >-
'"foo/bar" is not a valid docker tag!' == fail_2.msg
@@ -35,20 +35,20 @@
- assert:
that:
- present_1 is changed
- present_1.actions | length == 1
- present_1.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1)
- present_1.diff.before.exists is false
- present_1.diff.after.id is string
- present_2 is not changed
- present_2.actions | length == 1
- present_2.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1)
- present_2.diff.before.id == present_1.diff.after.id
- present_2.diff.after.id == present_1.diff.after.id
- present_3 is not changed
- present_3.actions | length == 0
- present_3.diff.before.id == present_1.diff.after.id
- present_3.diff.after.id == present_1.diff.after.id
- present_1 is changed
- present_1.actions | length == 1
- present_1.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1)
- present_1.diff.before.exists is false
- present_1.diff.after.id is string
- present_2 is not changed
- present_2.actions | length == 1
- present_2.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1)
- present_2.diff.before.id == present_1.diff.after.id
- present_2.diff.after.id == present_1.diff.after.id
- present_3 is not changed
- present_3.actions | length == 0
- present_3.diff.before.id == present_1.diff.after.id
- present_3.diff.after.id == present_1.diff.after.id
- name: Pull image 2 (check mode)
docker_image_pull:
@@ -67,17 +67,17 @@
- assert:
that:
- present_4 is changed
- present_4.actions | length == 1
- present_4.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2)
- present_4.diff.before.exists is false
- present_4.diff.after.id == 'unknown'
- present_5 is changed
- present_5.actions | length == 1
- present_5.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2)
- present_5.diff.before.exists is false
- present_5.diff.after.id != present_1.diff.after.id
- present_5.diff.after.id is string
- present_4 is changed
- present_4.actions | length == 1
- present_4.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2)
- present_4.diff.before.exists is false
- present_4.diff.after.id == 'unknown'
- present_5 is changed
- present_5.actions | length == 1
- present_5.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2)
- present_5.diff.before.exists is false
- present_5.diff.after.id != present_1.diff.after.id
- present_5.diff.after.id is string
always:
- name: cleanup
@@ -103,24 +103,24 @@
- assert:
that:
- pull_1_check is changed
- pull_1_check.diff.before.exists is false
- pull_1_check.diff.after.id == 'unknown'
- pull_1 is changed
- pull_1.diff.before.exists is false
- pull_1.diff.after.id == facts_1.images[0].Id
- pull_2_check is not changed
- pull_2_check.diff.before.id == facts_1.images[0].Id
- pull_2_check.diff.before == pull_2.diff.after
- pull_2 is not changed
- pull_2.diff.before.id == facts_1.images[0].Id
- pull_2.diff.before == pull_2.diff.after
- pull_3_check is changed
- pull_3_check.diff.before.id == facts_1.images[0].Id
- pull_3_check.diff.after.id == 'unknown'
- pull_3 is not changed
- pull_3.diff.before.id == facts_1.images[0].Id
- pull_3.diff.before == pull_2.diff.after
- facts_1.images | length == 1
- facts_2.images | length == 0
- facts_3.images | length == 1
- pull_1_check is changed
- pull_1_check.diff.before.exists is false
- pull_1_check.diff.after.id == 'unknown'
- pull_1 is changed
- pull_1.diff.before.exists is false
- pull_1.diff.after.id == facts_1.images[0].Id
- pull_2_check is not changed
- pull_2_check.diff.before.id == facts_1.images[0].Id
- pull_2_check.diff.before == pull_2.diff.after
- pull_2 is not changed
- pull_2.diff.before.id == facts_1.images[0].Id
- pull_2.diff.before == pull_2.diff.after
- pull_3_check is changed
- pull_3_check.diff.before.id == facts_1.images[0].Id
- pull_3_check.diff.after.id == 'unknown'
- pull_3 is not changed
- pull_3.diff.before.id == facts_1.images[0].Id
- pull_3.diff.before == pull_2.diff.after
- facts_1.images | length == 1
- facts_2.images | length == 0
- facts_3.images | length == 1
@@ -43,18 +43,18 @@
- assert:
that:
- fail_1 is failed
- >-
'Cannot find image registry.example.com:5000/foo/bar:baz' == fail_1.msg
- fail_2 is failed
- >-
'Cannot push an image by ID' == fail_2.msg
- fail_3 is failed
- >-
'Cannot push an image by digest' == fail_3.msg
- fail_4 is failed
- >-
'"foo/bar" is not a valid docker tag!' == fail_4.msg
- fail_5 is failed
- >-
'"foo bar" is not a valid docker tag!' == fail_5.msg
- fail_1 is failed
- >-
'Cannot find image registry.example.com:5000/foo/bar:baz' == fail_1.msg
- fail_2 is failed
- >-
'Cannot push an image by ID' == fail_2.msg
- fail_3 is failed
- >-
'Cannot push an image by digest' == fail_3.msg
- fail_4 is failed
- >-
'"foo/bar" is not a valid docker tag!' == fail_4.msg
- fail_5 is failed
- >-
'"foo bar" is not a valid docker tag!' == fail_5.msg
@@ -4,147 +4,147 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Log out server
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: absent
- name: Log out server
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: absent
- name: Log in with wrong password (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed_check
ignore_errors: true
check_mode: true
- name: Log in with wrong password (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed_check
ignore_errors: true
check_mode: true
- name: Log in with wrong password
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed
ignore_errors: true
- name: Log in with wrong password
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed
ignore_errors: true
- name: Make sure that login failed
assert:
that:
- login_failed_check is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed_check.msg"
- login_failed is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed.msg"
- name: Make sure that login failed
assert:
that:
- login_failed_check is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed_check.msg"
- login_failed is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed.msg"
- name: Log in (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_1
check_mode: true
- name: Log in (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_1
check_mode: true
- name: Log in
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_2
- name: Log in
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_2
- name: Get permissions of ~/.docker/config.json
stat:
path: ~/.docker/config.json
register: login_2_stat
- name: Get permissions of ~/.docker/config.json
stat:
path: ~/.docker/config.json
register: login_2_stat
- name: Log in (idempotent)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_3
- name: Log in (idempotent)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_3
- name: Log in (idempotent, check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_4
check_mode: true
- name: Log in (idempotent, check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_4
check_mode: true
- name: Make sure that login worked
assert:
that:
- login_1 is changed
- login_2 is changed
- login_3 is not changed
- login_4 is not changed
- login_2_stat.stat.mode == '0600'
- name: Make sure that login worked
assert:
that:
- login_1 is changed
- login_2 is changed
- login_3 is not changed
- login_4 is not changed
- login_2_stat.stat.mode == '0600'
- name: Log in again with wrong password (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed_check
ignore_errors: true
check_mode: true
- name: Log in again with wrong password (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed_check
ignore_errors: true
check_mode: true
- name: Log in again with wrong password
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed
ignore_errors: true
- name: Log in again with wrong password
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: "1234"
state: present
register: login_failed
ignore_errors: true
- name: Make sure that login failed again
assert:
that:
- login_failed_check is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed_check.msg"
- login_failed is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed.msg"
- name: Make sure that login failed again
assert:
that:
- login_failed_check is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed_check.msg"
- login_failed is failed
- "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed.msg"
- name: Log out (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_1
check_mode: true
- name: Log out (check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_1
check_mode: true
- name: Log out
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_2
- name: Log out
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_2
- name: Log out (idempotent)
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_3
- name: Log out (idempotent)
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_3
- name: Log out (idempotent, check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_4
check_mode: true
- name: Log out (idempotent, check mode)
docker_login:
registry_url: "{{ registry_frontend_address }}"
state: absent
register: logout_4
check_mode: true
- name: Make sure that login worked
assert:
that:
- logout_1 is changed
- logout_2 is changed
- logout_3 is not changed
- logout_4 is not changed
- name: Make sure that login worked
assert:
that:
- logout_1 is changed
- logout_2 is changed
- logout_3 is not changed
- logout_4 is not changed
when: registry_frontend_address != 'n/a'
@@ -4,58 +4,58 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Log out server 1
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: absent
- name: Log out server 1
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: absent
- name: Log out server 2
docker_login:
registry_url: "{{ registry_frontend2_address }}"
username: testuser
password: hunter2
state: absent
- name: Log out server 2
docker_login:
registry_url: "{{ registry_frontend2_address }}"
username: testuser
password: hunter2
state: absent
- name: Log in server 1
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_1
- name: Log in server 1
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_1
- name: Log in server 2
docker_login:
registry_url: "{{ registry_frontend2_address }}"
username: testuser
password: hunter2
state: present
register: login_2
- name: Log in server 2
docker_login:
registry_url: "{{ registry_frontend2_address }}"
username: testuser
password: hunter2
state: present
register: login_2
- name: Log in server 1 (idempotent)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_1_2
- name: Log in server 1 (idempotent)
docker_login:
registry_url: "{{ registry_frontend_address }}"
username: testuser
password: hunter2
state: present
register: login_1_2
- name: Log in server 2 (idempotent)
docker_login:
registry_url: "{{ registry_frontend2_address }}"
username: testuser
password: hunter2
state: present
register: login_2_2
- name: Log in server 2 (idempotent)
docker_login:
registry_url: "{{ registry_frontend2_address }}"
username: testuser
password: hunter2
state: present
register: login_2_2
- name: Make sure that login worked
assert:
that:
- login_1 is changed
- login_2 is changed
- login_1_2 is not changed
- login_2_2 is not changed
- name: Make sure that login worked
assert:
that:
- login_1 is changed
- login_2 is changed
- login_1_2 is not changed
- login_2_2 is not changed
when: registry_frontend_address != 'n/a' and registry_frontend2_address != 'n/a'
@@ -22,9 +22,9 @@
command: /bin/sleep 10m
state: started
loop:
- "{{ cname_1 }}"
- "{{ cname_2 }}"
- "{{ cname_3 }}"
- "{{ cname_1 }}"
- "{{ cname_2 }}"
- "{{ cname_3 }}"
loop_control:
loop_var: container_name
@@ -41,7 +41,7 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_1 }}"
- "{{ cname_1 }}"
register: networks_2
- name: Connect network to containers 1 (idempotency)
@@ -49,7 +49,7 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_1 }}"
- "{{ cname_1 }}"
register: networks_2_idem
- name: Connect network to containers 1 and 2
@@ -57,8 +57,8 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_1 }}"
- "{{ cname_2 }}"
- "{{ cname_1 }}"
- "{{ cname_2 }}"
register: networks_3
- name: Connect network to containers 1 and 2 (idempotency)
@@ -66,8 +66,8 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_1 }}"
- "{{ cname_2 }}"
- "{{ cname_1 }}"
- "{{ cname_2 }}"
register: networks_3_idem
- name: Connect network to container 3
@@ -75,7 +75,7 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_3 }}"
- "{{ cname_3 }}"
appends: true
register: networks_4
@@ -84,7 +84,7 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_3 }}"
- "{{ cname_3 }}"
appends: true
register: networks_4_idem
@@ -93,8 +93,8 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_2 }}"
- "{{ cname_3 }}"
- "{{ cname_2 }}"
- "{{ cname_3 }}"
register: networks_5
- name: Disconnect network from container 1 (idempotency)
@@ -102,8 +102,8 @@
name: "{{ nname_1 }}"
state: present
connected:
- "{{ cname_2 }}"
- "{{ cname_3 }}"
- "{{ cname_2 }}"
- "{{ cname_3 }}"
register: networks_5_idem
- name: Cleanup
@@ -113,15 +113,15 @@
- assert:
that:
- networks_1 is changed
- networks_2 is changed
- networks_2_idem is not changed
- networks_3 is changed
- networks_3_idem is not changed
- networks_4 is changed
- networks_4_idem is not changed
- networks_5 is changed
- networks_5_idem is not changed
- networks_1 is changed
- networks_2 is changed
- networks_2_idem is not changed
- networks_3 is changed
- networks_3_idem is not changed
- networks_4 is changed
- networks_4_idem is not changed
- networks_5 is changed
- networks_5_idem is not changed
####################################################################
@@ -131,8 +131,8 @@
state: absent
force_kill: true
loop:
- "{{ cname_1 }}"
- "{{ cname_2 }}"
- "{{ cname_3 }}"
- "{{ cname_1 }}"
- "{{ cname_2 }}"
- "{{ cname_3 }}"
loop_control:
loop_var: container_name
@@ -200,71 +200,71 @@
#################### multiple IPv4 networks ####################
- block:
- name: Create network with two IPv4 IPAM configs
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.120.0/24
- subnet: 10.26.121.0/24
register: network
- name: Create network with two IPv4 IPAM configs
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.120.0/24
- subnet: 10.26.121.0/24
register: network
- assert:
that:
- network is changed
- assert:
that:
- network is changed
- name: Create network with two IPv4 IPAM configs (idempotence)
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.121.0/24
- subnet: 10.26.120.0/24
register: network
- name: Create network with two IPv4 IPAM configs (idempotence)
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.121.0/24
- subnet: 10.26.120.0/24
register: network
- assert:
that:
- network is not changed
- assert:
that:
- network is not changed
- name: Create network with two IPv4 IPAM configs (change)
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.120.0/24
- subnet: 10.26.122.0/24
register: network
diff: true
- name: Create network with two IPv4 IPAM configs (change)
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.120.0/24
- subnet: 10.26.122.0/24
register: network
diff: true
- assert:
that:
- network is changed
- network.diff.differences | length == 1
- assert:
that:
- network is changed
- network.diff.differences | length == 1
- name: Create network with one IPv4 IPAM config (no change)
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.122.0/24
register: network
- name: Create network with one IPv4 IPAM config (no change)
docker_network:
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.122.0/24
register: network
- assert:
that:
- network is not changed
- assert:
that:
- network is not changed
- name: Cleanup network
docker_network:
name: "{{ nname_ipam_3 }}"
state: absent
- name: Cleanup network
docker_network:
name: "{{ nname_ipam_3 }}"
state: absent
when: ansible_facts.virtualization_type != 'docker' and ansible_default_ipv4.alias is defined
@@ -40,9 +40,9 @@
- assert:
that:
- internal_1 is changed
- internal_2 is not changed
- internal_3 is changed
- internal_1 is changed
- internal_2 is not changed
- internal_3 is changed
####################################################################
## driver_options ##################################################
@@ -91,62 +91,62 @@
- assert:
that:
- driver_options_1 is changed
- driver_options_2 is not changed
- driver_options_3 is not changed
- driver_options_4 is changed
- driver_options_5 is not changed
- driver_options_1 is changed
- driver_options_2 is not changed
- driver_options_3 is not changed
- driver_options_4 is changed
- driver_options_5 is not changed
####################################################################
## scope ###########################################################
####################################################################
- block:
- name: scope
docker_network:
name: "{{ nname_1 }}"
driver: bridge
scope: local
register: scope_1
- name: scope
docker_network:
name: "{{ nname_1 }}"
driver: bridge
scope: local
register: scope_1
- name: scope (idempotency)
docker_network:
name: "{{ nname_1 }}"
driver: bridge
scope: local
register: scope_2
- name: scope (idempotency)
docker_network:
name: "{{ nname_1 }}"
driver: bridge
scope: local
register: scope_2
- name: swarm
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: swarm
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
# Driver change alongside scope is intentional - bridge doesn't appear to support anything but local, and overlay can't downgrade to local. Additionally, overlay reports as swarm for swarm OR global, so no change is reported in that case.
# Test output indicates that the scope is altered, at least, so manual inspection will be required to verify this going forward, unless we come up with a test driver that supports multiple scopes.
- name: scope (change)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
scope: swarm
register: scope_3
# Driver change alongside scope is intentional - bridge doesn't appear to support anything but local, and overlay can't downgrade to local. Additionally, overlay reports as swarm for swarm OR global, so no change is reported in that case.
# Test output indicates that the scope is altered, at least, so manual inspection will be required to verify this going forward, unless we come up with a test driver that supports multiple scopes.
- name: scope (change)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
scope: swarm
register: scope_3
- name: cleanup network
docker_network:
name: "{{ nname_1 }}"
state: absent
force: true
- name: cleanup network
docker_network:
name: "{{ nname_1 }}"
state: absent
force: true
- assert:
that:
- scope_1 is changed
- scope_2 is not changed
- scope_3 is changed
- assert:
that:
- scope_1 is changed
- scope_2 is not changed
- scope_3 is changed
always:
- name: cleanup swarm
docker_swarm:
state: absent
force: true
- name: cleanup swarm
docker_swarm:
state: absent
force: true
####################################################################
## attachable ######################################################
@@ -158,21 +158,21 @@
attachable: true
register: attachable_1
ignore_errors: true
- name: attachable (idempotency)
docker_network:
name: "{{ nname_1 }}"
attachable: true
register: attachable_2
ignore_errors: true
- name: attachable (change)
docker_network:
name: "{{ nname_1 }}"
attachable: false
register: attachable_3
ignore_errors: true
- name: cleanup
docker_network:
name: "{{ nname_1 }}"
@@ -181,9 +181,9 @@
- assert:
that:
- attachable_1 is changed
- attachable_2 is not changed
- attachable_3 is changed
- attachable_1 is changed
- attachable_2 is not changed
- attachable_3 is changed
####################################################################
## labels ##########################################################
@@ -228,7 +228,7 @@
- assert:
that:
- labels_1 is changed
- labels_2 is not changed
- labels_3 is not changed
- labels_4 is changed
- labels_1 is changed
- labels_2 is not changed
- labels_3 is not changed
- labels_4 is changed
@@ -11,94 +11,94 @@
dnetworks: "{{ dnetworks + [nname_1] }}"
- block:
# Overlay networks require swarm initialization before they'll work
- name: swarm
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
# Overlay networks require swarm initialization before they'll work
- name: swarm
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
####################################################################
## overlay #########################################################
####################################################################
####################################################################
## overlay #########################################################
####################################################################
- name: overlay
docker_network:
name: "{{ nname_1 }}"
driver: overlay
driver_options:
com.docker.network.driver.overlay.vxlanid_list: "257"
register: overlay_1
- name: overlay
docker_network:
name: "{{ nname_1 }}"
driver: overlay
driver_options:
com.docker.network.driver.overlay.vxlanid_list: "257"
register: overlay_1
- name: overlay (idempotency)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
driver_options:
com.docker.network.driver.overlay.vxlanid_list: "257"
register: overlay_2
- name: overlay (idempotency)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
driver_options:
com.docker.network.driver.overlay.vxlanid_list: "257"
register: overlay_2
- name: overlay (change)
docker_network:
name: "{{ nname_1 }}"
driver: bridge
register: overlay_3
- name: overlay (change)
docker_network:
name: "{{ nname_1 }}"
driver: bridge
register: overlay_3
- name: cleanup network
docker_network:
name: "{{ nname_1 }}"
state: absent
force: true
- name: cleanup network
docker_network:
name: "{{ nname_1 }}"
state: absent
force: true
- assert:
that:
- overlay_1 is changed
- overlay_2 is not changed
- overlay_3 is changed
- assert:
that:
- overlay_1 is changed
- overlay_2 is not changed
- overlay_3 is changed
####################################################################
## ingress #########################################################
####################################################################
####################################################################
## ingress #########################################################
####################################################################
- name: cleanup default swarm ingress network
docker_network:
name: ingress
state: absent
- name: cleanup default swarm ingress network
docker_network:
name: ingress
state: absent
- name: ingress
docker_network:
name: "{{ nname_1 }}"
driver: overlay
ingress: true
register: ingress_1
- name: ingress
docker_network:
name: "{{ nname_1 }}"
driver: overlay
ingress: true
register: ingress_1
- name: ingress (idempotency)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
ingress: true
register: ingress_2
- name: ingress (idempotency)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
ingress: true
register: ingress_2
- name: ingress (change)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
ingress: false
register: ingress_3
- name: ingress (change)
docker_network:
name: "{{ nname_1 }}"
driver: overlay
ingress: false
register: ingress_3
- name: cleanup network
docker_network:
name: "{{ nname_1 }}"
state: absent
force: true
- name: cleanup network
docker_network:
name: "{{ nname_1 }}"
state: absent
force: true
- assert:
that:
- ingress_1 is changed
- ingress_2 is not changed
- ingress_3 is changed
- assert:
that:
- ingress_1 is changed
- ingress_2 is not changed
- ingress_3 is changed
always:
- name: cleanup swarm
docker_swarm:
state: absent
force: true
- name: cleanup swarm
docker_swarm:
state: absent
force: true
@@ -30,12 +30,12 @@
name: "{{ network_name }}"
state: absent
loop:
- "{{ nname_1 }}"
- "{{ nname_2 }}"
- "{{ nname_1 }}"
- "{{ nname_2 }}"
loop_control:
loop_var: network_name
- assert:
that:
- networks_1 is changed
- networks_2 is changed
- networks_1 is changed
- networks_2 is changed
@@ -9,70 +9,70 @@
####################################################################
- block:
- name: Create random network name
set_fact:
nname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Create random network name
set_fact:
nname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Make sure network is not there
docker_network:
name: "{{ nname }}"
state: absent
force: true
- name: Make sure network is not there
docker_network:
name: "{{ nname }}"
state: absent
force: true
- name: Inspect a non-present network
docker_network_info:
name: "{{ nname }}"
register: result
- name: Inspect a non-present network
docker_network_info:
name: "{{ nname }}"
register: result
- assert:
that:
- "not result.exists"
- "'network' in result"
- "result.network is none"
- assert:
that:
- "not result.exists"
- "'network' in result"
- "result.network is none"
- name: Make sure network exists
docker_network:
name: "{{ nname }}"
state: present
- name: Make sure network exists
docker_network:
name: "{{ nname }}"
state: present
- name: Inspect a present network
docker_network_info:
name: "{{ nname }}"
register: result
- name: Dump docker_network_info result
debug: var=result
- name: Inspect a present network
docker_network_info:
name: "{{ nname }}"
register: result
- name: Dump docker_network_info result
debug: var=result
- name: "Comparison: use 'docker network inspect'"
command: docker network inspect "{{ nname }}"
register: docker_inspect
ignore_errors: true
- block:
- set_fact:
docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
- name: Dump docker inspect result
debug: var=docker_inspect_result
when: docker_inspect is not failed
- name: "Comparison: use 'docker network inspect'"
command: docker network inspect "{{ nname }}"
register: docker_inspect
ignore_errors: true
- block:
- set_fact:
docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
- name: Dump docker inspect result
debug: var=docker_inspect_result
when: docker_inspect is not failed
- name: Cleanup
docker_network:
name: "{{ nname }}"
state: absent
force: true
- name: Cleanup
docker_network:
name: "{{ nname }}"
state: absent
force: true
- assert:
that:
- result.exists
- "'network' in result"
- "result.network is truthy"
- assert:
that:
- result.exists
- "'network' in result"
- "result.network is truthy"
- assert:
that:
- "result.network == docker_inspect_result[0]"
when: docker_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_inspect.stderr"
when: docker_inspect is failed
- assert:
that:
- "result.network == docker_inspect_result[0]"
when: docker_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_inspect.stderr"
when: docker_inspect is failed
when: docker_api_version is version('1.25', '>=')
@@ -10,30 +10,30 @@
# Run the tests
- block:
- include_tasks: test_node.yml
- include_tasks: test_node.yml
always:
- name: Cleanup (trying)
docker_swarm:
state: absent
force: true
diff: false
ignore_errors: true
- name: Cleanup (trying)
docker_swarm:
state: absent
force: true
diff: false
ignore_errors: true
- name: Restart docker daemon
service:
name: docker
state: restarted
become: true
- name: Wait for docker daemon to be fully restarted
command: docker ps
ignore_errors: true
- name: Restart docker daemon
service:
name: docker
state: restarted
become: true
- name: Wait for docker daemon to be fully restarted
command: docker ps
ignore_errors: true
- name: Cleanup
docker_swarm:
state: absent
force: true
diff: false
- name: Cleanup
docker_swarm:
state: absent
force: true
diff: false
when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')
File diff suppressed because it is too large Load Diff
@@ -4,89 +4,89 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Try to get docker_node_info when docker is not running in swarm mode
docker_node_info:
ignore_errors: true
register: output
- name: Try to get docker_node_info when docker is not running in swarm mode
docker_node_info:
ignore_errors: true
register: output
- name: assert failure when called when swarm is not in use or not run on manager node
assert:
that:
- 'output is failed'
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
- name: assert failure when called when swarm is not in use or not run on manager node
assert:
that:
- 'output is failed'
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
register: output
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
register: output
- name: assert changed when create a new swarm cluster
assert:
that:
- 'output is changed'
- '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- name: assert changed when create a new swarm cluster
assert:
that:
- 'output is changed'
- '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- name: Try to get docker_node_info when docker is running in swarm mode and as manager
docker_node_info:
register: output
- name: Try to get docker_node_info when docker is running in swarm mode and as manager
docker_node_info:
register: output
- name: assert reading docker swarm node facts
assert:
that:
- 'output.nodes | length > 0'
- 'output.nodes[0].ID is string'
- name: assert reading docker swarm node facts
assert:
that:
- 'output.nodes | length > 0'
- 'output.nodes[0].ID is string'
- name: Try to get docker_node_info using the self parameter
docker_node_info:
self: true
register: output
- name: Try to get docker_node_info using the self parameter
docker_node_info:
self: true
register: output
- name: assert reading swarm facts with list of nodes option
assert:
that:
- 'output.nodes | length == 1'
- 'output.nodes[0].ID is string'
- name: assert reading swarm facts with list of nodes option
assert:
that:
- 'output.nodes | length == 1'
- 'output.nodes[0].ID is string'
- name: Get local docker node name
set_fact:
localnodename: "{{ output.nodes[0].Description.Hostname }}"
- name: Get local docker node name
set_fact:
localnodename: "{{ output.nodes[0].Description.Hostname }}"
- name: Try to get docker_node_info using the local node name as parameter
docker_node_info:
name: "{{ localnodename }}"
register: output
- name: Try to get docker_node_info using the local node name as parameter
docker_node_info:
name: "{{ localnodename }}"
register: output
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.nodes | length == 1'
- 'output.nodes[0].ID is string'
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.nodes | length == 1'
- 'output.nodes[0].ID is string'
- name: Create random name
set_fact:
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
- name: Create random name
set_fact:
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
- name: Try to get docker_node_info using random node name as parameter
docker_node_info:
name: "{{ randomnodename }}"
register: output
- name: Try to get docker_node_info using random node name as parameter
docker_node_info:
name: "{{ randomnodename }}"
register: output
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.nodes | length == 0'
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.nodes | length == 0'
always:
- name: Cleanup
docker_swarm:
state: absent
force: true
- name: Cleanup
docker_swarm:
state: absent
force: true
@@ -126,22 +126,22 @@
- assert:
that:
- create_1_check is changed
- create_1 is changed
- create_2_check is not changed
- create_2 is not changed
- create_3_check is changed
- create_3 is changed
- create_4_check is not changed
- create_4 is not changed
- absent_1_check is changed
- absent_1 is changed
- absent_2_check is not changed
- absent_2 is not changed
- absent_3_check is changed
- absent_3 is changed
- absent_4_check is not changed
- absent_4 is not changed
- create_1_check is changed
- create_1 is changed
- create_2_check is not changed
- create_2 is not changed
- create_3_check is changed
- create_3 is changed
- create_4_check is not changed
- create_4 is not changed
- absent_1_check is changed
- absent_1 is changed
- absent_2_check is not changed
- absent_2 is not changed
- absent_3_check is changed
- absent_3 is changed
- absent_4_check is not changed
- absent_4 is not changed
############ Plugin_Options ############
########################################
@@ -186,7 +186,7 @@
- assert:
that:
- create_1 is changed
- create_2 is not changed
- update_1 is changed
- update_2 is not changed
- create_1 is changed
- create_2 is not changed
- update_1 is changed
- update_2 is not changed
@@ -66,14 +66,14 @@
- assert:
that:
- create_1 is changed
- create_2 is not changed
- create_3 is changed
- create_4 is not changed
- absent_1 is changed
- absent_2 is not changed
- absent_3 is changed
- absent_4 is not changed
- create_1 is changed
- create_2 is not changed
- create_3 is changed
- create_4 is not changed
- absent_1 is changed
- absent_2 is not changed
- absent_3 is changed
- absent_4 is not changed
- name: Cleanup plugin with an alias
docker_plugin:
@@ -15,159 +15,159 @@
vname: "{{ 'ansible-volume-%0x' % ((2**32) | random) }}"
- block:
# Create objects to be pruned
- name: Create container (without volume)
docker_container:
name: "{{ cname }}"
image: "{{ docker_test_image_hello_world }}"
state: present
register: container
- name: Create network
docker_network:
name: "{{ nname }}"
state: present
register: network
- name: Create named volume
docker_volume:
name: "{{ vname }}"
state: present
register: volume
- name: Create anonymous volume
command: docker volume create
register: volume_anon
# Create objects to be pruned
- name: Create container (without volume)
docker_container:
name: "{{ cname }}"
image: "{{ docker_test_image_hello_world }}"
state: present
register: container
- name: Create network
docker_network:
name: "{{ nname }}"
state: present
register: network
- name: Create named volume
docker_volume:
name: "{{ vname }}"
state: present
register: volume
- name: Create anonymous volume
command: docker volume create
register: volume_anon
- name: List volumes
command: docker volume list
- name: List volumes
command: docker volume list
# Prune objects
- name: Prune everything
docker_prune:
containers: true
images: true
networks: true
volumes: true
builder_cache: true
register: result
# Analyze result
- name: Show results
debug:
var: result
- name: General checks
assert:
that:
- result is changed
# containers
- container.container.Id in result.containers
- "'containers_space_reclaimed' in result"
# images
- "'images_space_reclaimed' in result"
# networks
- network.network.Name in result.networks
# volumes
- volume_anon.stdout in result.volumes
- "'volumes_space_reclaimed' in result"
# builder_cache
- "'builder_cache_space_reclaimed' in result"
- name: API-version specific volumes check (API version before 1.42)
assert:
that:
# For API version 1.41 and before, pruning always considers all volumes
- volume.volume.Name in result.volumes
when: docker_api_version is version('1.42', '<')
- name: API-version specific volumes check (API version 1.42+)
assert:
that:
# For API version 1.41 and before, pruning considers only anonymous volumes,
# so our named container is not removed
- volume.volume.Name not in result.volumes
when: docker_api_version is version('1.42', '>=')
# Prune objects again
- name: Prune everything again (should have no change)
docker_prune:
containers: true
images: true
networks: true
volumes: true
builder_cache: true
register: result
# Analyze result
- name: Show results
debug:
var: result
- name: General checks
assert:
that:
- result is not changed
# containers
- result.containers == []
- result.containers_space_reclaimed == 0
# images
- result.images == []
- result.images_space_reclaimed == 0
# networks
- result.networks == []
# volumes
- result.volumes == []
# builder_cache
- result.builder_cache_space_reclaimed == 0
# Test with filters
- name: Prune with filters
docker_prune:
images: true
images_filters:
dangling: true
register: result
- name: Show results
debug:
var: result
- name: Prune build cache (API version 1.39+)
when: docker_api_version is version('1.39', '>=')
block:
- name: Prune build cache with option
docker_prune:
builder_cache: true
builder_cache_all: true
builder_cache_filters:
until: 10m
builder_cache_keep_storage: 1MB
register: result
- name: Show results
debug:
var: result
- name: Check results
assert:
that:
- "'builder_cache_space_reclaimed' in result"
- "'builder_cache_caches_deleted' in result"
- name: Prune volumes with all filter (API version 1.42+)
when: docker_api_version is version('1.42', '>=')
block:
- name: Prune with filters
# Prune objects
- name: Prune everything
docker_prune:
containers: true
images: true
networks: true
volumes: true
volumes_filters:
all: true
builder_cache: true
register: result
# Analyze result
- name: Show results
debug:
var: result
- name: Check results
- name: General checks
assert:
that:
- result is changed
- volume.volume.Name in result.volumes
# containers
- container.container.Id in result.containers
- "'containers_space_reclaimed' in result"
# images
- "'images_space_reclaimed' in result"
# networks
- network.network.Name in result.networks
# volumes
- volume_anon.stdout in result.volumes
- "'volumes_space_reclaimed' in result"
# builder_cache
- "'builder_cache_space_reclaimed' in result"
- name: API-version specific volumes check (API version before 1.42)
assert:
that:
# For API version 1.41 and before, pruning always considers all volumes
- volume.volume.Name in result.volumes
when: docker_api_version is version('1.42', '<')
- name: API-version specific volumes check (API version 1.42+)
assert:
that:
# For API version 1.41 and before, pruning considers only anonymous volumes,
# so our named container is not removed
- volume.volume.Name not in result.volumes
when: docker_api_version is version('1.42', '>=')
# Prune objects again
- name: Prune everything again (should have no change)
docker_prune:
containers: true
images: true
networks: true
volumes: true
builder_cache: true
register: result
# Analyze result
- name: Show results
debug:
var: result
- name: General checks
assert:
that:
- result is not changed
# containers
- result.containers == []
- result.containers_space_reclaimed == 0
# images
- result.images == []
- result.images_space_reclaimed == 0
# networks
- result.networks == []
# volumes
- result.volumes == []
# builder_cache
- result.builder_cache_space_reclaimed == 0
# Test with filters
- name: Prune with filters
docker_prune:
images: true
images_filters:
dangling: true
register: result
- name: Show results
debug:
var: result
- name: Prune build cache (API version 1.39+)
when: docker_api_version is version('1.39', '>=')
block:
- name: Prune build cache with option
docker_prune:
builder_cache: true
builder_cache_all: true
builder_cache_filters:
until: 10m
builder_cache_keep_storage: 1MB
register: result
- name: Show results
debug:
var: result
- name: Check results
assert:
that:
- "'builder_cache_space_reclaimed' in result"
- "'builder_cache_caches_deleted' in result"
- name: Prune volumes with all filter (API version 1.42+)
when: docker_api_version is version('1.42', '>=')
block:
- name: Prune with filters
docker_prune:
volumes: true
volumes_filters:
all: true
register: result
- name: Show results
debug:
var: result
- name: Check results
assert:
that:
- result is changed
- volume.volume.Name in result.volumes
- "'volumes_space_reclaimed' in result"
when: docker_api_version is version('1.25', '>=')
@@ -4,219 +4,219 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Parameter name should be required
docker_secret:
state: present
ignore_errors: true
register: output
- name: Parameter name should be required
docker_secret:
state: present
ignore_errors: true
register: output
- name: assert failure when called with no name
assert:
that:
- 'output.failed'
- 'output.msg == "missing required arguments: name"'
- name: assert failure when called with no name
assert:
that:
- 'output.failed'
- 'output.msg == "missing required arguments: name"'
- name: Test parameters
docker_secret:
name: foo
state: present
ignore_errors: true
register: output
- name: Test parameters
docker_secret:
name: foo
state: present
ignore_errors: true
register: output
- name: assert failure when called with no data
assert:
that:
- 'output.failed'
- 'output.msg == "state is present but any of the following are missing: data, data_src"'
- name: assert failure when called with no data
assert:
that:
- 'output.failed'
- 'output.msg == "state is present but any of the following are missing: data, data_src"'
- name: Create secret
docker_secret:
name: db_password
data: opensesame!
state: present
register: output
- name: Create secret
docker_secret:
name: db_password
data: opensesame!
state: present
register: output
- name: Create variable secret_id
set_fact:
secret_id: "{{ output.secret_id }}"
- name: Create variable secret_id
set_fact:
secret_id: "{{ output.secret_id }}"
- name: Inspect secret
command: "docker secret inspect {{ secret_id }}"
register: inspect
ignore_errors: true
- name: Inspect secret
command: "docker secret inspect {{ secret_id }}"
register: inspect
ignore_errors: true
- debug: var=inspect
- debug: var=inspect
- name: assert secret creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: assert secret creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: Create secret again
docker_secret:
name: db_password
data: opensesame!
state: present
register: output
- name: Create secret again
docker_secret:
name: db_password
data: opensesame!
state: present
register: output
- name: assert create secret is idempotent
assert:
that:
- not output.changed
- name: assert create secret is idempotent
assert:
that:
- not output.changed
- name: Write secret into file
copy:
dest: "{{ remote_tmp_dir }}/data"
content: |-
opensesame!
- name: Write secret into file
copy:
dest: "{{ remote_tmp_dir }}/data"
content: |-
opensesame!
- name: Create secret again (from file)
docker_secret:
name: db_password
data_src: "{{ remote_tmp_dir }}/data"
state: present
register: output
- name: Create secret again (from file)
docker_secret:
name: db_password
data_src: "{{ remote_tmp_dir }}/data"
state: present
register: output
- name: assert create secret is idempotent
assert:
that:
- not output.changed
- name: assert create secret is idempotent
assert:
that:
- not output.changed
- name: Create secret again (base64)
docker_secret:
name: db_password
data: b3BlbnNlc2FtZSE=
data_is_b64: true
state: present
register: output
- name: Create secret again (base64)
docker_secret:
name: db_password
data: b3BlbnNlc2FtZSE=
data_is_b64: true
state: present
register: output
- name: assert create secret (base64) is idempotent
assert:
that:
- not output.changed
- name: assert create secret (base64) is idempotent
assert:
that:
- not output.changed
- name: Update secret
docker_secret:
name: db_password
data: newpassword!
state: present
register: output
- name: Update secret
docker_secret:
name: db_password
data: newpassword!
state: present
register: output
- name: assert secret was updated
assert:
that:
- output.changed
- output.secret_id != secret_id
- name: assert secret was updated
assert:
that:
- output.changed
- output.secret_id != secret_id
- name: Remove secret
docker_secret:
name: db_password
state: absent
- name: Remove secret
docker_secret:
name: db_password
state: absent
- name: Check that secret is removed
command: "docker secret inspect {{ secret_id }}"
register: output
ignore_errors: true
- name: Check that secret is removed
command: "docker secret inspect {{ secret_id }}"
register: output
ignore_errors: true
- name: assert secret was removed
assert:
that:
- output.failed
- name: assert secret was removed
assert:
that:
- output.failed
# Rolling update
# Rolling update
- name: Create rolling secret
docker_secret:
name: rolling_password
data: opensesame!
rolling_versions: true
state: present
register: original_output
- name: Create rolling secret
docker_secret:
name: rolling_password
data: opensesame!
rolling_versions: true
state: present
register: original_output
- name: Create variable secret_id
set_fact:
secret_id: "{{ original_output.secret_id }}"
- name: Create variable secret_id
set_fact:
secret_id: "{{ original_output.secret_id }}"
- name: Inspect secret
command: "docker secret inspect {{ secret_id }}"
register: inspect
ignore_errors: true
- name: Inspect secret
command: "docker secret inspect {{ secret_id }}"
register: inspect
ignore_errors: true
- debug: var=inspect
- debug: var=inspect
- name: assert secret creation succeeded
assert:
that:
- "'rolling_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
- "'ansible_version' in inspect.stdout"
- original_output.secret_name == 'rolling_password_v1'
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: assert secret creation succeeded
assert:
that:
- "'rolling_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
- "'ansible_version' in inspect.stdout"
- original_output.secret_name == 'rolling_password_v1'
when: inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in inspect.stderr"
when: inspect is failed
- name: Create secret again
docker_secret:
name: rolling_password
data: newpassword!
rolling_versions: true
state: present
register: new_output
- name: Create secret again
docker_secret:
name: rolling_password
data: newpassword!
rolling_versions: true
state: present
register: new_output
- name: assert that new version is created
assert:
that:
- new_output.changed
- new_output.secret_id != original_output.secret_id
- new_output.secret_name != original_output.secret_name
- new_output.secret_name == 'rolling_password_v2'
- name: assert that new version is created
assert:
that:
- new_output.changed
- new_output.secret_id != original_output.secret_id
- new_output.secret_name != original_output.secret_name
- new_output.secret_name == 'rolling_password_v2'
- name: Remove rolling secrets
docker_secret:
name: rolling_password
rolling_versions: true
state: absent
- name: Remove rolling secrets
docker_secret:
name: rolling_password
rolling_versions: true
state: absent
- name: Check that secret is removed
command: "docker secret inspect {{ original_output.secret_id }}"
register: output
ignore_errors: true
- name: Check that secret is removed
command: "docker secret inspect {{ original_output.secret_id }}"
register: output
ignore_errors: true
- name: assert secret was removed
assert:
that:
- output.failed
- name: assert secret was removed
assert:
that:
- output.failed
- name: Check that secret is removed
command: "docker secret inspect {{ new_output.secret_id }}"
register: output
ignore_errors: true
- name: Check that secret is removed
command: "docker secret inspect {{ new_output.secret_id }}"
register: output
ignore_errors: true
- name: assert secret was removed
assert:
that:
- output.failed
- name: assert secret was removed
assert:
that:
- output.failed
always:
- name: Remove Swarm cluster
docker_swarm:
state: absent
force: true
- name: Remove Swarm cluster
docker_swarm:
state: absent
force: true
@@ -4,114 +4,114 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: install docker_stack python requirements
pip:
name: jsondiff,pyyaml
- name: install docker_stack python requirements
pip:
name: jsondiff,pyyaml
- name: Create a stack without name
register: output
docker_stack:
state: present
ignore_errors: true
- name: Create a stack without name
register: output
docker_stack:
state: present
ignore_errors: true
- name: assert failure when name not set
assert:
that:
- output is failed
- 'output.msg == "missing required arguments: name"'
- name: assert failure when name not set
assert:
that:
- output is failed
- 'output.msg == "missing required arguments: name"'
- name: Create a stack without compose
register: output
docker_stack:
name: test_stack
ignore_errors: true
- name: Create a stack without compose
register: output
docker_stack:
name: test_stack
ignore_errors: true
- name: assert failure when compose not set
assert:
that:
- output is failed
- 'output.msg == "compose parameter must be a list containing at least one element"'
- name: assert failure when compose not set
assert:
that:
- output is failed
- 'output.msg == "compose parameter must be a list containing at least one element"'
- name: Ensure stack is absent
register: output
docker_stack:
state: absent
name: test_stack
absent_retries: 30
- name: Ensure stack is absent
register: output
docker_stack:
state: absent
name: test_stack
absent_retries: 30
- name: Template compose files
template:
src: "{{item}}"
dest: "{{remote_tmp_dir}}/"
with_items:
- stack_compose_base.yml
- stack_compose_overrides.yml
- name: Template compose files
template:
src: "{{item}}"
dest: "{{remote_tmp_dir}}/"
with_items:
- stack_compose_base.yml
- stack_compose_overrides.yml
- name: Create stack with compose file
register: output
docker_stack:
state: present
name: test_stack
compose:
- "{{remote_tmp_dir}}/stack_compose_base.yml"
- name: Create stack with compose file
register: output
docker_stack:
state: present
name: test_stack
compose:
- "{{remote_tmp_dir}}/stack_compose_base.yml"
- name: assert test_stack changed on stack creation with compose file
assert:
that:
- output is changed
- name: assert test_stack changed on stack creation with compose file
assert:
that:
- output is changed
# FIXME: updating the stack prevents leaving the swarm on Shippable
#- name: Update stack with YAML
# register: output
# docker_stack:
# state: present
# name: test_stack
# compose:
# - "{{stack_compose_base}}"
# - "{{stack_compose_overrides}}"
#
#- name: assert test_stack correctly changed on update with yaml
# assert:
# that:
# - output is changed
# - output.stack_spec_diff == stack_update_expected_diff
# FIXME: updating the stack prevents leaving the swarm on Shippable
# - name: Update stack with YAML
# register: output
# docker_stack:
# state: present
# name: test_stack
# compose:
# - "{{stack_compose_base}}"
# - "{{stack_compose_overrides}}"
#
# - name: assert test_stack correctly changed on update with yaml
# assert:
# that:
# - output is changed
# - output.stack_spec_diff == stack_update_expected_diff
- name: Delete stack
register: output
docker_stack:
state: absent
name: test_stack
absent_retries: 30
- name: Delete stack
register: output
docker_stack:
state: absent
name: test_stack
absent_retries: 30
- name: assert delete of existing stack returns changed
assert:
that:
- output is changed
- name: assert delete of existing stack returns changed
assert:
that:
- output is changed
- name: Delete stack again
register: output
docker_stack:
state: absent
name: test_stack
absent_retries: 30
- name: Delete stack again
register: output
docker_stack:
state: absent
name: test_stack
absent_retries: 30
- name: assert state=absent idempotency
assert:
that:
- output is not changed
- name: assert state=absent idempotency
assert:
that:
- output is not changed
always:
- name: Remove a Swarm cluster
docker_swarm:
state: absent
force: true
- name: Remove a Swarm cluster
docker_swarm:
state: absent
force: true
@@ -5,6 +5,6 @@
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
@@ -5,6 +5,6 @@
version: '3'
services:
busybox:
environment:
envvar: value
busybox:
environment:
envvar: value
@@ -4,17 +4,17 @@
# SPDX-License-Identifier: GPL-3.0-or-later
stack_compose_base:
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
stack_compose_overrides:
version: '3'
services:
busybox:
environment:
envvar: value
version: '3'
services:
busybox:
environment:
envvar: value
stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}'
@@ -4,75 +4,75 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Get docker_stack_info when docker is not running in swarm mode
docker_stack_info:
ignore_errors: true
register: output
- name: Get docker_stack_info when docker is not running in swarm mode
docker_stack_info:
ignore_errors: true
register: output
- name: Assert failure when called when swarm is not running
assert:
that:
- 'output is failed'
- '"Error response from daemon: This node is not a swarm manager" in output.msg'
- name: Assert failure when called when swarm is not running
assert:
that:
- 'output is failed'
- '"Error response from daemon: This node is not a swarm manager" in output.msg'
- name: Create a swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Create a swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Get docker_stack_info when docker is running and not stack available
docker_stack_info:
register: output
- name: Get docker_stack_info when docker is running and not stack available
docker_stack_info:
register: output
- name: Assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results | length == 0'
- name: Assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results | length == 0'
- name: Template compose files
template:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/"
with_items:
- stack_compose_base.yml
- stack_compose_overrides.yml
- name: Template compose files
template:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/"
with_items:
- stack_compose_base.yml
- stack_compose_overrides.yml
- name: Install docker_stack python requirements
pip:
name: jsondiff,pyyaml
- name: Install docker_stack python requirements
pip:
name: jsondiff,pyyaml
- name: Create stack with compose file
register: output
docker_stack:
state: present
name: test_stack
compose:
- "{{ remote_tmp_dir }}/stack_compose_base.yml"
- name: Create stack with compose file
register: output
docker_stack:
state: present
name: test_stack
compose:
- "{{ remote_tmp_dir }}/stack_compose_base.yml"
- name: Assert test_stack changed on stack creation with compose file
assert:
that:
- output is changed
- name: Assert test_stack changed on stack creation with compose file
assert:
that:
- output is changed
- name: Get docker_stack_info when docker is running
docker_stack_info:
register: output
- name: Get docker_stack_info when docker is running
docker_stack_info:
register: output
- name: assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results[0].Name == "test_stack"'
- 'output.results[0].Services == "1"'
- name: assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results[0].Name == "test_stack"'
- 'output.results[0].Services == "1"'
always:
- name: Cleanup
docker_swarm:
state: absent
force: true
- name: Cleanup
docker_swarm:
state: absent
force: true
@@ -5,6 +5,6 @@
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
@@ -5,6 +5,6 @@
version: '3'
services:
busybox:
environment:
envvar: value
busybox:
environment:
envvar: value
@@ -4,17 +4,17 @@
# SPDX-License-Identifier: GPL-3.0-or-later
stack_compose_base:
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
stack_compose_overrides:
version: '3'
services:
busybox:
environment:
envvar: value
version: '3'
services:
busybox:
environment:
envvar: value
stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}'
@@ -4,82 +4,82 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Get docker_stack_info when docker is not running in swarm mode
docker_stack_info:
ignore_errors: true
register: output
- name: Get docker_stack_info when docker is not running in swarm mode
docker_stack_info:
ignore_errors: true
register: output
- name: Assert failure when called when swarm is not running
assert:
that:
- 'output is failed'
- '"Error response from daemon: This node is not a swarm manager" in output.msg'
- name: Assert failure when called when swarm is not running
assert:
that:
- 'output is failed'
- '"Error response from daemon: This node is not a swarm manager" in output.msg'
- name: Create a swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Create a swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Get docker_stack_info when docker is running and not stack available
docker_stack_info:
register: output
- name: Get docker_stack_info when docker is running and not stack available
docker_stack_info:
register: output
- name: Assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results | length == 0'
- name: Assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results | length == 0'
- name: Template compose files
template:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/"
with_items:
- stack_compose_base.yml
- stack_compose_overrides.yml
- name: Template compose files
template:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/"
with_items:
- stack_compose_base.yml
- stack_compose_overrides.yml
- name: Install docker_stack python requirements
pip:
name: jsondiff,pyyaml
- name: Install docker_stack python requirements
pip:
name: jsondiff,pyyaml
- name: Create stack with compose file
register: output
docker_stack:
state: present
name: test_stack
compose:
- "{{ remote_tmp_dir }}/stack_compose_base.yml"
- name: Create stack with compose file
register: output
docker_stack:
state: present
name: test_stack
compose:
- "{{ remote_tmp_dir }}/stack_compose_base.yml"
- name: Assert test_stack changed on stack creation with compose file
assert:
that:
- output is changed
- name: Assert test_stack changed on stack creation with compose file
assert:
that:
- output is changed
- name: Wait a bit to make sure stack is running
pause:
seconds: 5
- name: Wait a bit to make sure stack is running
pause:
seconds: 5
- name: Get docker_stack_info when docker is running
docker_stack_info:
register: output
- name: Get docker_stack_info when docker is running
docker_stack_info:
register: output
- name: Get docker_stack_task_info first element
docker_stack_task_info:
name: "{{ output.results[0].Name }}"
register: output
- name: Get docker_stack_task_info first element
docker_stack_task_info:
name: "{{ output.results[0].Name }}"
register: output
- name: assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results[0].DesiredState == "Running"'
- 'output.results[0].Image == docker_test_image_busybox'
- 'output.results[0].Name == "test_stack_busybox.1"'
- name: assert stack facts
assert:
that:
- 'output.results | type_debug == "list"'
- 'output.results[0].DesiredState == "Running"'
- 'output.results[0].Image == docker_test_image_busybox'
- 'output.results[0].Name == "test_stack_busybox.1"'
always:
- name: Cleanup
@@ -5,6 +5,6 @@
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
@@ -5,6 +5,6 @@
version: '3'
services:
busybox:
environment:
envvar: value
busybox:
environment:
envvar: value
@@ -4,17 +4,17 @@
# SPDX-License-Identifier: GPL-3.0-or-later
stack_compose_base:
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
version: '3'
services:
busybox:
image: "{{ docker_test_image_busybox }}"
command: sleep 3600
stack_compose_overrides:
version: '3'
services:
busybox:
environment:
envvar: value
version: '3'
services:
busybox:
environment:
envvar: value
stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}'
@@ -18,8 +18,8 @@
- name: assert failure when called with state=join and no remote_addrs,join_token
assert:
that:
- 'output.failed'
- 'output.msg == "state is join but all of the following are missing: remote_addrs, join_token"'
- 'output.failed'
- 'output.msg == "state is join but all of the following are missing: remote_addrs, join_token"'
- name: Test parameters with state=remove
docker_swarm:
@@ -30,8 +30,8 @@
- name: assert failure when called with state=remove and no node_id
assert:
that:
- 'output.failed'
- 'output.msg == "state is remove but all of the following are missing: node_id"'
- 'output.failed'
- 'output.msg == "state is remove but all of the following are missing: node_id"'
####################################################################
## Creation ########################################################
@@ -87,27 +87,27 @@
- name: assert changed when create a new swarm cluster
assert:
that:
- 'output_1 is changed'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- '(output_2.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- 'output_2.swarm_facts.JoinTokens.Manager is truthy'
- 'output_2.swarm_facts.JoinTokens.Worker is truthy'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- '(output_2.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- 'output_2.swarm_facts.JoinTokens.Manager is truthy'
- 'output_2.swarm_facts.JoinTokens.Worker is truthy'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## Removal #########################################################
@@ -146,18 +146,18 @@
- name: assert changed when remove a swarm cluster
assert:
that:
- 'output_1 is changed'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Node has left the swarm cluster"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_1 is changed'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Node has left the swarm cluster"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- include_tasks: cleanup.yml
@@ -8,126 +8,126 @@
- name: options-ca
when: cryptography_version.stdout is version('1.6', '>=')
block:
- name: Generate privatekey
loop:
- key1
- key2
loop_control:
loop_var: key
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key'
size: 2048
mode: '0666'
- name: Generate CSR
loop:
- key1
- key2
loop_control:
loop_var: key
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr'
privatekey_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key'
basic_constraints:
- CA:TRUE
key_usage:
- keyCertSign
- name: Generate self-signed certificate
loop:
- key1
- key2
loop_control:
loop_var: key
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/ansible_{{ key }}.pem'
privatekey_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key'
csr_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr'
provider: selfsigned
- name: Load certificates
slurp:
src: '{{ remote_tmp_dir }}/{{ item }}'
loop:
- ansible_key1.pem
- ansible_key2.pem
register: ansible_certificates
- name: Load certificate keys
slurp:
src: '{{ remote_tmp_dir }}/{{ item }}'
loop:
- ansible_key1.key
- ansible_key2.key
register: ansible_keys
- name: signing_ca_cert and signing_ca_key (check mode)
docker_swarm:
advertise_addr: '{{ansible_default_ipv4.address | default("127.0.0.1")}}'
state: present
signing_ca_cert: '{{ ansible_certificates.results[0].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}'
timeout: 120
check_mode: true
diff: true
register: output_1
ignore_errors: true
- name: signing_ca_cert and signing_ca_key
docker_swarm:
advertise_addr: '{{ansible_default_ipv4.address | default("127.0.0.1")}}'
state: present
signing_ca_cert: '{{ ansible_certificates.results[0].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}'
timeout: 120
diff: true
register: output_2
ignore_errors: true
- name: Private key
debug: msg="{{ ansible_keys.results[0].content | b64decode }}"
- name: Cert
debug: msg="{{ ansible_certificates.results[0].content | b64decode }}"
- docker_swarm_info: null
register: output
ignore_errors: true
- debug: var=output
- name: signing_ca_cert and signing_ca_key (change, check mode)
docker_swarm:
state: present
signing_ca_cert: '{{ ansible_certificates.results[1].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}'
timeout: 120
check_mode: true
diff: true
register: output_5
ignore_errors: true
- name: signing_ca_cert and signing_ca_key (change)
docker_swarm:
state: present
signing_ca_cert: '{{ ansible_certificates.results[1].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}'
timeout: 120
diff: true
register: output_6
ignore_errors: true
- name: assert signing_ca_cert and signing_ca_key
assert:
that:
- output_1 is changed
- '(output_1.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- output_1.diff.before is defined
- output_1.diff.after is defined
- output_2 is changed
- '(output_2.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- output_2.diff.before is defined
- output_2.diff.after is defined
- output_5 is changed
- output_5.actions[0] == "Swarm cluster updated"
- output_5.diff.before is defined
- output_5.diff.after is defined
- output_6 is changed
- output_6.actions[0] == "Swarm cluster updated"
- output_6.diff.before is defined
- output_6.diff.after is defined
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- output_1 is failed
- ('version is ' ~ docker_py_version ~ ' ') in output_1.msg
- '"Minimum version required is 2.6.0 " in output_1.msg'
when: docker_py_version is version('2.6.0', '<')
- include_tasks: cleanup.yml
- name: Generate privatekey
loop:
- key1
- key2
loop_control:
loop_var: key
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key'
size: 2048
mode: '0666'
- name: Generate CSR
loop:
- key1
- key2
loop_control:
loop_var: key
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr'
privatekey_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key'
basic_constraints:
- CA:TRUE
key_usage:
- keyCertSign
- name: Generate self-signed certificate
loop:
- key1
- key2
loop_control:
loop_var: key
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/ansible_{{ key }}.pem'
privatekey_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key'
csr_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr'
provider: selfsigned
- name: Load certificates
slurp:
src: '{{ remote_tmp_dir }}/{{ item }}'
loop:
- ansible_key1.pem
- ansible_key2.pem
register: ansible_certificates
- name: Load certificate keys
slurp:
src: '{{ remote_tmp_dir }}/{{ item }}'
loop:
- ansible_key1.key
- ansible_key2.key
register: ansible_keys
- name: signing_ca_cert and signing_ca_key (check mode)
docker_swarm:
advertise_addr: '{{ansible_default_ipv4.address | default("127.0.0.1")}}'
state: present
signing_ca_cert: '{{ ansible_certificates.results[0].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}'
timeout: 120
check_mode: true
diff: true
register: output_1
ignore_errors: true
- name: signing_ca_cert and signing_ca_key
docker_swarm:
advertise_addr: '{{ansible_default_ipv4.address | default("127.0.0.1")}}'
state: present
signing_ca_cert: '{{ ansible_certificates.results[0].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}'
timeout: 120
diff: true
register: output_2
ignore_errors: true
- name: Private key
debug: msg="{{ ansible_keys.results[0].content | b64decode }}"
- name: Cert
debug: msg="{{ ansible_certificates.results[0].content | b64decode }}"
- docker_swarm_info: null
register: output
ignore_errors: true
- debug: var=output
- name: signing_ca_cert and signing_ca_key (change, check mode)
docker_swarm:
state: present
signing_ca_cert: '{{ ansible_certificates.results[1].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}'
timeout: 120
check_mode: true
diff: true
register: output_5
ignore_errors: true
- name: signing_ca_cert and signing_ca_key (change)
docker_swarm:
state: present
signing_ca_cert: '{{ ansible_certificates.results[1].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}'
timeout: 120
diff: true
register: output_6
ignore_errors: true
- name: assert signing_ca_cert and signing_ca_key
assert:
that:
- output_1 is changed
- '(output_1.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- output_1.diff.before is defined
- output_1.diff.after is defined
- output_2 is changed
- '(output_2.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- output_2.diff.before is defined
- output_2.diff.after is defined
- output_5 is changed
- output_5.actions[0] == "Swarm cluster updated"
- output_5.diff.before is defined
- output_5.diff.after is defined
- output_6 is changed
- output_6.actions[0] == "Swarm cluster updated"
- output_6.diff.before is defined
- output_6.diff.after is defined
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- output_1 is failed
- ('version is ' ~ docker_py_version ~ ' ') in output_1.msg
- '"Minimum version required is 2.6.0 " in output_1.msg'
when: docker_py_version is version('2.6.0', '<')
- include_tasks: cleanup.yml
@@ -81,30 +81,30 @@
- name: assert autolock_managers changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
when: docker_py_version is version('2.6.0', '>=')
- name: assert UnlockKey in swarm_facts
@@ -118,9 +118,9 @@
- assert:
that:
- output_1 is failed
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
- "'Minimum version required is 2.6.0 ' in output_1.msg"
- output_1 is failed
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
- "'Minimum version required is 2.6.0 ' in output_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -181,36 +181,36 @@
- name: assert ca_force_rotate changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- output_1 is failed
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
- "'Minimum version required is 2.6.0 ' in output_1.msg"
- output_1 is failed
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
- "'Minimum version required is 2.6.0 ' in output_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -265,30 +265,30 @@
- name: assert dispatcher_heartbeat_period changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## election_tick ###################################################
@@ -342,30 +342,30 @@
- name: assert election_tick changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## heartbeat_tick ##################################################
@@ -419,30 +419,30 @@
- name: assert heartbeat_tick changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## keep_old_snapshots ##############################################
@@ -495,30 +495,30 @@
- name: assert keep_old_snapshots changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## labels ##########################################################
@@ -648,64 +648,64 @@
- name: assert labels changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_7 is not changed'
- 'output_7.actions[0] == "No modification"'
- 'output_7.diff.before is defined'
- 'output_7.diff.after is defined'
- 'output_8 is not changed'
- 'output_8.actions[0] == "No modification"'
- 'output_8.diff.before is defined'
- 'output_8.diff.after is defined'
- 'output_9 is not changed'
- 'output_9.actions[0] == "No modification"'
- 'output_9.diff.before is defined'
- 'output_9.diff.after is defined'
- 'output_10 is changed'
- 'output_10.actions[0] == "Swarm cluster updated"'
- 'output_10.diff.before is defined'
- 'output_10.diff.after is defined'
- 'output_11 is changed'
- 'output_11.actions[0] == "Swarm cluster updated"'
- 'output_11.diff.before is defined'
- 'output_11.diff.after is defined'
- 'output_12 is not changed'
- 'output_12.actions[0] == "No modification"'
- 'output_12.diff.before is defined'
- 'output_12.diff.after is defined'
- 'output_13 is not changed'
- 'output_13.actions[0] == "No modification"'
- 'output_13.diff.before is defined'
- 'output_13.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_7 is not changed'
- 'output_7.actions[0] == "No modification"'
- 'output_7.diff.before is defined'
- 'output_7.diff.after is defined'
- 'output_8 is not changed'
- 'output_8.actions[0] == "No modification"'
- 'output_8.diff.before is defined'
- 'output_8.diff.after is defined'
- 'output_9 is not changed'
- 'output_9.actions[0] == "No modification"'
- 'output_9.diff.before is defined'
- 'output_9.diff.after is defined'
- 'output_10 is changed'
- 'output_10.actions[0] == "Swarm cluster updated"'
- 'output_10.diff.before is defined'
- 'output_10.diff.after is defined'
- 'output_11 is changed'
- 'output_11.actions[0] == "Swarm cluster updated"'
- 'output_11.diff.before is defined'
- 'output_11.diff.after is defined'
- 'output_12 is not changed'
- 'output_12.actions[0] == "No modification"'
- 'output_12.diff.before is defined'
- 'output_12.diff.after is defined'
- 'output_13 is not changed'
- 'output_13.actions[0] == "No modification"'
- 'output_13.diff.before is defined'
- 'output_13.diff.after is defined'
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- output_1 is failed
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
- "'Minimum version required is 2.6.0 ' in output_1.msg"
- output_1 is failed
- "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
- "'Minimum version required is 2.6.0 ' in output_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -759,30 +759,30 @@
- name: assert log_entries_for_slow_followers changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## name ############################################################
@@ -816,15 +816,15 @@
- name: assert name changes
assert:
that:
- 'output_1 is not changed'
- 'output_1.actions[0] == "No modification"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is not changed'
- 'output_2.actions[0] == "No modification"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is failed or output_3 is changed'
- 'output_1 is not changed'
- 'output_1.actions[0] == "No modification"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is not changed'
- 'output_2.actions[0] == "No modification"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is failed or output_3 is changed'
####################################################################
## node_cert_expiry ################################################
@@ -877,30 +877,30 @@
- name: assert node_cert_expiry changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## rotate_manager_token ############################################
@@ -938,22 +938,22 @@
- name: assert rotate_manager_token changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
####################################################################
## rotate_worker_token #############################################
@@ -991,22 +991,22 @@
- name: assert rotate_worker_token changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
####################################################################
## snapshot_interval ###############################################
@@ -1059,30 +1059,30 @@
- name: assert snapshot_interval changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
####################################################################
## task_history_retention_limit ####################################
@@ -1135,29 +1135,29 @@
- name: assert task_history_retention_limit changes
assert:
that:
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- 'output_1 is changed'
- 'output_1.actions[0] == "Swarm cluster updated"'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2.actions[0] == "Swarm cluster updated"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3.actions[0] == "No modification"'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4.actions[0] == "No modification"'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- 'output_5 is changed'
- 'output_5.actions[0] == "Swarm cluster updated"'
- 'output_5.diff.before is defined'
- 'output_5.diff.after is defined'
- 'output_6 is changed'
- 'output_6.actions[0] == "Swarm cluster updated"'
- 'output_6.diff.before is defined'
- 'output_6.diff.after is defined'
- include_tasks: cleanup.yml
@@ -31,9 +31,9 @@
- name: assert default_addr_pool
assert:
that:
- 'output_1 is changed'
- 'output_2 is not changed'
- 'output_2.swarm_facts.DefaultAddrPool == ["2.0.0.0/16"]'
- 'output_1 is changed'
- 'output_2 is not changed'
- 'output_2.swarm_facts.DefaultAddrPool == ["2.0.0.0/16"]'
when:
- docker_api_version is version('1.39', '>=')
- docker_py_version is version('4.0.0', '>=')
@@ -41,8 +41,8 @@
- name: assert default_addr_pool failed when unsupported
assert:
that:
- 'output_1 is failed'
- "'Minimum version required' in output_1.msg"
- 'output_1 is failed'
- "'Minimum version required' in output_1.msg"
when: docker_api_version is version('1.39', '<') or
docker_py_version is version('4.0.0', '<')
@@ -77,9 +77,9 @@
- name: assert subnet_size
assert:
that:
- 'output_1 is changed'
- 'output_2 is not changed'
- 'output_2.swarm_facts.SubnetSize == 26'
- 'output_1 is changed'
- 'output_2 is not changed'
- 'output_2.swarm_facts.SubnetSize == 26'
when:
- docker_api_version is version('1.39', '>=')
- docker_py_version is version('4.0.0', '>=')
@@ -87,8 +87,8 @@
- name: assert subnet_size failed when unsupported
assert:
that:
- output_1 is failed
- "'Minimum version required' in output_1.msg"
- output_1 is failed
- "'Minimum version required' in output_1.msg"
when: docker_api_version is version('1.39', '<') or
docker_py_version is version('4.0.0', '<')
@@ -4,191 +4,191 @@
# SPDX-License-Identifier: GPL-3.0-or-later
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Try to get docker_swarm_info when docker is not running in swarm mode
docker_swarm_info:
ignore_errors: true
register: output
- name: Try to get docker_swarm_info when docker is not running in swarm mode
docker_swarm_info:
ignore_errors: true
register: output
- name: assert failure when called when swarm is not in use or not run on manager node
assert:
that:
- 'output is failed'
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == false'
- 'output.docker_swarm_manager == false'
- 'output.swarm_unlock_key is not defined'
- name: assert failure when called when swarm is not in use or not run on manager node
assert:
that:
- 'output is failed'
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == false'
- 'output.docker_swarm_manager == false'
- 'output.swarm_unlock_key is not defined'
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
register: output
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
register: output
- name: assert changed when create a new swarm cluster
assert:
that:
- 'output is changed'
- '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- name: assert changed when create a new swarm cluster
assert:
that:
- 'output is changed'
- '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- name: Try to get docker_swarm_info when docker is running in swarm mode and as manager
docker_swarm_info:
register: output
- name: Try to get docker_swarm_info when docker is running in swarm mode and as manager
docker_swarm_info:
register: output
- name: assert creding docker swarm facts
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: assert creding docker swarm facts
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: Try to get docker_swarm_info and list of nodes when docker is running in swarm mode and as manager
docker_swarm_info:
nodes: true
register: output
- name: Try to get docker_swarm_info and list of nodes when docker is running in swarm mode and as manager
docker_swarm_info:
nodes: true
register: output
- name: assert reading swarm facts with list of nodes option
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes[0].ID is string'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: assert reading swarm facts with list of nodes option
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes[0].ID is string'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: Get local docker node name
set_fact:
localnodename: "{{ output.nodes[0].Hostname }}"
- name: Get local docker node name
set_fact:
localnodename: "{{ output.nodes[0].Hostname }}"
- name: Try to get docker_swarm_info and verbose list of nodes when docker is running in swarm mode and as manager
docker_swarm_info:
nodes: true
verbose_output: true
register: output
- name: Try to get docker_swarm_info and verbose list of nodes when docker is running in swarm mode and as manager
docker_swarm_info:
nodes: true
verbose_output: true
register: output
- name: assert reading swarm facts with list of nodes and versbose output options
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes[0].ID is string'
- 'output.nodes[0].CreatedAt is truthy'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: assert reading swarm facts with list of nodes and versbose output options
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes[0].ID is string'
- 'output.nodes[0].CreatedAt is truthy'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: Try to get docker_swarm_info and list of nodes with filters providing existing node name
docker_swarm_info:
nodes: true
nodes_filters:
name: "{{ localnodename }}"
register: output
- name: Try to get docker_swarm_info and list of nodes with filters providing existing node name
docker_swarm_info:
nodes: true
nodes_filters:
name: "{{ localnodename }}"
register: output
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes | length == 1'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes | length == 1'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: Create random name
set_fact:
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
- name: Create random name
set_fact:
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
- name: Try to get docker_swarm_info and list of nodes with filters providing non-existing random node name
docker_swarm_info:
nodes: true
nodes_filters:
name: "{{ randomnodename }}"
register: output
- name: Try to get docker_swarm_info and list of nodes with filters providing non-existing random node name
docker_swarm_info:
nodes: true
nodes_filters:
name: "{{ randomnodename }}"
register: output
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes | length == 0'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: assert reading reading swarm facts and using node filter (random node name)
assert:
that:
- 'output.swarm_facts.JoinTokens.Manager is truthy'
- 'output.swarm_facts.JoinTokens.Worker is truthy'
- 'output.swarm_facts.ID is truthy'
- 'output.nodes | length == 0'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
- 'output.swarm_unlock_key is not defined'
- name: Try to get docker_swarm_info and swarm_unlock_key on non a unlocked swarm
docker_swarm_info:
unlock_key: true
register: output
ignore_errors: true
- name: Try to get docker_swarm_info and swarm_unlock_key on non a unlocked swarm
docker_swarm_info:
unlock_key: true
register: output
ignore_errors: true
- name: assert reading swarm facts and non existing swarm unlock key
assert:
that:
- 'output.swarm_unlock_key is none'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
when: docker_py_version is version('2.7.0', '>=')
- assert:
that:
- output is failed
- "('version is ' ~ docker_py_version ~ ' ') in output.msg"
- "'Minimum version required is 2.7.0 ' in output.msg"
when: docker_py_version is version('2.7.0', '<')
- name: assert reading swarm facts and non existing swarm unlock key
assert:
that:
- 'output.swarm_unlock_key is none'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
when: docker_py_version is version('2.7.0', '>=')
- assert:
that:
- output is failed
- "('version is ' ~ docker_py_version ~ ' ') in output.msg"
- "'Minimum version required is 2.7.0 ' in output.msg"
when: docker_py_version is version('2.7.0', '<')
- name: Update swarm cluster to be locked
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
autolock_managers: true
register: autolock_managers_update_output
ignore_errors: true
- name: Update swarm cluster to be locked
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
autolock_managers: true
register: autolock_managers_update_output
ignore_errors: true
- name: Try to get docker_swarm_info and swarm_unlock_key
docker_swarm_info:
unlock_key: true
register: output
ignore_errors: true
- name: Try to get docker_swarm_info and swarm_unlock_key
docker_swarm_info:
unlock_key: true
register: output
ignore_errors: true
- name: assert reading swarm facts and swarm unlock key
assert:
that:
- 'output.swarm_unlock_key is string'
- 'output.swarm_unlock_key == autolock_managers_update_output.swarm_facts.UnlockKey'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
when: docker_py_version is version('2.7.0', '>=')
- assert:
that:
- output is failed
- "('version is ' ~ docker_py_version ~ ' ') in output.msg"
- "'Minimum version required is 2.7.0 ' in output.msg"
when: docker_py_version is version('2.7.0', '<')
- name: assert reading swarm facts and swarm unlock key
assert:
that:
- 'output.swarm_unlock_key is string'
- 'output.swarm_unlock_key == autolock_managers_update_output.swarm_facts.UnlockKey'
- 'output.can_talk_to_docker == true'
- 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true'
when: docker_py_version is version('2.7.0', '>=')
- assert:
that:
- output is failed
- "('version is ' ~ docker_py_version ~ ' ') in output.msg"
- "'Minimum version required is 2.7.0 ' in output.msg"
when: docker_py_version is version('2.7.0', '<')
always:
- name: Cleanup
docker_swarm:
state: absent
force: true
- name: Cleanup
docker_swarm:
state: absent
force: true
@@ -185,23 +185,23 @@
- assert:
that:
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_4 is not changed
- configs_5 is not changed
- configs_6 is not changed
- configs_7 is changed
- configs_8 is not changed
- configs_9 is changed
- configs_10 is not failed
- configs_11 is changed
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_4 is not changed
- configs_5 is not changed
- configs_6 is not changed
- configs_7 is changed
- configs_8 is not changed
- configs_9 is changed
- configs_10 is not failed
- configs_11 is changed
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
####################################################################
@@ -217,10 +217,10 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
uid: 1000
uid: 1000
register: configs_1
ignore_errors: true
- name: configs (uid int idempotency)
docker_swarm_service:
name: "{{ service_name }}"
@@ -230,7 +230,7 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
uid: 1000
uid: 1000
register: configs_2
ignore_errors: true
@@ -243,10 +243,10 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
uid: 1002
uid: 1002
register: configs_3
ignore_errors: true
- name: configs (uid str)
docker_swarm_service:
name: "{{ service_name }}"
@@ -280,17 +280,17 @@
diff: false
- assert:
that:
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_4 is changed
- configs_5 is not changed
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_4 is changed
- configs_5 is not changed
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
@@ -307,10 +307,10 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
gid: 1000
gid: 1000
register: configs_1
ignore_errors: true
- name: configs (gid int idempotency)
docker_swarm_service:
name: "{{ service_name }}"
@@ -320,7 +320,7 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
gid: 1000
gid: 1000
register: configs_2
ignore_errors: true
@@ -333,10 +333,10 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
gid: 1002
gid: 1002
register: configs_3
ignore_errors: true
- name: configs (gid str)
docker_swarm_service:
name: "{{ service_name }}"
@@ -370,17 +370,17 @@
diff: false
- assert:
that:
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_4 is changed
- configs_5 is not changed
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_4 is changed
- configs_5 is not changed
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
####################################################################
@@ -396,7 +396,7 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
mode: 0600
mode: "0600"
register: configs_1
ignore_errors: true
@@ -409,7 +409,7 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
mode: 0600
mode: "0600"
register: configs_2
ignore_errors: true
@@ -422,7 +422,7 @@
configs:
- config_id: "{{ config_result_1.config_id|default('') }}"
config_name: "{{ config_name_1 }}"
mode: 0777
mode: "0777"
register: configs_3
ignore_errors: true
@@ -433,15 +433,15 @@
diff: false
- assert:
that:
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
- configs_1 is changed
- configs_2 is not changed
- configs_3 is changed
when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
- configs_1 is failed
- "'Minimum version required' in configs_1.msg"
when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
####################################################################
@@ -462,8 +462,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- mounts_tmpfs_size_1 is failed
- "'Minimum version required' in mounts_tmpfs_size_1.msg"
- mounts_tmpfs_size_1 is failed
- "'Minimum version required' in mounts_tmpfs_size_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -480,7 +480,7 @@
- source: "{{ volume_name_1 }}"
target: "/tmp/{{ volume_name_1 }}"
type: "tmpfs"
tmpfs_mode: 0444
tmpfs_mode: "0444"
register: mounts_tmpfs_mode_1
ignore_errors: true
@@ -494,7 +494,7 @@
- source: "{{ volume_name_1 }}"
target: "/tmp/{{ volume_name_1 }}"
type: "tmpfs"
tmpfs_mode: 0444
tmpfs_mode: "0444"
register: mounts_tmpfs_mode_2
ignore_errors: true
@@ -508,7 +508,7 @@
- source: "{{ volume_name_1 }}"
target: "/tmp/{{ volume_name_1 }}"
type: "tmpfs"
tmpfs_mode: 0777
tmpfs_mode: "0777"
register: mounts_tmpfs_mode_3
ignore_errors: true
@@ -526,8 +526,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- mounts_tmpfs_size_1 is failed
- "'Minimum version required' in mounts_tmpfs_size_1.msg"
- mounts_tmpfs_size_1 is failed
- "'Minimum version required' in mounts_tmpfs_size_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -586,8 +586,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- mounts_tmpfs_source_1 is failed
- "'Minimum version required' in mounts_tmpfs_source_1.msg"
- mounts_tmpfs_source_1 is failed
- "'Minimum version required' in mounts_tmpfs_source_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -213,14 +213,14 @@
- assert:
that:
- networks_4.rebuilt == false
- networks_7.rebuilt == false
- networks_4.rebuilt == false
- networks_7.rebuilt == false
when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.7.0', '>=')
- assert:
that:
- networks_4.rebuilt == true
- networks_7.rebuilt == true
- networks_4.rebuilt == true
- networks_7.rebuilt == true
when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.7.0', '<')
####################################################################
@@ -325,8 +325,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- dns_1 is failed
- "'Minimum version required' in dns_1.msg"
- dns_1 is failed
- "'Minimum version required' in dns_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -418,8 +418,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- dns_options_1 is failed
- "'Minimum version required' in dns_options_1.msg"
- dns_options_1 is failed
- "'Minimum version required' in dns_options_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -511,8 +511,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- dns_search_1 is failed
- "'Minimum version required' in dns_search_1.msg"
- dns_search_1 is failed
- "'Minimum version required' in dns_search_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -563,8 +563,8 @@
when: docker_py_version is version('3.0.0', '>=')
- assert:
that:
- endpoint_mode_1 is failed
- "'Minimum version required' in endpoint_mode_1.msg"
- endpoint_mode_1 is failed
- "'Minimum version required' in endpoint_mode_1.msg"
when: docker_py_version is version('3.0.0', '<')
####################################################################
@@ -755,13 +755,13 @@
- assert:
that:
- env_file_1 is changed
- env_file_2 is not changed
- env_file_3 is changed
- env_file_4 is changed
- env_file_5 is not changed
- env_file_6 is changed
- env_file_7 is not changed
- env_file_1 is changed
- env_file_2 is not changed
- env_file_3 is changed
- env_file_4 is changed
- env_file_5 is not changed
- env_file_6 is changed
- env_file_7 is not changed
###################################################################
## force_update ###################################################
@@ -806,8 +806,8 @@
when: docker_py_version is version('2.1.0', '>=')
- assert:
that:
- force_update_1 is failed
- "'Minimum version required' in force_update_1.msg"
- force_update_1 is failed
- "'Minimum version required' in force_update_1.msg"
when: docker_py_version is version('2.1.0', '<')
####################################################################
@@ -889,17 +889,17 @@
- assert:
that:
- groups_1 is changed
- groups_2 is not changed
- groups_3 is not changed
- groups_4 is changed
- groups_5 is changed
- groups_6 is not changed
- groups_1 is changed
- groups_2 is not changed
- groups_3 is not changed
- groups_4 is changed
- groups_5 is changed
- groups_6 is not changed
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- groups_1 is failed
- "'Minimum version required' in groups_1.msg"
- groups_1 is failed
- "'Minimum version required' in groups_1.msg"
when: docker_py_version is version('2.6.0', '<')
####################################################################
@@ -1033,20 +1033,20 @@
- assert:
that:
- healthcheck_1 is changed
- healthcheck_2 is not changed
- healthcheck_3 is changed
- healthcheck_4 is changed
- healthcheck_5 is not changed
- healthcheck_6 is changed
- healthcheck_7 is not changed
- healthcheck_8 is changed
- healthcheck_9 is not changed
- healthcheck_1 is changed
- healthcheck_2 is not changed
- healthcheck_3 is changed
- healthcheck_4 is changed
- healthcheck_5 is not changed
- healthcheck_6 is changed
- healthcheck_7 is not changed
- healthcheck_8 is changed
- healthcheck_9 is not changed
when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- healthcheck_1 is failed
- "'Minimum version required' in healthcheck_1.msg"
- healthcheck_1 is failed
- "'Minimum version required' in healthcheck_1.msg"
when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.6.0', '<')
###################################################################
@@ -1097,8 +1097,8 @@
when: docker_py_version is version('2.2.0', '>=')
- assert:
that:
- hostname_1 is failed
- "'Minimum version required' in hostname_1.msg"
- hostname_1 is failed
- "'Minimum version required' in hostname_1.msg"
when: docker_py_version is version('2.2.0', '<')
###################################################################
@@ -1154,8 +1154,8 @@
when: docker_py_version is version('2.6.0', '>=')
- assert:
that:
- hosts_1 is failed
- "'Minimum version required' in hosts_1.msg"
- hosts_1 is failed
- "'Minimum version required' in hosts_1.msg"
when: docker_py_version is version('2.6.0', '<')
@@ -1352,9 +1352,9 @@
- assert:
that:
- stop_grace_period_1 is changed
- stop_grace_period_2 is not changed
- stop_grace_period_3 is changed
- stop_grace_period_1 is changed
- stop_grace_period_2 is not changed
- stop_grace_period_3 is changed
####################################################################
## stop_signal #####################################################
@@ -1398,14 +1398,14 @@
- assert:
that:
- stop_signal_1 is changed
- stop_signal_2 is not changed
- stop_signal_3 is changed
- stop_signal_1 is changed
- stop_signal_2 is not changed
- stop_signal_3 is changed
when: docker_api_version is version('1.28', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- stop_signal_1 is failed
- "'Minimum version required' in stop_signal_1.msg"
- stop_signal_1 is failed
- "'Minimum version required' in stop_signal_1.msg"
when: docker_api_version is version('1.28', '<') or docker_py_version is version('2.6.0', '<')
####################################################################
@@ -1593,8 +1593,8 @@
when: docker_py_version is version('3.0.0', '>=')
- assert:
that:
- publish_1 is failed
- "'Minimum version required' in publish_1.msg"
- publish_1 is failed
- "'Minimum version required' in publish_1.msg"
when: docker_py_version is version('3.0.0', '<')
###################################################################
@@ -1645,8 +1645,8 @@
when: docker_api_version is version('1.28', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- read_only_1 is failed
- "'Minimum version required' in read_only_1.msg"
- read_only_1 is failed
- "'Minimum version required' in read_only_1.msg"
when: docker_api_version is version('1.28', '<') or docker_py_version is version('2.6.0', '<')
###################################################################
@@ -1790,8 +1790,8 @@
when: docker_py_version is version('2.4.0', '>=')
- assert:
that:
- tty_1 is failed
- "'Minimum version required' in tty_1.msg"
- tty_1 is failed
- "'Minimum version required' in tty_1.msg"
when: docker_py_version is version('2.4.0', '<')
###################################################################
@@ -1873,9 +1873,9 @@
- assert:
that:
- working_dir_1 is changed
- working_dir_2 is not changed
- working_dir_3 is changed
- working_dir_1 is changed
- working_dir_2 is not changed
- working_dir_3 is changed
####################################################################
## init ############################################################
@@ -1920,8 +1920,8 @@
- assert:
that:
- init_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.37') in hosts_1.msg"
- init_1 is failed
- "('version is ' ~ docker_api_version ~'. Minimum version required is 1.37') in hosts_1.msg"
when: docker_api_version is version('1.37', '<')
####################################################################
@@ -1935,9 +1935,9 @@
resolve_image: false
init: true
cap_add:
- sys_time
- sys_time
cap_drop:
- all
- all
register: capabilities_1
ignore_errors: true
@@ -1948,9 +1948,9 @@
resolve_image: false
init: true
cap_add:
- sys_time
- sys_time
cap_drop:
- all
- all
register: capabilities_2
ignore_errors: true
diff: true
@@ -1963,7 +1963,7 @@
init: true
cap_add: []
cap_drop:
- all
- all
register: capabilities_3
ignore_errors: true
diff: true
@@ -1975,9 +1975,9 @@
resolve_image: false
init: true
cap_add:
- setgid
- setgid
cap_drop:
- all
- all
register: capabilities_4
ignore_errors: true
diff: true
@@ -1990,16 +1990,16 @@
- assert:
that:
- capabilities_1 is changed
- capabilities_2 is not changed
- capabilities_3 is changed
- capabilities_4 is changed
- capabilities_1 is changed
- capabilities_2 is not changed
- capabilities_3 is changed
- capabilities_4 is changed
when: docker_api_version is version('1.41', '>=') and docker_py_version is version('5.0.3', '>=')
- assert:
that:
- capabilities_1 is failed
- >
(('version is ' ~ docker_py_version ~ ' ') in capabilities_1.msg and 'Minimum version required is 5.0.3 ' in capabilities_1.msg)
or (('Docker API version is ' ~ docker_api_version ~ '. ') in capabilities_1.msg and 'Minimum version required is 1.41 ' in capabilities_1.msg)
- capabilities_1 is failed
- >
(('version is ' ~ docker_py_version ~ ' ') in capabilities_1.msg and 'Minimum version required is 5.0.3 ' in capabilities_1.msg)
or (('Docker API version is ' ~ docker_api_version ~ '. ') in capabilities_1.msg and 'Minimum version required is 1.41 ' in capabilities_1.msg)
when: docker_api_version is version('1.41', '<') or docker_py_version is version('5.0.3', '<')
@@ -90,8 +90,8 @@
when: docker_api_version is version('1.27', '>=') and docker_py_version is version('2.4.0', '>=')
- assert:
that:
- placement_preferences_1 is failed
- "'Minimum version required' in placement_preferences_1.msg"
- placement_preferences_1 is failed
- "'Minimum version required' in placement_preferences_1.msg"
when: docker_api_version is version('1.27', '<') or docker_py_version is version('2.4.0', '<')
####################################################################
@@ -200,8 +200,8 @@
when: docker_api_version is version('1.27', '>=') and docker_py_version is version('2.4.0', '>=')
- assert:
that:
- constraints_1 is failed
- "'Minimum version required' in constraints_1.msg"
- constraints_1 is failed
- "'Minimum version required' in constraints_1.msg"
when: docker_api_version is version('1.27', '<') or docker_py_version is version('2.4.0', '<')
####################################################################
@@ -256,6 +256,6 @@
when: docker_api_version is version('1.40', '>=') and docker_py_version is version('4.4.3', '>=')
- assert:
that:
- replicas_max_per_node_1 is failed
- "'Minimum version required' in replicas_max_per_node_1.msg"
- replicas_max_per_node_1 is failed
- "'Minimum version required' in replicas_max_per_node_1.msg"
when: docker_api_version is version('1.40', '<') or docker_py_version is version('4.4.3', '<')
@@ -199,8 +199,8 @@
when: docker_py_version is version('2.4.0', '>=')
- assert:
that:
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
when: docker_py_version is version('2.4.0', '<')
####################################################################
@@ -288,8 +288,8 @@
when: docker_py_version is version('2.4.0', '>=')
- assert:
that:
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
when: docker_py_version is version('2.4.0', '<')
####################################################################
@@ -377,8 +377,8 @@
when: docker_py_version is version('2.4.0', '>=')
- assert:
that:
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
when: docker_py_version is version('2.4.0', '<')
####################################################################
@@ -394,7 +394,7 @@
secrets:
- secret_id: "{{ secret_result_1.secret_id|default('') }}"
secret_name: "{{ secret_name_1 }}"
mode: 0600
mode: "0600"
register: secrets_1
ignore_errors: true
@@ -407,7 +407,7 @@
secrets:
- secret_id: "{{ secret_result_1.secret_id|default('') }}"
secret_name: "{{ secret_name_1 }}"
mode: 0600
mode: "0600"
register: secrets_2
ignore_errors: true
@@ -420,7 +420,7 @@
secrets:
- secret_id: "{{ secret_result_1.secret_id|default('') }}"
secret_name: "{{ secret_name_1 }}"
mode: 0777
mode: "0777"
register: secrets_3
ignore_errors: true
@@ -438,8 +438,8 @@
when: docker_py_version is version('2.4.0', '>=')
- assert:
that:
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
- secrets_1 is failed
- "'Minimum version required' in secrets_1.msg"
when: docker_py_version is version('2.4.0', '<')
####################################################################
@@ -189,8 +189,8 @@
when: docker_py_version is version('2.1.0', '>=')
- assert:
that:
- update_max_failure_ratio_1 is failed
- "'Minimum version required' in update_max_failure_ratio_1.msg"
- update_max_failure_ratio_1 is failed
- "'Minimum version required' in update_max_failure_ratio_1.msg"
when: docker_py_version is version('2.1.0', '<')
###################################################################
@@ -244,8 +244,8 @@
when: docker_py_version is version('2.1.0', '>=')
- assert:
that:
- update_monitor_1 is failed
- "'Minimum version required' in update_monitor_1.msg"
- update_monitor_1 is failed
- "'Minimum version required' in update_monitor_1.msg"
when: docker_py_version is version('2.1.0', '<')
###################################################################
@@ -299,8 +299,8 @@
when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.7.0', '>=')
- assert:
that:
- update_order_1 is failed
- "'Minimum version required' in update_order_1.msg"
- update_order_1 is failed
- "'Minimum version required' in update_order_1.msg"
when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.7.0', '<')
###################################################################
@@ -12,60 +12,60 @@
service_name: "{{ service_base_name ~ '-1' }}"
- block:
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- name: Try to get docker_swarm_service_info when docker is not running in swarm mode
docker_swarm_service_info:
name: "{{ service_name }}"
ignore_errors: true
register: output
- name: Try to get docker_swarm_service_info when docker is not running in swarm mode
docker_swarm_service_info:
name: "{{ service_name }}"
ignore_errors: true
register: output
- name: assert failure when called when swarm is not in use or not run on manager node
assert:
that:
- 'output is failed'
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
- name: assert failure when called when swarm is not in use or not run on manager node
assert:
that:
- 'output is failed'
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
register: output
- name: Create a Swarm cluster
docker_swarm:
state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
register: output
- name: Create services
docker_swarm_service:
name: "{{ service_name }}"
image: "{{ docker_test_image_alpine }}"
- name: Create services
docker_swarm_service:
name: "{{ service_name }}"
image: "{{ docker_test_image_alpine }}"
- name: Try to get docker_swarm_service_info for a single service
docker_swarm_service_info:
name: "{{ service_name }}"
register: output
- name: Try to get docker_swarm_service_info for a single service
docker_swarm_service_info:
name: "{{ service_name }}"
register: output
- name: assert reading reading service info
assert:
that:
- 'output.exists == true'
- 'output.service.ID is string'
- 'output.service.Spec.Name == service_name'
- name: assert reading reading service info
assert:
that:
- 'output.exists == true'
- 'output.service.ID is string'
- 'output.service.Spec.Name == service_name'
- name: Create random name
set_fact:
random_service_name: "{{ 'random-service-%0x' % ((2**32) | random) }}"
- name: Create random name
set_fact:
random_service_name: "{{ 'random-service-%0x' % ((2**32) | random) }}"
- name: Try to get docker_swarm_service_info using random service name as parameter
docker_swarm_service_info:
name: "{{ random_service_name }}"
register: output
- name: Try to get docker_swarm_service_info using random service name as parameter
docker_swarm_service_info:
name: "{{ random_service_name }}"
register: output
- name: assert reading reading service info
assert:
that:
- 'output.service is none'
- 'output.exists == false'
- name: assert reading reading service info
assert:
that:
- 'output.service is none'
- 'output.exists == false'
always:
- name: Remove services
@@ -50,12 +50,12 @@
- assert:
that:
- create_1 is changed
- create_2 is not changed
- create_3 is not changed
- create_4 is changed
- absent_1 is changed
- absent_2 is not changed
- create_1 is changed
- create_2 is not changed
- create_3 is not changed
- create_4 is changed
- absent_1 is changed
- absent_2 is not changed
####################################################################
## driver_options ##################################################
@@ -109,10 +109,10 @@
- assert:
that:
- driver_options_1 is changed
- driver_options_2 is not changed
- driver_options_3 is not changed
- driver_options_4 is changed
- driver_options_1 is changed
- driver_options_2 is not changed
- driver_options_3 is not changed
- driver_options_4 is changed
####################################################################
## labels ##########################################################
@@ -181,11 +181,11 @@
- assert:
that:
- driver_labels_invalid is failed
- driver_labels_invalid.msg == "The value 1.0 for 'foo' of labels is not a string or something than can be safely converted to a string!"
- driver_labels_1 is changed
- driver_labels_2 is not changed
- driver_labels_3 is not changed
- driver_labels_4 is not changed
- driver_labels_5 is not changed
- driver_labels_6 is changed
- driver_labels_invalid is failed
- driver_labels_invalid.msg == "The value 1.0 for 'foo' of labels is not a string or something than can be safely converted to a string!"
- driver_labels_1 is changed
- driver_labels_2 is not changed
- driver_labels_3 is not changed
- driver_labels_4 is not changed
- driver_labels_5 is not changed
- driver_labels_6 is changed
@@ -9,67 +9,67 @@
####################################################################
- block:
- name: Create random volume name
set_fact:
cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Create random volume name
set_fact:
cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
- name: Make sure volume is not there
docker_volume:
name: "{{ cname }}"
state: absent
- name: Make sure volume is not there
docker_volume:
name: "{{ cname }}"
state: absent
- name: Inspect a non-present volume
docker_volume_info:
name: "{{ cname }}"
register: result
- name: Inspect a non-present volume
docker_volume_info:
name: "{{ cname }}"
register: result
- assert:
that:
- "not result.exists"
- "'volume' in result"
- "result.volume is none"
- assert:
that:
- "not result.exists"
- "'volume' in result"
- "result.volume is none"
- name: Make sure volume exists
docker_volume:
name: "{{ cname }}"
- name: Make sure volume exists
docker_volume:
name: "{{ cname }}"
- name: Inspect a present volume
docker_volume_info:
name: "{{ cname }}"
register: result
- name: Dump docker_volume_info result
debug: var=result
- name: Inspect a present volume
docker_volume_info:
name: "{{ cname }}"
register: result
- name: Dump docker_volume_info result
debug: var=result
- name: "Comparison: use 'docker volume inspect'"
command: docker volume inspect "{{ cname }}"
register: docker_volume_inspect
ignore_errors: true
- block:
- set_fact:
docker_volume_inspect_result: "{{ docker_volume_inspect.stdout | from_json }}"
- name: Dump docker volume inspect result
debug: var=docker_volume_inspect_result
when: docker_volume_inspect is not failed
- name: "Comparison: use 'docker volume inspect'"
command: docker volume inspect "{{ cname }}"
register: docker_volume_inspect
ignore_errors: true
- block:
- set_fact:
docker_volume_inspect_result: "{{ docker_volume_inspect.stdout | from_json }}"
- name: Dump docker volume inspect result
debug: var=docker_volume_inspect_result
when: docker_volume_inspect is not failed
- name: Cleanup
docker_volume:
name: "{{ cname }}"
state: absent
- name: Cleanup
docker_volume:
name: "{{ cname }}"
state: absent
- assert:
that:
- result.exists
- "'volume' in result"
- "result.volume is truthy"
- assert:
that:
- result.exists
- "'volume' in result"
- "result.volume is truthy"
- assert:
that:
- "result.volume == docker_volume_inspect_result[0]"
when: docker_volume_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_volume_inspect.stderr"
when: docker_volume_inspect is failed
- assert:
that:
- "result.volume == docker_volume_inspect_result[0]"
when: docker_volume_inspect is not failed
- assert:
that:
- "'is too new. Maximum supported API version is' in docker_volume_inspect.stderr"
when: docker_volume_inspect is failed
when: docker_api_version is version('1.25', '>=')
@@ -13,103 +13,36 @@
daemon_nginx_frontend: '{{ "ansible-docker-test-daemon-frontend-%0x" % ((2**32) | random) }}'
- block:
- name: Create volume for config files
docker_volume:
name: '{{ daemon_nginx_frontend }}'
state: present
- name: Create volume for config files
docker_volume:
name: '{{ daemon_nginx_frontend }}'
state: present
- name: Create container for nginx frontend for daemon
docker_container:
state: stopped
name: '{{ daemon_nginx_frontend }}'
image: "{{ docker_test_image_registry_nginx }}"
volumes:
- '{{ daemon_nginx_frontend }}:/etc/nginx/'
- '/var/run/docker.sock:/var/run/docker.sock'
network_mode: '{{ current_container_network_ip | default(omit, true) }}'
networks: >-
{{
[dict([['name', current_container_network_ip]])]
if current_container_network_ip not in ['', 'bridge'] else omit
}}
register: nginx_container
- name: Create container for nginx frontend for daemon
docker_container:
state: stopped
name: '{{ daemon_nginx_frontend }}'
image: "{{ docker_test_image_registry_nginx }}"
volumes:
- '{{ daemon_nginx_frontend }}:/etc/nginx/'
- '/var/run/docker.sock:/var/run/docker.sock'
network_mode: '{{ current_container_network_ip | default(omit, true) }}'
networks: >-
{{
[dict([['name', current_container_network_ip]])]
if current_container_network_ip not in ['', 'bridge'] else omit
}}
register: nginx_container
- name: Copy config files
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/{{ item }}"
mode: "0644"
loop:
- nginx.conf
- name: Copy static files into volume
docker_container_copy_into:
container: '{{ daemon_nginx_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
container_path: '/etc/nginx/{{ item }}'
owner_id: 0
group_id: 0
loop:
- nginx.conf
register: can_copy_files
ignore_errors: true
- when: can_copy_files is not failed
block:
- name: Create private keys
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/{{ item }}.key'
type: ECC
curve: secp256r1
force: true
- name: Copy config files
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/{{ item }}"
mode: "0644"
loop:
- cert
- ca
- nginx.conf
- name: Create CSR for CA certificate
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/ca.csr'
privatekey_path: '{{ remote_tmp_dir }}/ca.key'
subject:
commonName: Ansible test CA for Docker HTTPS connection tests
useCommonNameForSAN: false
basic_constraints:
- 'CA:TRUE'
basic_constraints_critical: true
key_usage:
- digitalSignature
- Certificate Sign
key_usage_critical: true
extended_key_usage:
- serverAuth # the same as "TLS Web Server Authentication"
extended_key_usage_critical: true
- name: Create CA certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/ca.pem'
csr_path: '{{ remote_tmp_dir }}/ca.csr'
privatekey_path: '{{ remote_tmp_dir }}/ca.key'
provider: selfsigned
- name: Create CSR for frontend certificate
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
subject_alt_name:
- DNS:daemon-tls.ansible.com
subject_alt_name_critical: true
- name: Create frontend certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/cert.pem'
csr_path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
ownca_path: '{{ remote_tmp_dir }}/ca.pem'
ownca_privatekey_path: '{{ remote_tmp_dir }}/ca.key'
provider: ownca
- name: Copy dynamic files into volume
- name: Copy static files into volume
docker_container_copy_into:
container: '{{ daemon_nginx_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
@@ -117,91 +50,158 @@
owner_id: 0
group_id: 0
loop:
- ca.pem
- cert.pem
- cert.key
- nginx.conf
register: can_copy_files
ignore_errors: true
- name: Start nginx frontend for daemon
docker_container:
name: '{{ daemon_nginx_frontend }}'
state: started
register: nginx_container
- when: can_copy_files is not failed
block:
- name: Output nginx container network settings
debug:
var: nginx_container.container.NetworkSettings
- name: Create private keys
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/{{ item }}.key'
type: ECC
curve: secp256r1
force: true
loop:
- cert
- ca
- name: Get proxied daemon URLs
set_fact:
docker_daemon_frontend_https: "https://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
docker_daemon_frontend_http: "http://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:6000"
- name: Create CSR for CA certificate
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/ca.csr'
privatekey_path: '{{ remote_tmp_dir }}/ca.key'
subject:
commonName: Ansible test CA for Docker HTTPS connection tests
useCommonNameForSAN: false
basic_constraints:
- 'CA:TRUE'
basic_constraints_critical: true
key_usage:
- digitalSignature
- Certificate Sign
key_usage_critical: true
extended_key_usage:
- serverAuth # the same as "TLS Web Server Authentication"
extended_key_usage_critical: true
- name: Wait for registry frontend
uri:
url: '{{ docker_daemon_frontend_http }}/version'
register: result
until: result is success
retries: 5
delay: 1
- name: Create CA certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/ca.pem'
csr_path: '{{ remote_tmp_dir }}/ca.csr'
privatekey_path: '{{ remote_tmp_dir }}/ca.key'
provider: selfsigned
- name: Get docker daemon information directly
docker_host_info:
register: output_direct
- name: Create CSR for frontend certificate
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
subject_alt_name:
- DNS:daemon-tls.ansible.com
subject_alt_name_critical: true
- name: Show direct host info
debug:
var: output_direct.host_info | sanitize_host_info
- name: Create frontend certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/cert.pem'
csr_path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
ownca_path: '{{ remote_tmp_dir }}/ca.pem'
ownca_privatekey_path: '{{ remote_tmp_dir }}/ca.key'
provider: ownca
- name: Get docker daemon information via HTTP
docker_host_info:
docker_host: '{{ docker_daemon_frontend_http }}'
register: output_http
- name: Copy dynamic files into volume
docker_container_copy_into:
container: '{{ daemon_nginx_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
container_path: '/etc/nginx/{{ item }}'
owner_id: 0
group_id: 0
loop:
- ca.pem
- cert.pem
- cert.key
- name: Show HTTP host info
debug:
var: output_http.host_info | sanitize_host_info
- name: Start nginx frontend for daemon
docker_container:
name: '{{ daemon_nginx_frontend }}'
state: started
register: nginx_container
- name: Check that information matches
assert:
that:
- (output_direct.host_info | sanitize_host_info) == (output_http.host_info | sanitize_host_info)
- name: Output nginx container network settings
debug:
var: nginx_container.container.NetworkSettings
- name: Get docker daemon information via HTTPS
docker_host_info:
docker_host: '{{ docker_daemon_frontend_https }}'
tls_hostname: daemon-tls.ansible.com
ca_cert: '{{ remote_tmp_dir }}/ca.pem'
tls: true
validate_certs: true
register: output_https
- name: Get proxied daemon URLs
set_fact:
docker_daemon_frontend_https: "https://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
docker_daemon_frontend_http: "http://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:6000"
- name: Show HTTPS host info
debug:
var: output_https.host_info | sanitize_host_info
- name: Wait for registry frontend
uri:
url: '{{ docker_daemon_frontend_http }}/version'
register: result
until: result is success
retries: 5
delay: 1
- name: Check that information matches
assert:
that:
- (output_direct.host_info | sanitize_host_info) == (output_https.host_info | sanitize_host_info)
- name: Get docker daemon information directly
docker_host_info:
register: output_direct
- name: Show direct host info
debug:
var: output_direct.host_info | sanitize_host_info
- name: Get docker daemon information via HTTP
docker_host_info:
docker_host: '{{ docker_daemon_frontend_http }}'
register: output_http
- name: Show HTTP host info
debug:
var: output_http.host_info | sanitize_host_info
- name: Check that information matches
assert:
that:
- (output_direct.host_info | sanitize_host_info) == (output_http.host_info | sanitize_host_info)
- name: Get docker daemon information via HTTPS
docker_host_info:
docker_host: '{{ docker_daemon_frontend_https }}'
tls_hostname: daemon-tls.ansible.com
ca_cert: '{{ remote_tmp_dir }}/ca.pem'
tls: true
validate_certs: true
register: output_https
- name: Show HTTPS host info
debug:
var: output_https.host_info | sanitize_host_info
- name: Check that information matches
assert:
that:
- (output_direct.host_info | sanitize_host_info) == (output_https.host_info | sanitize_host_info)
always:
- name: Obtain logs from the nginx frontend
command: docker logs {{ daemon_nginx_frontend }}
register: output
ignore_errors: true
- debug:
var: output.stdout_lines
ignore_errors: true
- name: Obtain logs from the nginx frontend
command: docker logs {{ daemon_nginx_frontend }}
register: output
ignore_errors: true
- debug:
var: output.stdout_lines
ignore_errors: true
- name: Remove container
docker_container:
state: absent
name: '{{ daemon_nginx_frontend }}'
force_kill: true
ignore_errors: true
- name: Remove container
docker_container:
state: absent
name: '{{ daemon_nginx_frontend }}'
force_kill: true
ignore_errors: true
- name: Remove volume
docker_volume:
name: '{{ daemon_nginx_frontend }}'
state: absent
ignore_errors: true
- name: Remove volume
docker_volume:
name: '{{ daemon_nginx_frontend }}'
state: absent
ignore_errors: true
@@ -25,15 +25,15 @@
# will be other containers.
- inventory_hostname.startswith('ansible-docker-test-docker-inventory-container-')
block:
- name: Run raw command
raw: ls /
register: output
- name: Run raw command
raw: ls /
register: output
- name: Check whether we have some directories we expect in the output
assert:
that:
- "'bin' in output.stdout_lines"
- "'dev' in output.stdout_lines"
- "'lib' in output.stdout_lines"
- "'proc' in output.stdout_lines"
- "'sys' in output.stdout_lines"
- name: Check whether we have some directories we expect in the output
assert:
that:
- "'bin' in output.stdout_lines"
- "'dev' in output.stdout_lines"
- "'lib' in output.stdout_lines"
- "'proc' in output.stdout_lines"
- "'sys' in output.stdout_lines"
@@ -6,40 +6,40 @@
- hosts: 127.0.0.1
gather_facts: false
tasks:
- name: sanity check Docker Machine output
vars:
dm_ls_format: !unsafe '{{.Name}} | {{.DriverName}} | {{.State}} | {{.URL}} | {{.Error}}'
success_regex: "^vm | [^|]+ | Running | tcp://.+ |$"
command: docker-machine ls --format '{{ dm_ls_format }}'
register: result
failed_when: result.rc != 0 or result.stdout is not match(success_regex)
- name: sanity check Docker Machine output
vars:
dm_ls_format: !unsafe '{{.Name}} | {{.DriverName}} | {{.State}} | {{.URL}} | {{.Error}}'
success_regex: "^vm | [^|]+ | Running | tcp://.+ |$"
command: docker-machine ls --format '{{ dm_ls_format }}'
register: result
failed_when: result.rc != 0 or result.stdout is not match(success_regex)
- name: verify Docker Machine ip
command: docker-machine ip vm
register: result
failed_when: result.rc != 0 or result.stdout != hostvars['vm'].ansible_host
- name: verify Docker Machine ip
command: docker-machine ip vm
register: result
failed_when: result.rc != 0 or result.stdout != hostvars['vm'].ansible_host
- name: verify Docker Machine env
command: docker-machine env --shell=sh vm
register: result
- name: verify Docker Machine env
command: docker-machine env --shell=sh vm
register: result
- debug: var=result.stdout
- debug: var=result.stdout
- assert:
that:
- "'DOCKER_TLS_VERIFY=\"{{ hostvars['vm'].dm_DOCKER_TLS_VERIFY }}\"' in result.stdout"
- "'DOCKER_HOST=\"{{ hostvars['vm'].dm_DOCKER_HOST }}\"' in result.stdout"
- "'DOCKER_CERT_PATH=\"{{ hostvars['vm'].dm_DOCKER_CERT_PATH }}\"' in result.stdout"
- "'DOCKER_MACHINE_NAME=\"{{ hostvars['vm'].dm_DOCKER_MACHINE_NAME }}\"' in result.stdout"
- assert:
that:
- "'DOCKER_TLS_VERIFY=\"{{ hostvars['vm'].dm_DOCKER_TLS_VERIFY }}\"' in result.stdout"
- "'DOCKER_HOST=\"{{ hostvars['vm'].dm_DOCKER_HOST }}\"' in result.stdout"
- "'DOCKER_CERT_PATH=\"{{ hostvars['vm'].dm_DOCKER_CERT_PATH }}\"' in result.stdout"
- "'DOCKER_MACHINE_NAME=\"{{ hostvars['vm'].dm_DOCKER_MACHINE_NAME }}\"' in result.stdout"
- hosts: vm
gather_facts: false
tasks:
- name: do something to verify that accept-new ssh setting was applied by the docker-machine inventory plugin
raw: uname -a
register: result
- name: do something to verify that accept-new ssh setting was applied by the docker-machine inventory plugin
raw: uname -a
register: result
- debug: var=result.stdout
- debug: var=result.stdout
- hosts: 127.0.0.1
gather_facts: false
@@ -49,7 +49,7 @@
DOCKER_MACHINE_NAME: "{{ hostvars['vm'].dm_DOCKER_MACHINE_NAME }}"
DOCKER_TLS_VERIFY: "{{ hostvars['vm'].dm_DOCKER_TLS_VERIFY }}"
tasks:
- name: run a Docker container on the target Docker Machine host to verify that Docker daemon connection settings from the docker-machine inventory plugin work as expected
docker_container:
name: test
image: "{{ docker_test_image_hello_world }}"
- name: run a Docker container on the target Docker Machine host to verify that Docker daemon connection settings from the docker-machine inventory plugin work as expected
docker_container:
name: test
image: "{{ docker_test_image_hello_world }}"
@@ -23,28 +23,28 @@
state: present
- block:
- name: Prevent service restart
copy:
content: exit 101
dest: /usr/sbin/policy-rc.d
backup: true
mode: '0755'
register: policy_rc_d
- name: Prevent service restart
copy:
content: exit 101
dest: /usr/sbin/policy-rc.d
backup: true
mode: '0755'
register: policy_rc_d
- name: Install Docker CE
apt:
name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}'
state: present
- name: Install Docker CE
apt:
name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}'
state: present
always:
- name: Restore /usr/sbin/policy-rc.d (if needed)
command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d
when:
- '"backup_file" in policy_rc_d'
- name: Restore /usr/sbin/policy-rc.d (if needed)
command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d
when:
- '"backup_file" in policy_rc_d'
- name: Remove /usr/sbin/policy-rc.d (if needed)
file:
path: /usr/sbin/policy-rc.d
state: absent
when:
- '"backup_file" not in policy_rc_d'
- name: Remove /usr/sbin/policy-rc.d (if needed)
file:
path: /usr/sbin/policy-rc.d
state: absent
when:
- '"backup_file" not in policy_rc_d'
@@ -90,66 +90,66 @@
msg: "Docker CLI version: {{ docker_cli_version }}; Docker API version: {{ docker_api_version }}"
- block:
# Cleanup docker daemon
- name: Show all containers
command: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %}'
# Cleanup docker daemon
- name: Show all containers
command: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %}'
- name: "Remove all ansible-docker-test-* docker containers"
shell: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker rm -f'
register: docker_containers
retries: 3
delay: 3
until: docker_containers is success
ignore_errors: true
- name: "Remove all ansible-docker-test-* docker containers"
shell: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker rm -f'
register: docker_containers
retries: 3
delay: 3
until: docker_containers is success
ignore_errors: true
- name: "Remove all ansible-docker-test-* docker volumes"
shell: 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker volume rm -f'
register: docker_volumes
ignore_errors: true
- name: "Remove all ansible-docker-test-* docker volumes"
shell: 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker volume rm -f'
register: docker_volumes
ignore_errors: true
- name: "Remove all ansible-docker-test-* docker networks"
shell: 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker network rm'
register: docker_networks
ignore_errors: true
- name: "Remove all ansible-docker-test-* docker networks"
shell: 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker network rm'
register: docker_networks
ignore_errors: true
- name: Cleaned docker resources
debug:
var: docker_resources
vars:
docker_resources:
containers: "{{ docker_containers.stdout_lines | default([]) }}"
volumes: "{{ docker_volumes.stdout_lines | default([]) }}"
networks: "{{ docker_networks.stdout_lines | default([]) }}"
- name: Cleaned docker resources
debug:
var: docker_resources
vars:
docker_resources:
containers: "{{ docker_containers.stdout_lines | default([]) }}"
volumes: "{{ docker_volumes.stdout_lines | default([]) }}"
networks: "{{ docker_networks.stdout_lines | default([]) }}"
# List all existing docker resources
- name: List all docker containers
command: docker ps --no-trunc -a
register: docker_containers
ignore_errors: true
# List all existing docker resources
- name: List all docker containers
command: docker ps --no-trunc -a
register: docker_containers
ignore_errors: true
- name: List all docker volumes
command: docker volume ls
register: docker_volumes
ignore_errors: true
- name: List all docker volumes
command: docker volume ls
register: docker_volumes
ignore_errors: true
- name: List all docker networks
command: docker network ls --no-trunc
register: docker_networks
ignore_errors: true
- name: List all docker networks
command: docker network ls --no-trunc
register: docker_networks
ignore_errors: true
- name: List all docker images
command: docker images --no-trunc -a
register: docker_images
ignore_errors: true
- name: List all docker images
command: docker images --no-trunc -a
register: docker_images
ignore_errors: true
- name: Still existing docker resources
debug:
var: docker_resources
vars:
docker_resources:
containers: "{{ docker_containers.stdout_lines | default([]) }}"
volumes: "{{ docker_volumes.stdout_lines | default([]) }}"
networks: "{{ docker_networks.stdout_lines | default([]) }}"
images: "{{ docker_images.stdout_lines | default([]) }}"
- name: Still existing docker resources
debug:
var: docker_resources
vars:
docker_resources:
containers: "{{ docker_containers.stdout_lines | default([]) }}"
volumes: "{{ docker_volumes.stdout_lines | default([]) }}"
networks: "{{ docker_networks.stdout_lines | default([]) }}"
images: "{{ docker_images.stdout_lines | default([]) }}"
when: docker_cli_version is version('0.0', '>')
@@ -17,34 +17,34 @@
- "{{ role_path }}/vars"
- block:
- name: Include distribution specific tasks
include_tasks: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
paths:
- "{{ role_path }}/tasks"
- name: Include distribution specific tasks
include_tasks: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
paths:
- "{{ role_path }}/tasks"
- name: Install Python on Whales
pip:
state: present
name: python-on-whales
extra_args: "-c {{ remote_constraints }}"
- name: Install Python on Whales
pip:
state: present
name: python-on-whales
extra_args: "-c {{ remote_constraints }}"
- name: Register docker-compose version
command: "docker compose version --short"
register: docker_compose_version
- name: Register docker-compose version
command: "docker compose version --short"
register: docker_compose_version
- name: Declare docker-compose version
set_fact:
docker_compose_version: "{{ docker_compose_version.stdout }}"
- name: Declare docker-compose version
set_fact:
docker_compose_version: "{{ docker_compose_version.stdout }}"
- name: Declare docker-compose as existing
set_fact:
has_docker_compose: '{{ docker_compose_version is version("2.0", ">=") }}'
- name: Declare docker-compose as existing
set_fact:
has_docker_compose: '{{ docker_compose_version is version("2.0", ">=") }}'
when: not skip_docker_compose
@@ -4,8 +4,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
dependencies:
#- setup_docker -- done in setup.yml, to work around cleanup problems!
#- setup_docker_current_container_network_ip
# - setup_docker -- done in setup.yml, to work around cleanup problems!
# - setup_docker_current_container_network_ip
- setup_docker_python_deps
- setup_openssl
- setup_remote_tmp_dir
@@ -18,9 +18,9 @@
# `links` does not work when using a network. That's why the docker_container task
# in setup.yml specifies `aliases` so we get the same effect.
links:
- '{{ docker_registry_container_name_registry }}:real-registry'
- '{{ docker_registry_container_name_registry }}:real-registry'
volumes:
- '{{ docker_registry_container_name_frontend }}:/etc/nginx/'
- '{{ docker_registry_container_name_frontend }}:/etc/nginx/'
network_mode: '{{ current_container_network_ip | default(omit, true) }}'
networks: >-
{{
@@ -35,8 +35,8 @@
dest: "{{ remote_tmp_dir }}/{{ item }}"
mode: "0644"
loop:
- nginx.conf
- nginx.htpasswd
- nginx.conf
- nginx.htpasswd
- name: Copy static files into volume
docker_container_copy_into:
@@ -46,74 +46,74 @@
owner_id: 0
group_id: 0
loop:
- nginx.conf
- nginx.htpasswd
- nginx.conf
- nginx.htpasswd
register: can_copy_files
ignore_errors: true
- when: can_copy_files is not failed
block:
- name: Create private key for frontend certificate
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/cert.key'
type: ECC
curve: secp256r1
force: true
- name: Create private key for frontend certificate
community.crypto.openssl_privatekey:
path: '{{ remote_tmp_dir }}/cert.key'
type: ECC
curve: secp256r1
force: true
- name: Create CSR for frontend certificate
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
subject_alt_name:
- DNS:test-registry.ansible.com
- name: Create CSR for frontend certificate
community.crypto.openssl_csr:
path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
subject_alt_name:
- DNS:test-registry.ansible.com
- name: Create frontend certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/cert.pem'
csr_path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
provider: selfsigned
- name: Create frontend certificate
community.crypto.x509_certificate:
path: '{{ remote_tmp_dir }}/cert.pem'
csr_path: '{{ remote_tmp_dir }}/cert.csr'
privatekey_path: '{{ remote_tmp_dir }}/cert.key'
provider: selfsigned
- name: Copy dynamic files into volume
docker_container_copy_into:
container: '{{ docker_registry_container_name_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
container_path: '/etc/nginx/{{ item }}'
owner_id: 0
group_id: 0
loop:
- cert.pem
- cert.key
- name: Copy dynamic files into volume
docker_container_copy_into:
container: '{{ docker_registry_container_name_frontend }}'
path: '{{ remote_tmp_dir }}/{{ item }}'
container_path: '/etc/nginx/{{ item }}'
owner_id: 0
group_id: 0
loop:
- cert.pem
- cert.key
- name: Start nginx frontend for registry
docker_container:
name: '{{ docker_registry_container_name_frontend }}'
state: started
register: nginx_container
- name: Start nginx frontend for registry
docker_container:
name: '{{ docker_registry_container_name_frontend }}'
state: started
register: nginx_container
- name: Output nginx container network settings
debug:
var: nginx_container.container.NetworkSettings
- name: Output nginx container network settings
debug:
var: nginx_container.container.NetworkSettings
- name: Get registry URL
set_fact:
# Note that this host/port combination is used by the Docker daemon, that's why `localhost` is appropriate!
# This host/port combination cannot be used if the tests are running inside a docker container.
docker_registry_frontend_address: localhost:{{ nginx_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
# The following host/port combination can be used from inside the docker container.
docker_registry_frontend_address_internal: "{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
- name: Get registry URL
set_fact:
# Note that this host/port combination is used by the Docker daemon, that's why `localhost` is appropriate!
# This host/port combination cannot be used if the tests are running inside a docker container.
docker_registry_frontend_address: localhost:{{ nginx_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
# The following host/port combination can be used from inside the docker container.
docker_registry_frontend_address_internal: "{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
- name: Wait for registry frontend
uri:
url: https://{{ docker_registry_frontend_address_internal }}/v2/
url_username: testuser
url_password: hunter2
validate_certs: false
register: result
until: result is success
retries: 5
delay: 1
- name: Wait for registry frontend
uri:
url: https://{{ docker_registry_frontend_address_internal }}/v2/
url_username: testuser
url_password: hunter2
validate_certs: false
register: result
until: result is success
retries: 5
delay: 1
- set_fact:
docker_registry_frontend_address: 'n/a'
@@ -30,12 +30,12 @@
set_fact:
docker_registry_setup_inames: []
docker_registry_setup_cnames:
- '{{ docker_registry_container_name_registry }}'
- '{{ docker_registry_container_name_nginx }}'
- '{{ docker_registry_container_name_nginx2 }}'
- '{{ docker_registry_container_name_registry }}'
- '{{ docker_registry_container_name_nginx }}'
- '{{ docker_registry_container_name_nginx2 }}'
docker_registry_setup_vnames:
- '{{ docker_registry_container_name_nginx }}'
- '{{ docker_registry_container_name_nginx2 }}'
- '{{ docker_registry_container_name_nginx }}'
- '{{ docker_registry_container_name_nginx2 }}'
- debug:
msg: Using test registry name {{ docker_registry_container_name_registry }} and nginx frontend names {{ docker_registry_container_name_nginx }} and {{ docker_registry_container_name_nginx2 }}
@@ -47,42 +47,42 @@
block:
# Set up registry container
- name: Start test registry
docker_container:
name: '{{ docker_registry_container_name_registry }}'
image: "{{ docker_test_image_registry }}"
ports: 5000
network_mode: '{{ current_container_network_ip | default(omit, true) }}'
# We need to define the alias `real-registry` here because the global `links`
# option for the NGINX containers (see setup-frontend.yml) does not work when
# using networks.
networks: >-
{{
[dict([['name', current_container_network_ip], ['aliases', ['real-registry']]])]
if current_container_network_ip not in ['', 'bridge'] else omit
}}
register: registry_container
- name: Start test registry
docker_container:
name: '{{ docker_registry_container_name_registry }}'
image: "{{ docker_test_image_registry }}"
ports: 5000
network_mode: '{{ current_container_network_ip | default(omit, true) }}'
# We need to define the alias `real-registry` here because the global `links`
# option for the NGINX containers (see setup-frontend.yml) does not work when
# using networks.
networks: >-
{{
[dict([['name', current_container_network_ip], ['aliases', ['real-registry']]])]
if current_container_network_ip not in ['', 'bridge'] else omit
}}
register: registry_container
- name: Get registry URL
set_fact:
registry_address: localhost:{{ registry_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
- name: Get registry URL
set_fact:
registry_address: localhost:{{ registry_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
# Set up first nginx frontend for registry
- include_tasks: setup-frontend.yml
vars:
docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx }}'
# Set up first nginx frontend for registry
- include_tasks: setup-frontend.yml
vars:
docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx }}'
- set_fact:
registry_frontend_address: '{{ docker_registry_frontend_address }}'
- set_fact:
registry_frontend_address: '{{ docker_registry_frontend_address }}'
# Set up second nginx frontend for registry
- include_tasks: setup-frontend.yml
vars:
docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx2 }}'
# Set up second nginx frontend for registry
- include_tasks: setup-frontend.yml
vars:
docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx2 }}'
- set_fact:
registry_frontend2_address: '{{ docker_registry_frontend_address }}'
- set_fact:
registry_frontend2_address: '{{ docker_registry_frontend_address }}'
# Print addresses for registry and frontends
- debug:
msg: "Registry available under {{ registry_address }}, NGINX frontends available under {{ registry_frontend_address }} and {{ registry_frontend2_address }}"
# Print addresses for registry and frontends
- debug:
msg: "Registry available under {{ registry_address }}, NGINX frontends available under {{ registry_frontend_address }} and {{ registry_frontend2_address }}"
+2 -2
View File
@@ -4,5 +4,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later
collections:
- community.internal_test_tools
- community.library_inventory_filtering_v1
- community.internal_test_tools
- community.library_inventory_filtering_v1