# Each case is followed by mitogen_via= case to test hostvars method.

- name: integration/transport_config/host_key_checking.yml
  hosts: tc-hkc-unset
  tasks:
    - include_tasks: ../_mitogen_only.yml
    - {mitogen_get_stack: {}, register: out}
    - assert:
        that:
          - out.result | length == 1
          - out.result[0].method == "ssh"
          - out.result[0].kwargs.check_host_keys == "ignore"
        fail_msg: |
          out={{ out }}
  tags:
    - mitogen_only

- name: tc-hkc-unset via tc-hkc-host-key-checking
  hosts: tc-hkc-unset
  vars:
    mitogen_via: tc-hkc-host-key-checking
  tasks:
    - include_tasks: ../_mitogen_only.yml
    - {mitogen_get_stack: {}, register: out}
    - assert:
        that:
          - out.result | length == 2
          - out.result[0].method == "ssh"
          - out.result[0].kwargs.check_host_keys == "enforce"
          - out.result[1].method == "ssh"
          - out.result[1].kwargs.check_host_keys == "ignore"
        fail_msg: |
          out={{ out }}
  tags:
    - mitogen_only


- hosts: tc-hkc-host-key-checking
  tasks:
    - include_tasks: ../_mitogen_only.yml
    - {mitogen_get_stack: {}, register: out}
    - assert:
        that:
          - out.result | length == 1
          - out.result[0].method == "ssh"
          - out.result[0].kwargs.check_host_keys == "enforce"
        fail_msg: |
          out={{ out }}
  tags:
    - mitogen_only

- name: tc-hkc-host-key-checking via tc-hkc-unset
  hosts: tc-hkc-host-key-checking
  vars:
    mitogen_via: tc-hkc-unset
  tasks:
    - include_tasks: ../_mitogen_only.yml
    - {mitogen_get_stack: {}, register: out}
    - assert:
        that:
          - out.result | length == 2
          - out.result[0].method == "ssh"
          - out.result[0].kwargs.check_host_keys == "ignore"
          - out.result[1].method == "ssh"
          - out.result[1].kwargs.check_host_keys == "enforce"
        fail_msg: |
          out={{ out }}
  tags:
    - mitogen_only


- hosts: tc-hkc-ssh-host-key-checking
  tasks:
    - include_tasks: ../_mitogen_only.yml
    - {mitogen_get_stack: {}, register: out}
    - assert:
        that:
          - out.result | length == 1
          - out.result[0].method == "ssh"
          - out.result[0].kwargs.check_host_keys == "enforce"
        fail_msg: |
          out={{ out }}
  tags:
    - mitogen_only

- name: tc-hkc-ssh-host-key-checking via tc-hkc-unset
  hosts: tc-hkc-ssh-host-key-checking
  vars:
    mitogen_via: tc-hkc-unset
  tasks:
    - include_tasks: ../_mitogen_only.yml
    - {mitogen_get_stack: {}, register: out}
    - assert:
        that:
          - out.result | length == 2
          - out.result[0].method == "ssh"
          - out.result[0].kwargs.check_host_keys == "ignore"
          - out.result[1].method == "ssh"
          - out.result[1].kwargs.check_host_keys == "enforce"
        fail_msg: |
          out={{ out }}
  tags:
    - mitogen_only
