1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docker: rename docker_*_facts -> docker_*_info (#54124)

* Rename docker_*_facts -> docker_*_info.

* Add changelog.

* Update scenario guide.
This commit is contained in:
Felix Fontein 2019-03-21 09:37:18 +01:00 committed by John R Barker
parent 9c77509cbc
commit 8d62794f91
40 changed files with 114 additions and 106 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- The ``docker_image_facts`` module has been renamed to ``docker_image_info``.

View file

@ -14,8 +14,8 @@ Ansible offers the following modules for orchestrating Docker containers:
docker_image docker_image
Provides full control over images, including: build, pull, push, tag and remove. Provides full control over images, including: build, pull, push, tag and remove.
docker_image_facts docker_image_info
Inspects one or more images in the Docker host's image cache, providing the information as facts for making Inspects one or more images in the Docker host's image cache, providing the information for making
decision or assertions in a playbook. decision or assertions in a playbook.
docker_login docker_login

View file

@ -0,0 +1 @@
docker_image_info.py

View file

@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: docker_container_facts module: docker_container_info
short_description: Retrieves facts about docker container short_description: Retrieves facts about docker container
@ -46,7 +46,7 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get infos on container - name: Get infos on container
docker_container_facts: docker_container_info:
name: mydata name: mydata
register: result register: result

View file

@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: docker_host_facts module: docker_host_info
short_description: Retrieves facts about docker host and lists of objects of the services. short_description: Retrieves facts about docker host and lists of objects of the services.
@ -87,7 +87,7 @@ options:
- When set to C(yes) and I(networks), I(volumes), I(images), I(containers) or I(disk_usage) is set to C(yes) - When set to C(yes) and I(networks), I(volumes), I(images), I(containers) or I(disk_usage) is set to C(yes)
then output will contain verbose information about objects matching the full output of API method. then output will contain verbose information about objects matching the full output of API method.
For details see the documentation of your version of Docker API at L(https://docs.docker.com/engine/api/). For details see the documentation of your version of Docker API at L(https://docs.docker.com/engine/api/).
- The verbose output in this module contains only subset of information returned by I(_facts) module - The verbose output in this module contains only subset of information returned by I(_info) module
for each type of the objects. for each type of the objects.
type: bool type: bool
default: no default: no
@ -105,29 +105,29 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get info on docker host - name: Get info on docker host
docker_host_facts: docker_host_info:
register: result register: result
- name: Get info on docker host and list images - name: Get info on docker host and list images
docker_host_facts: docker_host_info:
images: yes images: yes
register: result register: result
- name: Get info on docker host and list images matching the filter - name: Get info on docker host and list images matching the filter
docker_host_facts: docker_host_info:
images: yes images: yes
images_filters: images_filters:
label: "mylabel" label: "mylabel"
register: result register: result
- name: Get info on docker host and verbose list images - name: Get info on docker host and verbose list images
docker_host_facts: docker_host_info:
images: yes images: yes
verbose_output: yes verbose_output: yes
register: result register: result
- name: Get info on docker host and used disk space - name: Get info on docker host and used disk space
docker_host_facts: docker_host_info:
disk_usage: yes disk_usage: yes
register: result register: result

View file

@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: docker_image_facts module: docker_image_info
short_description: Inspect docker images short_description: Inspect docker images
@ -23,6 +23,9 @@ version_added: "2.1.0"
description: description:
- Provide one or more image names, and the module will inspect each, returning an array of inspection results. - Provide one or more image names, and the module will inspect each, returning an array of inspection results.
notes:
- This module was called C(docker_image_facts) before Ansible 2.8. The usage did not change.
options: options:
name: name:
description: description:
@ -48,11 +51,11 @@ author:
EXAMPLES = ''' EXAMPLES = '''
- name: Inspect a single image - name: Inspect a single image
docker_image_facts: docker_image_info:
name: pacur/centos-7 name: pacur/centos-7
- name: Inspect multiple images - name: Inspect multiple images
docker_image_facts: docker_image_info:
name: name:
- pacur/centos-7 - pacur/centos-7
- sinatra - sinatra
@ -228,6 +231,8 @@ def main():
supports_check_mode=True, supports_check_mode=True,
min_docker_api_version='1.20', min_docker_api_version='1.20',
) )
if client.module._name == 'docker_image_facts':
client.module.deprecate("The 'docker_image_facts' module has been renamed to 'docker_image_info'", version='2.12')
results = dict( results = dict(
changed=False, changed=False,

View file

@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: docker_network_facts module: docker_network_info
short_description: Retrieves facts about docker network short_description: Retrieves facts about docker network
@ -46,7 +46,7 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get infos on network - name: Get infos on network
docker_network_facts: docker_network_info:
name: mydata name: mydata
register: result register: result

View file

@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: docker_node_facts module: docker_node_info
short_description: Retrieves facts about docker swarm node from Swarm Manager short_description: Retrieves facts about docker swarm node from Swarm Manager
@ -54,23 +54,23 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get info on all nodes - name: Get info on all nodes
docker_node_facts: docker_node_info:
register: result register: result
- name: Get info on node - name: Get info on node
docker_node_facts: docker_node_info:
name: mynode name: mynode
register: result register: result
- name: Get info on list of nodes - name: Get info on list of nodes
docker_node_facts: docker_node_info:
name: name:
- mynode1 - mynode1
- mynode2 - mynode2
register: result register: result
- name: Get info on host if it is Swarm Manager - name: Get info on host if it is Swarm Manager
docker_node_facts: docker_node_info:
self: true self: true
register: result register: result
''' '''

View file

@ -412,7 +412,7 @@ class SwarmManager(DockerBaseClass):
if self.state == 'inspect': if self.state == 'inspect':
self.client.module.deprecate( self.client.module.deprecate(
"The 'inspect' state is deprecated, please use 'docker_swarm_facts' to inspect swarm cluster", "The 'inspect' state is deprecated, please use 'docker_swarm_info' to inspect swarm cluster",
version='2.12') version='2.12')
choice_map.get(self.state)() choice_map.get(self.state)()

View file

@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: docker_swarm_facts module: docker_swarm_info
short_description: Retrieves facts about Docker Swarm cluster. short_description: Retrieves facts about Docker Swarm cluster.
@ -73,7 +73,7 @@ options:
- When set to C(yes) and I(nodes), I(services) or I(tasks) is set to C(yes) - When set to C(yes) and I(nodes), I(services) or I(tasks) is set to C(yes)
then output will contain verbose information about objects matching the full output of API method. then output will contain verbose information about objects matching the full output of API method.
For details see the documentation of your version of Docker API at U(https://docs.docker.com/engine/api/). For details see the documentation of your version of Docker API at U(https://docs.docker.com/engine/api/).
- The verbose output in this module contains only subset of information returned by I(_facts) module - The verbose output in this module contains only subset of information returned by I(_info) module
for each type of the objects. for each type of the objects.
type: bool type: bool
default: no default: no
@ -88,7 +88,7 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get info on Docker Swarm - name: Get info on Docker Swarm
docker_swarm_facts: docker_swarm_info:
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -102,18 +102,18 @@ EXAMPLES = '''
- block: - block:
- name: Get info on Docker Swarm and list of registered nodes - name: Get info on Docker Swarm and list of registered nodes
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
register: result register: result
- name: Get info on Docker Swarm and extended list of registered nodes - name: Get info on Docker Swarm and extended list of registered nodes
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
verbose_output: yes verbose_output: yes
register: result register: result
- name: Get info on Docker Swarm and filtered list of registered nodes - name: Get info on Docker Swarm and filtered list of registered nodes
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
nodes_filter: nodes_filter:
name: mynode name: mynode

View file

@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = u''' DOCUMENTATION = u'''
module: docker_volume_facts module: docker_volume_info
version_added: "2.8" version_added: "2.8"
short_description: Retrieve facts about Docker volumes short_description: Retrieve facts about Docker volumes
description: description:
@ -42,7 +42,7 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get infos on volume - name: Get infos on volume
docker_volume_facts: docker_volume_info:
name: mydata name: mydata
register: result register: result

View file

@ -17,23 +17,23 @@
loop_var: image loop_var: image
- name: Get image ID of hello-world and alpine images - name: Get image ID of hello-world and alpine images
docker_image_facts: docker_image_info:
name: name:
- "hello-world:latest" - "hello-world:latest"
- "alpine:3.8" - "alpine:3.8"
register: image_facts register: image_info
- assert: - assert:
that: that:
- image_facts.images | length == 2 - image_info.images | length == 2
- name: Print image IDs - name: Print image IDs
debug: debug:
msg: "hello-world: {{ image_facts.images[0].Id }}; alpine: {{ image_facts.images[1].Id }}" msg: "hello-world: {{ image_info.images[0].Id }}; alpine: {{ image_info.images[1].Id }}"
- name: Create container with hello-world image via ID - name: Create container with hello-world image via ID
docker_container: docker_container:
image: "{{ image_facts.images[0].Id }}" image: "{{ image_info.images[0].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes
@ -41,7 +41,7 @@
- name: Create container with hello-world image via ID (idempotent) - name: Create container with hello-world image via ID (idempotent)
docker_container: docker_container:
image: "{{ image_facts.images[0].Id }}" image: "{{ image_info.images[0].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes
@ -49,7 +49,7 @@
- name: Create container with alpine image via ID - name: Create container with alpine image via ID
docker_container: docker_container:
image: "{{ image_facts.images[1].Id }}" image: "{{ image_info.images[1].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes
@ -57,7 +57,7 @@
- name: Create container with alpine image via ID (idempotent) - name: Create container with alpine image via ID (idempotent)
docker_container: docker_container:
image: "{{ image_facts.images[1].Id }}" image: "{{ image_info.images[1].Id }}"
name: "{{ cname }}" name: "{{ cname }}"
state: present state: present
force_kill: yes force_kill: yes

View file

@ -11,7 +11,7 @@
force_kill: yes force_kill: yes
- name: Inspect a non-present container - name: Inspect a non-present container
docker_container_facts: docker_container_info:
name: "{{ cname }}" name: "{{ cname }}"
register: result register: result
@ -31,10 +31,10 @@
force_kill: yes force_kill: yes
- name: Inspect a present container - name: Inspect a present container
docker_container_facts: docker_container_info:
name: "{{ cname }}" name: "{{ cname }}"
register: result register: result
- name: Dump docker_container_facts result - name: Dump docker_container_info result
debug: var=result debug: var=result
- name: "Comparison: use 'docker inspect'" - name: "Comparison: use 'docker inspect'"
@ -60,5 +60,5 @@
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=') when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
- fail: msg="Too old docker / docker-py version to run docker_container_facts tests!" - fail: msg="Too old docker / docker-py version to run docker_container_info tests!"
when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

View file

@ -1,5 +1,5 @@
- include_tasks: test_host_facts.yml - include_tasks: test_host_info.yml
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.21', '>=') when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.21', '>=')
- fail: msg="Too old docker / docker-py version to run docker_host_facts tests!" - fail: msg="Too old docker / docker-py version to run docker_host_info tests!"
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

View file

@ -9,7 +9,7 @@
- block: - block:
- name: Get info on Docker host - name: Get info on Docker host
docker_host_facts: docker_host_info:
register: output register: output
- name: assert reading docker host facts when docker is running - name: assert reading docker host facts when docker is running
@ -48,7 +48,7 @@
- volume_output is changed - volume_output is changed
- name: Get info on Docker host and list containers - name: Get info on Docker host and list containers
docker_host_facts: docker_host_info:
containers: yes containers: yes
register: output register: output
@ -64,7 +64,7 @@
- 'output.containers[0].ImageID is not defined' - 'output.containers[0].ImageID is not defined'
- name: Get info on Docker host and list containers with verbose output - name: Get info on Docker host and list containers with verbose output
docker_host_facts: docker_host_info:
containers: yes containers: yes
verbose_output: yes verbose_output: yes
register: output register: output
@ -81,7 +81,7 @@
- 'output.containers[0].ImageID is string' - 'output.containers[0].ImageID is string'
- name: Get info on Docker host and list images - name: Get info on Docker host and list images
docker_host_facts: docker_host_info:
images: yes images: yes
register: output register: output
@ -97,7 +97,7 @@
- 'output.disk_usage is not defined' - 'output.disk_usage is not defined'
- name: Get info on Docker host and list images with verbose output - name: Get info on Docker host and list images with verbose output
docker_host_facts: docker_host_info:
images: yes images: yes
verbose_output: yes verbose_output: yes
register: output register: output
@ -114,7 +114,7 @@
- 'output.disk_usage is not defined' - 'output.disk_usage is not defined'
- name: Get info on Docker host and list networks - name: Get info on Docker host and list networks
docker_host_facts: docker_host_info:
networks: yes networks: yes
register: output register: output
@ -130,7 +130,7 @@
- 'output.disk_usage is not defined' - 'output.disk_usage is not defined'
- name: Get info on Docker host and list networks with verbose output - name: Get info on Docker host and list networks with verbose output
docker_host_facts: docker_host_info:
networks: yes networks: yes
verbose_output: yes verbose_output: yes
register: output register: output
@ -147,7 +147,7 @@
- 'output.disk_usage is not defined' - 'output.disk_usage is not defined'
- name: Get info on Docker host and list volumes - name: Get info on Docker host and list volumes
docker_host_facts: docker_host_info:
volumes: yes volumes: yes
register: output register: output
@ -163,7 +163,7 @@
- 'output.disk_usage is not defined' - 'output.disk_usage is not defined'
- name: Get info on Docker host and list volumes with verbose output - name: Get info on Docker host and list volumes with verbose output
docker_host_facts: docker_host_info:
volumes: yes volumes: yes
verbose_output: yes verbose_output: yes
register: output register: output
@ -180,7 +180,7 @@
- 'output.disk_usage is not defined' - 'output.disk_usage is not defined'
- name: Get info on Docker host and get disk usage - name: Get info on Docker host and get disk usage
docker_host_facts: docker_host_info:
disk_usage: yes disk_usage: yes
register: output register: output
@ -196,7 +196,7 @@
- 'output.disk_usage.BuilderSize is not defined' - 'output.disk_usage.BuilderSize is not defined'
- name: Get info on Docker host and get disk usage with verbose output - name: Get info on Docker host and get disk usage with verbose output
docker_host_facts: docker_host_info:
disk_usage: yes disk_usage: yes
verbose_output: yes verbose_output: yes
register: output register: output
@ -213,7 +213,7 @@
- 'output.disk_usage.BuilderSize is number' - 'output.disk_usage.BuilderSize is number'
- name: Get info on Docker host, disk usage and get all lists together - name: Get info on Docker host, disk usage and get all lists together
docker_host_facts: docker_host_info:
volumes: yes volumes: yes
containers: yes containers: yes
networks: yes networks: yes
@ -237,7 +237,7 @@
- 'output.disk_usage.BuilderSize is not defined' - 'output.disk_usage.BuilderSize is not defined'
- name: Get info on Docker host, disk usage and get all lists together with verbose output - name: Get info on Docker host, disk usage and get all lists together with verbose output
docker_host_facts: docker_host_info:
volumes: yes volumes: yes
containers: yes containers: yes
networks: yes networks: yes

View file

@ -115,7 +115,7 @@
- push_3 is not changed - push_3 is not changed
- name: Get facts of local image - name: Get facts of local image
docker_image_facts: docker_image_info:
name: "{{ registry_address }}/test/hello-world:latest" name: "{{ registry_address }}/test/hello-world:latest"
register: facts_1 register: facts_1
@ -126,7 +126,7 @@
force_absent: yes force_absent: yes
- name: Get facts of local image (absent) - name: Get facts of local image (absent)
docker_image_facts: docker_image_info:
name: "{{ registry_address }}/test/hello-world:latest" name: "{{ registry_address }}/test/hello-world:latest"
register: facts_2 register: facts_2
@ -145,7 +145,7 @@
register: pull_2 register: pull_2
- name: Get facts of local image (present) - name: Get facts of local image (present)
docker_image_facts: docker_image_info:
name: "{{ registry_address }}/test/hello-world:latest" name: "{{ registry_address }}/test/hello-world:latest"
register: facts_3 register: facts_3

View file

@ -162,7 +162,7 @@
- repository_2 is not changed - repository_2 is not changed
- name: Get facts of image - name: Get facts of image
docker_image_facts: docker_image_info:
name: "{{ registry_address }}/test/{{ iname }}:latest" name: "{{ registry_address }}/test/{{ iname }}:latest"
register: facts_1 register: facts_1

View file

@ -6,7 +6,7 @@
state: absent state: absent
- name: Inspect a non-available image - name: Inspect a non-available image
docker_image_facts: docker_image_info:
name: alpine:3.7 name: alpine:3.7
register: result register: result
@ -24,7 +24,7 @@
- "alpine:3.8" - "alpine:3.8"
- name: Inspect an available image - name: Inspect an available image
docker_image_facts: docker_image_info:
name: hello-world:latest name: hello-world:latest
register: result register: result
@ -34,7 +34,7 @@
- "'hello-world:latest' in result.images[0].RepoTags" - "'hello-world:latest' in result.images[0].RepoTags"
- name: Inspect multiple images - name: Inspect multiple images
docker_image_facts: docker_image_info:
name: name:
- "hello-world:latest" - "hello-world:latest"
- "alpine:3.8" - "alpine:3.8"
@ -50,5 +50,5 @@
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=') when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
- fail: msg="Too old docker / docker-py version to run docker_image_facts tests!" - fail: msg="Too old docker / docker-py version to run docker_image_info tests!"
when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

View file

@ -11,7 +11,7 @@
force: yes force: yes
- name: Inspect a non-present network - name: Inspect a non-present network
docker_network_facts: docker_network_info:
name: "{{ nname }}" name: "{{ nname }}"
register: result register: result
@ -27,10 +27,10 @@
state: present state: present
- name: Inspect a present network - name: Inspect a present network
docker_network_facts: docker_network_info:
name: "{{ nname }}" name: "{{ nname }}"
register: result register: result
- name: Dump docker_network_facts result - name: Dump docker_network_info result
debug: var=result debug: var=result
- name: "Comparison: use 'docker network inspect'" - name: "Comparison: use 'docker network inspect'"
@ -56,5 +56,5 @@
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=') when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')
- fail: msg="Too old docker / docker-py version to run docker_network_facts tests!" - fail: msg="Too old docker / docker-py version to run docker_network_info tests!"
when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

View file

@ -5,8 +5,8 @@
state: absent state: absent
force: true force: true
- name: Try to get docker_node_facts when docker is not running in swarm mode - name: Try to get docker_node_info when docker is not running in swarm mode
docker_node_facts: docker_node_info:
ignore_errors: yes ignore_errors: yes
register: output register: output
@ -29,8 +29,8 @@
- 'output.swarm_facts.JoinTokens.Manager' - 'output.swarm_facts.JoinTokens.Manager'
- 'output.swarm_facts.JoinTokens.Worker' - 'output.swarm_facts.JoinTokens.Worker'
- name: Try to get docker_node_facts when docker is running in swarm mode and as manager - name: Try to get docker_node_info when docker is running in swarm mode and as manager
docker_node_facts: docker_node_info:
register: output register: output
- name: assert reading docker swarm node facts - name: assert reading docker swarm node facts

View file

@ -1,6 +1,6 @@
- include_tasks: test_node_facts.yml - include_tasks: test_node_info.yml
# Maximum of 1.24 (docker API version for docker_node_facts) and 1.25 (docker API version for docker_swarm) is 1.25 # Maximum of 1.24 (docker API version for docker_node_info) and 1.25 (docker API version for docker_swarm) is 1.25
when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=') when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')
- fail: msg="Too old docker / docker-py version to run docker_node_facts tests!" - fail: msg="Too old docker / docker-py version to run docker_node_info tests!"
when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

View file

@ -5,8 +5,8 @@
state: absent state: absent
force: true force: true
- name: Try to get docker_node_facts when docker is not running in swarm mode - name: Try to get docker_node_info when docker is not running in swarm mode
docker_node_facts: docker_node_info:
ignore_errors: yes ignore_errors: yes
register: output register: output
@ -29,8 +29,8 @@
- 'output.swarm_facts.JoinTokens.Manager' - 'output.swarm_facts.JoinTokens.Manager'
- 'output.swarm_facts.JoinTokens.Worker' - 'output.swarm_facts.JoinTokens.Worker'
- name: Try to get docker_node_facts when docker is running in swarm mode and as manager - name: Try to get docker_node_info when docker is running in swarm mode and as manager
docker_node_facts: docker_node_info:
register: output register: output
- name: assert reading docker swarm node facts - name: assert reading docker swarm node facts
@ -39,8 +39,8 @@
- 'output.nodes | length > 0' - 'output.nodes | length > 0'
- 'output.nodes[0].ID is string' - 'output.nodes[0].ID is string'
- name: Try to get docker_node_facts using the self parameter - name: Try to get docker_node_info using the self parameter
docker_node_facts: docker_node_info:
self: yes self: yes
register: output register: output
@ -55,8 +55,8 @@
localnodename: "{{ output.nodes[0].Description.Hostname }}" localnodename: "{{ output.nodes[0].Description.Hostname }}"
- name: Try to get docker_node_facts using the local node name as parameter - name: Try to get docker_node_info using the local node name as parameter
docker_node_facts: docker_node_info:
name: "{{ localnodename }}" name: "{{ localnodename }}"
register: output register: output
@ -70,8 +70,8 @@
set_fact: set_fact:
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}" randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
- name: Try to get docker_node_facts using random node name as parameter - name: Try to get docker_node_info using random node name as parameter
docker_node_facts: docker_node_info:
name: "{{ randomnodename }}" name: "{{ randomnodename }}"
register: output register: output

View file

@ -67,7 +67,7 @@
debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.key') }}" debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
- name: Cert - name: Cert
debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}" debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
- docker_swarm_facts: - docker_swarm_info:
register: output register: output
ignore_errors: yes ignore_errors: yes
- debug: var=output - debug: var=output

View file

@ -1,6 +1,6 @@
- include_tasks: test_swarm_facts.yml - include_tasks: test_swarm_info.yml
# Maximum of 1.24 (docker API version for docker_swarm_facts) and 1.25 (docker API version for docker_swarm) is 1.25 # Maximum of 1.24 (docker API version for docker_swarm_info) and 1.25 (docker API version for docker_swarm) is 1.25
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=') 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_facts tests!" - 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) 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)

View file

@ -5,8 +5,8 @@
state: absent state: absent
force: true force: true
- name: Try to get docker_swarm_facts when docker is not running in swarm mode - name: Try to get docker_swarm_info when docker is not running in swarm mode
docker_swarm_facts: docker_swarm_info:
ignore_errors: yes ignore_errors: yes
register: output register: output
@ -32,8 +32,8 @@
- 'output.swarm_facts.JoinTokens.Manager' - 'output.swarm_facts.JoinTokens.Manager'
- 'output.swarm_facts.JoinTokens.Worker' - 'output.swarm_facts.JoinTokens.Worker'
- name: Try to get docker_swarm_facts when docker is running in swarm mode and as manager - name: Try to get docker_swarm_info when docker is running in swarm mode and as manager
docker_swarm_facts: docker_swarm_info:
register: output register: output
- name: assert creding docker swarm facts - name: assert creding docker swarm facts
@ -46,8 +46,8 @@
- 'output.docker_swarm_active == true' - 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true' - 'output.docker_swarm_manager == true'
- name: Try to get docker_swarm_facts and list of nodes when docker is running in swarm mode and as manager - name: Try to get docker_swarm_info and list of nodes when docker is running in swarm mode and as manager
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
register: output register: output
@ -67,8 +67,8 @@
localnodename: "{{ output.nodes[0].Hostname }}" localnodename: "{{ output.nodes[0].Hostname }}"
- name: Try to get docker_swarm_facts and verbose list of nodes when docker is running in swarm mode and as manager - name: Try to get docker_swarm_info and verbose list of nodes when docker is running in swarm mode and as manager
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
verbose_output: yes verbose_output: yes
register: output register: output
@ -85,8 +85,8 @@
- 'output.docker_swarm_active == true' - 'output.docker_swarm_active == true'
- 'output.docker_swarm_manager == true' - 'output.docker_swarm_manager == true'
- name: Try to get docker_swarm_facts and list of nodes with filters providing existing node name - name: Try to get docker_swarm_info and list of nodes with filters providing existing node name
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
nodes_filters: nodes_filters:
name: "{{ localnodename }}" name: "{{ localnodename }}"
@ -107,8 +107,8 @@
set_fact: set_fact:
randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}" randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
- name: Try to get docker_swarm_facts and list of nodes with filters providing non-existing random node name - name: Try to get docker_swarm_info and list of nodes with filters providing non-existing random node name
docker_swarm_facts: docker_swarm_info:
nodes: yes nodes: yes
nodes_filters: nodes_filters:
name: "{{ randomnodename }}" name: "{{ randomnodename }}"

View file

@ -10,7 +10,7 @@
state: absent state: absent
- name: Inspect a non-present volume - name: Inspect a non-present volume
docker_volume_facts: docker_volume_info:
name: "{{ cname }}" name: "{{ cname }}"
register: result register: result
@ -25,10 +25,10 @@
name: "{{ cname }}" name: "{{ cname }}"
- name: Inspect a present volume - name: Inspect a present volume
docker_volume_facts: docker_volume_info:
name: "{{ cname }}" name: "{{ cname }}"
register: result register: result
- name: Dump docker_volume_facts result - name: Dump docker_volume_info result
debug: var=result debug: var=result
- name: "Comparison: use 'docker volume inspect'" - name: "Comparison: use 'docker volume inspect'"
@ -54,5 +54,5 @@
# Requirements for docker_volume # Requirements for docker_volume
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=') when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')
- fail: msg="Too old docker / docker-py version to run docker_volume_facts tests!" - fail: msg="Too old docker / docker-py version to run docker_volume_info tests!"
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)