---
- name: Assert fail on EL 7 with version = 2022 and EL 9 with version != 2022
  include_tasks: assert_fail_on_unsupported_ver.yml

# role does not run during bootc QEMU validation, thus _is_booted is undefined
- name: Set __mssql_is_booted for bootc validation tests
  set_fact:
    __mssql_is_booted: true
  when: __bootc_validation | d(false)

- name: Set up MSSQL
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD"
    mssql_edition: Evaluation
    mssql_tools_versions: [17]
  when: not __bootc_validation | d(false)

- name: Configure the mssql-server service start limit interval and burst
  include_tasks: tasks/mssql-sever-increase-start-limit.yml
  when: not __bootc_validation | d(false)

- name: >-
    Change the password with default settings.
    Should report Changed.
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD11"
  when: not __bootc_validation | d(false)

- name: Verify settings
  include_tasks: tasks/verify_settings.yml
  vars:
    __verify_mssql_password: "p@55w0rD11"
  when: not __bootc_validation | d(false)

- name: Verify the package {{ __mssql_verify_package_name }}
  include_tasks: verify_package.yml
  vars:
    __mssql_verify_package_name: mssql-tools
    __mssql_verify_package_installed: true

- name: Change the IP address setting.
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_ip_address: 127.0.0.1
  when: not __bootc_validation | d(false)

- name: Create QEMU deployment during bootc end-to-end test
  delegate_to: localhost
  become: false
  command: "{{ lsr_scriptdir }}/bootc-buildah-qcow.sh {{ ansible_host }}"
  changed_when: true
  when: ansible_connection == "buildah"

- name: >-
    Change the password with a custom IP address.
    Should report Changed.
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD"
    mssql_tools_versions: [17, 18]
  when: not __bootc_validation | d(false)

- name: Verify settings
  include_tasks: tasks/verify_settings.yml
  vars:
    __verify_mssql_password: "p@55w0rD"
  when: not __bootc_validation | d(false)

- name: Verify the package {{ __mssql_verify_package_name }}
  include_tasks: verify_package.yml
  vars:
    __mssql_verify_package_name: mssql-tools18
    __mssql_verify_package_installed: true

- name: Change the TCP port setting.
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_tcp_port: 1432
  when: not __bootc_validation | d(false)

- name: >-
    Change the password with a custom TCP port and IP address.
    Should report Changed.
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD11"
    mssql_tools_versions: [18]
  when: not __bootc_validation | d(false)

- name: Verify settings
  include_tasks: tasks/verify_settings.yml
  vars:
    __verify_mssql_password: "p@55w0rD11"
  when: not __bootc_validation | d(false)

- name: Verify the package {{ __mssql_verify_package_name }}
  include_tasks: verify_package.yml
  vars:
    __mssql_verify_package_name: mssql-tools18
    __mssql_verify_package_installed: true

- name: Check the ansible_managed header in the configuration file
  include_tasks: tasks/check_header.yml
