# SPDX-License-Identifier: MIT
---
- name: Verify node_name in ha_cluster_node_options check is working
  hosts: all
  vars_files: vars/main.yml

  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: Find first node name
          set_fact:
            __test_first_node: "{{
                (ansible_play_hosts_all | length == 1)
                | ternary('localhost', ansible_play_hosts[0]) }}"

        - name: Verify node options check is working for various input data
          include_tasks: tasks/assert_node_options_check.yml
          loop:
            # yamllint disable rule:hyphens
            -
              - node_name: "{{ __test_first_node }}"
              - node_name: "{{ __test_first_node }}"
            -
              - node_name: "{{ __test_first_node }}"
              - node_name: "{{ __test_first_node ~ 'x' }}"
              # yamllint enable rule:hyphens
          loop_control:
            loop_var: ha_cluster_node_options
