Skip to content

Commit

Permalink
feat: Support mssql-server 2022 preview on RHEL 9
Browse files Browse the repository at this point in the history
- Add --noprompt to suppress "This is a preview version" and other
messages when setting up mssql server
- vars/RedHat.yml  for RHEL 9 that only supports SQL Server 2022
- Use tests/tasks/assert_fail_on_unsupported_ver.yml for general version
  assert
  • Loading branch information
spetrosi committed Oct 11, 2023
1 parent ab6966d commit 7d22728
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 31 deletions.
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ galaxy_info:
- "35"
- name: EL
versions:
- "9"
- "8"
- "7"
galaxy_tags:
Expand Down
13 changes: 3 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,6 @@
You must set the mssql_version variable to one of
{{ __mssql_supported_versions | join(", ") }}
- name: Verify that version 2022 is not used with RHEL 7
fail:
msg: >-
SQL Server 2022 does not support EL 7 hosts
when:
- mssql_version | int == 2022
- ansible_distribution in ['CentOS', 'RedHat']
- ansible_distribution_major_version is version('8', '<')

- name: >-
Verify if mssql_version is not smaller then the existing SQL Server version
fail:
Expand All @@ -150,6 +141,8 @@
rpm_key:
key: "{{ mssql_rpm_key }}"
state: present
register: __mssql_gpg
until: __mssql_gpg is success

- name: Prepare for the upgrade
when:
Expand Down Expand Up @@ -259,7 +252,7 @@
- name: Set up MSSQL # noqa command-instead-of-shell
shell: >-
MSSQL_SA_PASSWORD={{ mssql_password | quote }}
{{ __mssql_conf_cli }} setup
{{ __mssql_conf_cli }} --noprompt setup
environment:
ACCEPT_EULA: "Y"
MSSQL_PID: "{{ mssql_edition }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
setup:
gather_subset: min

- name: Assert fail on RHEL 7 when upgrading to 2022
when:
- ansible_distribution in ['CentOS', 'RedHat']
- ansible_distribution_version is version('8', '<')
- name: Assert fail on EL 7 with version = 2022 and EL 9 with version != 2022
when: >-
(ansible_distribution in ['CentOS', 'RedHat'] and
ansible_distribution_major_version is version('7', '=') and
mssql_version == 2022) or
(ansible_distribution in ['CentOS', 'RedHat'] and
ansible_distribution_major_version is version('9', '=') and
mssql_version != 2022)
block:
- name: Run the role
vars:
mssql_version: 2022
mssql_password: "p@55w0rD"
mssql_edition: Evaluation
include_role:
Expand All @@ -23,9 +26,9 @@
- name: Assert that the role failed with EL < 8 not supported
assert:
that: >-
'SQL Server 2022 does not support EL 7 hosts'
'You must set the mssql_version variable to one of'
in ansible_failed_result.msg
always:
- name: Clean up after the role invocation
include_tasks: tasks/cleanup.yml

Expand Down
5 changes: 2 additions & 3 deletions tests/tasks/tests_idempotency.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Assert fail on RHEL 7 when upgrading to 2022
include_tasks: sqlserver2022-rhel7-assert-fail.yml
when: mssql_version | int == 2022
- 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:
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/tests_input_sql_file.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Assert fail on RHEL 7 when upgrading to 2022
include_tasks: sqlserver2022-rhel7-assert-fail.yml
include_tasks: assert_fail_on_unsupported_ver.yml
when: mssql_version | int == 2022

- name: Set up MSSQL and input sql files with pre_input
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/tests_password.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Assert fail on RHEL 7 when upgrading to 2022
include_tasks: sqlserver2022-rhel7-assert-fail.yml
include_tasks: assert_fail_on_unsupported_ver.yml
when: mssql_version | int == 2022

- name: Set up MSSQL
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/tests_tcp_firewall.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Assert fail on RHEL 7 when upgrading to 2022
include_tasks: sqlserver2022-rhel7-assert-fail.yml
include_tasks: assert_fail_on_unsupported_ver.yml
when: mssql_version | int == 2022

- name: Test while not settings mssql_tcp_port to default it to 1433
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/tests_tls.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Assert fail on RHEL 7 when upgrading to 2022
include_tasks: sqlserver2022-rhel7-assert-fail.yml
include_tasks: assert_fail_on_unsupported_ver.yml
when: mssql_version | int == 2022

- name: Ensure the openssl package
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/upgrade_and_assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'SQL Server 2022 does not support EL 7 hosts'
in ansible_failed_result.msg
always:
- name: Clean up EL 7after the role invocation
- name: Clean up EL 7 after the role invocation
when:
- __mssql_version == 2022
- ansible_distribution in ['CentOS', 'RedHat']
Expand Down
5 changes: 5 additions & 0 deletions tests/tests_2019_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
mssql_accept_microsoft_cli_utilities_for_sql_server_eula: true
mssql_accept_microsoft_sql_server_standard_eula: true
tasks:
- name: Assert fail on EL 7 with version=2022 and EL 9 with version!=2022
include_tasks: tasks/assert_fail_on_unsupported_ver.yml
vars:
mssql_version: 2017

- name: Run test in a block to clean up in always
block:
- name: Verify the failure when mssql_version is provided incorrectly
Expand Down
5 changes: 5 additions & 0 deletions tests/tests_2022_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
mssql_accept_microsoft_cli_utilities_for_sql_server_eula: true
mssql_accept_microsoft_sql_server_standard_eula: true
tasks:
- name: Assert fail on EL 7 with version=2022 and EL 9 with version!=2022
include_tasks: tasks/assert_fail_on_unsupported_ver.yml
vars:
mssql_version: 2019

- name: Run test in a block to clean up in always
block:
- name: Verify the failure when mssql_version is provided incorrectly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
mssql_accept_microsoft_odbc_driver_17_for_sql_server_eula: true
mssql_accept_microsoft_cli_utilities_for_sql_server_eula: true
mssql_accept_microsoft_sql_server_standard_eula: true
mssql_version: 2017
mssql_version: "{{
'2022' if ansible_distribution_major_version is version('9', '>=')
else '2017' }}"
tasks:
- name: Run test in a block to clean up in always
block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
# noqa var-naming[no-role-prefix]
mssql_accept_microsoft_sql_server_standard_eula: true
# noqa var-naming[no-role-prefix]
mssql_version: 2019
mssql_version: "{{
'2022' if ansible_distribution_major_version is version('9', '>=')
else '2017' }}"
# noqa var-naming[no-role-prefix]
mssql_password: P@55w0rD
# noqa var-naming[no-role-prefix]
Expand Down
6 changes: 2 additions & 4 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# SPDX-License-Identifier: MIT
---
__mssql_server_repository: >-
https://packages.microsoft.com/rhel/8/mssql-server-{{ mssql_version | int }}/
https://packages.microsoft.com/rhel/9/mssql-server-preview/
__mssql_client_repository: >-
https://packages.microsoft.com/rhel/8/prod/
https://packages.microsoft.com/rhel/9/prod/
__mssql_supported_versions:
- 2017
- 2019
- 2022
10 changes: 10 additions & 0 deletions vars/RedHat_8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: MIT
---
__mssql_server_repository: >-
https://packages.microsoft.com/rhel/8/mssql-server-{{ mssql_version | int }}/
__mssql_client_repository: >-
https://packages.microsoft.com/rhel/8/prod/
__mssql_supported_versions:
- 2017
- 2019
- 2022

0 comments on commit 7d22728

Please sign in to comment.