---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

####################################################################
# WARNING: These are designed specifically for Ansible tests       #
# and should not be used as examples of how to write Ansible roles #
####################################################################

- include_tasks: test_host_info.yml
  when: docker_api_version is version('1.25', '>=')

- fail: msg="Too old docker / docker-py version to run docker_host_info tests!"
  when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)

- when: podman_cli_version is version('1.0.0', '>=')
  block:
    - name: Get Podman context
      community.docker.docker_context_info:
        name: podman
      register: docker_podman_context

    - name: Run tests with Podman context
      module_defaults:
        group/community.docker.docker: "{{ docker_podman_context.contexts[0].config }}"
      block:

        - name: Get info on Podman host
          docker_host_info:
          register: output

        - name: Check for some Podman specific values
          assert:
            that:
              - output.host_info.ProductLicense == 'Apache-2.0'
              - >-
                "Rootless" in output.host_info
