mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Use FQCNs. (#1180)
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
- include_tasks: test_swarm_info.yml
|
||||
- ansible.builtin.include_tasks: test_swarm_info.yml
|
||||
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')
|
||||
|
||||
- fail: msg="Too old docker / docker-py version to run docker_swarm_info tests!"
|
||||
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_swarm_info tests!"
|
||||
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
|
||||
- block:
|
||||
- name: Make sure we're not already using Docker swarm
|
||||
docker_swarm:
|
||||
community.docker.docker_swarm:
|
||||
state: absent
|
||||
force: true
|
||||
|
||||
- name: Try to get docker_swarm_info when docker is not running in swarm mode
|
||||
docker_swarm_info:
|
||||
community.docker.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:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output is failed'
|
||||
- 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
|
||||
@@ -25,13 +25,13 @@
|
||||
- 'output.swarm_unlock_key is not defined'
|
||||
|
||||
- name: Create a Swarm cluster
|
||||
docker_swarm:
|
||||
community.docker.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:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output is changed'
|
||||
- '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy'
|
||||
@@ -39,11 +39,11 @@
|
||||
- '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:
|
||||
community.docker.docker_swarm_info:
|
||||
register: output
|
||||
|
||||
- name: assert creding docker swarm facts
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output.swarm_facts.JoinTokens.Manager is truthy'
|
||||
- 'output.swarm_facts.JoinTokens.Worker is truthy'
|
||||
@@ -54,12 +54,12 @@
|
||||
- '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:
|
||||
community.docker.docker_swarm_info:
|
||||
nodes: true
|
||||
register: output
|
||||
|
||||
- name: assert reading swarm facts with list of nodes option
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output.swarm_facts.JoinTokens.Manager is truthy'
|
||||
- 'output.swarm_facts.JoinTokens.Worker is truthy'
|
||||
@@ -71,18 +71,18 @@
|
||||
- 'output.swarm_unlock_key is not defined'
|
||||
|
||||
- name: Get local docker node name
|
||||
set_fact:
|
||||
ansible.builtin.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:
|
||||
community.docker.docker_swarm_info:
|
||||
nodes: true
|
||||
verbose_output: true
|
||||
register: output
|
||||
|
||||
- name: assert reading swarm facts with list of nodes and versbose output options
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output.swarm_facts.JoinTokens.Manager is truthy'
|
||||
- 'output.swarm_facts.JoinTokens.Worker is truthy'
|
||||
@@ -95,14 +95,14 @@
|
||||
- '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:
|
||||
community.docker.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:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output.swarm_facts.JoinTokens.Manager is truthy'
|
||||
- 'output.swarm_facts.JoinTokens.Worker is truthy'
|
||||
@@ -114,18 +114,18 @@
|
||||
- 'output.swarm_unlock_key is not defined'
|
||||
|
||||
- name: Create random name
|
||||
set_fact:
|
||||
ansible.builtin.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:
|
||||
community.docker.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:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output.swarm_facts.JoinTokens.Manager is truthy'
|
||||
- 'output.swarm_facts.JoinTokens.Worker is truthy'
|
||||
@@ -137,20 +137,20 @@
|
||||
- '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:
|
||||
community.docker.docker_swarm_info:
|
||||
unlock_key: true
|
||||
register: output
|
||||
ignore_errors: true
|
||||
|
||||
- name: assert reading swarm facts and non existing swarm unlock key
|
||||
assert:
|
||||
ansible.builtin.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:
|
||||
- ansible.builtin.assert:
|
||||
that:
|
||||
- output is failed
|
||||
- "('version is ' ~ docker_py_version ~ ' ') in output.msg"
|
||||
@@ -158,7 +158,7 @@
|
||||
when: docker_py_version is version('2.7.0', '<')
|
||||
|
||||
- name: Update swarm cluster to be locked
|
||||
docker_swarm:
|
||||
community.docker.docker_swarm:
|
||||
state: present
|
||||
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
|
||||
autolock_managers: true
|
||||
@@ -166,13 +166,13 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Try to get docker_swarm_info and swarm_unlock_key
|
||||
docker_swarm_info:
|
||||
community.docker.docker_swarm_info:
|
||||
unlock_key: true
|
||||
register: output
|
||||
ignore_errors: true
|
||||
|
||||
- name: assert reading swarm facts and swarm unlock key
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'output.swarm_unlock_key is string'
|
||||
- 'output.swarm_unlock_key == autolock_managers_update_output.swarm_facts.UnlockKey'
|
||||
@@ -180,7 +180,7 @@
|
||||
- 'output.docker_swarm_active == true'
|
||||
- 'output.docker_swarm_manager == true'
|
||||
when: docker_py_version is version('2.7.0', '>=')
|
||||
- assert:
|
||||
- ansible.builtin.assert:
|
||||
that:
|
||||
- output is failed
|
||||
- "('version is ' ~ docker_py_version ~ ' ') in output.msg"
|
||||
@@ -189,6 +189,6 @@
|
||||
|
||||
always:
|
||||
- name: Cleanup
|
||||
docker_swarm:
|
||||
community.docker.docker_swarm:
|
||||
state: absent
|
||||
force: true
|
||||
|
||||
Reference in New Issue
Block a user