Skip to content

Commit

Permalink
Apply feedback from Noriko and Rich
Browse files Browse the repository at this point in the history
- Add `mssql_debug`
- Note that role manages firewall only if firewalld started or enabled
- Fix typos
  • Loading branch information
spetrosi committed May 18, 2022
1 parent 3426237 commit 80d1a93
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
18 changes: 17 additions & 1 deletion README.md
Expand Up @@ -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.
Expand Down Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tasks/input_sql_file.yml
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions tasks/main.yml
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion 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;
Expand Down
5 changes: 3 additions & 2 deletions tests/tests_configure_ha_cluster.yml
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 80d1a93

Please sign in to comment.