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

- name: Run on a fresh host and set all parameters
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD"
    mssql_edition: Evaluation
    mssql_tcp_port: 1433
    mssql_ip_address: 0.0.0.0
    mssql_enable_sql_agent: true
    mssql_install_fts: true
    mssql_tune_for_fua_storage: true
    mssql_install_powershell: true
    mssql_datadir: /tmp/mssql_data
    mssql_logdir: /tmp/mssql_log

- name: Configure the mssql-server service start limit interval and burst
  include_tasks: mssql-sever-increase-start-limit.yml

- name: Run again with the same settings - should report not changed
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD"
    mssql_edition: Evaluation
    mssql_tcp_port: 1433
    mssql_ip_address: 0.0.0.0
    mssql_enable_sql_agent: true
    mssql_install_fts: true
    mssql_tune_for_fua_storage: true
    mssql_install_powershell: true
    mssql_datadir: /tmp/mssql_data
    mssql_logdir: /tmp/mssql_log

- name: Verify settings
  include_tasks: verify_settings.yml
  vars:
    __verify_mssql_password: "p@55w0rD"
    __verify_mssql_edition: Evaluation
    __verify_mssql_tcp_port: 1433
    __verify_mssql_ip_address: 0.0.0.0
    __verify_mssql_agent_is_enabled: true
    __verify_mssql_fts_is_installed: true
    __verify_mssql_is_tuned_for_fua: true
    __verify_mssql_powershell_is_installed: true
    __verify_mssql_datadir: /tmp/mssql_data
    __verify_mssql_logdir: /tmp/mssql_log

- name: Run to edit settings
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD1"
    mssql_edition: Standard
    mssql_tcp_port: 1435
    mssql_ip_address: 127.0.0.1
    mssql_enable_sql_agent: false
    mssql_install_fts: false
    mssql_tune_for_fua_storage: false
    mssql_install_powershell: false
    mssql_datadir: /var/opt/mssql/data
    mssql_logdir: /var/opt/mssql/log
    mssql_datadir_mode: '755'
    mssql_logdir_mode: '755'

- name: Run with the edited settings again - should report not changed
  include_role:
    name: linux-system-roles.mssql
  vars:
    mssql_password: "p@55w0rD1"
    mssql_edition: Standard
    mssql_tcp_port: 1435
    mssql_ip_address: 127.0.0.1
    mssql_enable_sql_agent: false
    mssql_install_fts: false
    mssql_tune_for_fua_storage: false
    mssql_install_powershell: false
    mssql_datadir: /var/opt/mssql/data
    mssql_logdir: /var/opt/mssql/log

- name: Verify disabled settings
  include_tasks: verify_settings.yml
  vars:
    __verify_mssql_password: "p@55w0rD1"
    __verify_mssql_edition: Standard
    __verify_mssql_tcp_port: 1435
    __verify_mssql_ip_address: 127.0.0.1
    __verify_mssql_agent_is_enabled: false
    __verify_mssql_fts_is_installed: false
    __verify_mssql_ha_is_installed: false
    __verify_mssql_is_tuned_for_fua: false
    __verify_mssql_powershell_is_installed: false
    __verify_mssql_datadir: /var/opt/mssql/data
    __verify_mssql_logdir: /var/opt/mssql/log
    __verify_mssql_datadir_mode: '0755'
    __verify_mssql_logdir_mode: '0755'

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