diff --git a/README.md b/README.md index b3c82378..67015598 100644 --- a/README.md +++ b/README.md @@ -167,12 +167,25 @@ and does not input any SQL file. Note that this task is not idempotent, the role always inputs an SQL file if this variable is defined. +When this variable is defined, `mssql_debug` is set to true to print the output +of the sqlcmd command. + You can find an example of the SQL file at `tests/sql_script.sql`. Default: `null` Type: `str` +### `mssql_debug` + +Whether or not to print the output of sqlcmd commands. The role inputs SQL +scripts with the sqlcmd command to configure SQL Server or to input users' SQL +scripts when the `mssql_input_sql_file` variable is provided. + +Default: `true` if `mssql_input_sql_file` is defined else `false` + +Type: `bool` + ### `mssql_enable_sql_agent` Set this variable to `true` or `false` to enable or disable the SQL agent. @@ -363,12 +376,15 @@ The available values are: `primary`, `synchronous`, `witness`. Default: no -Type: `bool` +Type: `str` #### `mssql_ha_firewall_configure` Whether to configure firewall for high availability or not. +The role configures firewall only if the `firewalld` service has been started or +enabled. + Default: `true` Type: `bool` diff --git a/defaults/main.yml b/defaults/main.yml index 96320427..00a774ba 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,6 +10,7 @@ mssql_edition: null mssql_tcp_port: null mssql_ip_address: null mssql_input_sql_file: null +mssql_debug: "{{ true if mssql_input_sql_file is not none else false }}" mssql_enable_sql_agent: null mssql_install_fts: null mssql_install_powershell: null diff --git a/tasks/input_sql_file.yml b/tasks/input_sql_file.yml index 442618d0..da9ed095 100644 --- a/tasks/input_sql_file.yml +++ b/tasks/input_sql_file.yml @@ -62,7 +62,9 @@ debug: var: __mssql_sqlcmd_input_file.stdout_lines changed_when: false - when: __mssql_sqlcmd_input_file.stdout_lines is defined + when: + - __mssql_sqlcmd_input_file.stdout_lines is defined + - mssql_debug | bool # Keep the file if the SQL command failed for debugging - name: Remove the tempfile diff --git a/tasks/main.yml b/tasks/main.yml index 28792842..6d8cbba7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -444,16 +444,17 @@ - name: Open required firewall ports and set required facts when: - mssql_ha_configure | bool - - mssql_ha_firewall_configure | bool - - >- - ('running' in - ansible_facts['services']['firewalld.service']['state']) or - ('enabled' in - ansible_facts['services']['firewalld.service']['status']) block: - name: >- Open the {{ mssql_ha_listener_port }}/tcp port and enable the high-availability service + when: + - mssql_ha_firewall_configure | bool + - >- + ('running' in + ansible_facts['services']['firewalld.service']['state']) or + ('enabled' in + ansible_facts['services']['firewalld.service']['status']) include_role: name: fedora.linux_system_roles.firewall vars: diff --git a/templates/create_and_back_up_cert.j2 b/templates/create_and_back_up_cert.j2 index f3089aae..c49e047a 100644 --- a/templates/create_and_back_up_cert.j2 +++ b/templates/create_and_back_up_cert.j2 @@ -1,5 +1,5 @@ -- Enabling NOCOUNT to suppress (1 rows affected) messages from DECLARE --- keywordss on the output +-- keywords on the output SET NOCOUNT ON; DECLARE @cerExists INT; diff --git a/tests/tests_configure_ha_cluster.yml b/tests/tests_configure_ha_cluster.yml index f4e29a91..5720f978 100644 --- a/tests/tests_configure_ha_cluster.yml +++ b/tests/tests_configure_ha_cluster.yml @@ -9,6 +9,7 @@ mssql_password: "p@55w0rD" mssql_edition: Evaluation mssql_ha_db_name: ExampleDB + mssql_debug: true tasks: # - name: Gather system services facts # service_facts: @@ -30,10 +31,10 @@ # ansible_facts['services']['firewalld.service']['status']) # include_role: # name: fedora.linux_system_roles.firewall - - name: Skip this test on EL < 7 because ha_cluster does not support it + - name: Skip this test on EL < 8 because ha_cluster does not support it meta: end_play when: - - ansible_distribution_version is version('8.3', '<') + - ansible_distribution_version is version('8', '<') - ansible_distribution in ['CentOS', 'RedHat'] - name: Set the mssql_ha_replica_type fact to appear in hostvars