# SPDX-License-Identifier: MIT
---
- name: Cluster with knet transport, transport type not specified
  hosts: all
  vars_files: vars/main.yml
  vars:
    ha_cluster_cluster_name: test-cluster
    ha_cluster_transport:
      crypto:
        - name: cipher
          value: none
        - name: hash
          value: none

  tasks:
    - name: Run test
      tags: tests::verify
      block:
        - name: Set up test environment
          include_role:
            name: linux-system-roles.ha_cluster
            tasks_from: test_setup.yml

        - name: Run HA Cluster role
          include_role:
            name: linux-system-roles.ha_cluster
            public: true

        - name: Fetch cluster versions of cluster components
          include_tasks: tasks/fetch_versions.yml

        - name: Check corosync
          include_tasks: tasks/assert_corosync_config.yml
          vars:
            # noqa jinja[spacing]
            __test_expected_lines:
              - 'totem {'
              - '    version: 2'
              - '    cluster_name: {{ ha_cluster_cluster_name }}'
              - '    transport: knet'
              - '    crypto_cipher: none'
              - '    crypto_hash: none'
              - '}'
              - 'nodelist {'
              - '}'
              - 'quorum {'
              - '    provider: corosync_votequorum'
              - "{{ (ansible_play_hosts_all | length == 2) | ternary(
                '    two_node: 1',
                '') }}"
              - '}'
              - 'logging {'
              - '    to_logfile: yes'
              - '    logfile: /var/log/cluster/corosync.log'
              - '    to_syslog: yes'
              - '    timestamp: on'
              - '}'

        - name: Check cluster status
          include_tasks: tasks/assert_cluster_running.yml

        - name: Check firewall and selinux state
          include_tasks: tasks/check_firewall_selinux.yml
