Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Database enhancements #681

Merged
merged 22 commits into from
Apr 21, 2022
Merged

Conversation

l3ender
Copy link
Contributor

@l3ender l3ender commented Nov 11, 2021

SUMMARY

This PR updates the following:

  • Bumps sql SDK to latest version.
  • Adds following parameters to azure_rm_sqlserver:
    • minimal_tls_version: minimum TLS version allowed by the client.
    • public_network_access: enable/disable public network access.
    • restrict_outbound_network_access: enable/disable outbound network access.
    • change_admin_password: allow module usage for updating SQL password.
    • administrators: configure Azure Active Directory administrator for the server.
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • azure_rm_sqlserver
  • azure_rm_sqlserver_info
ADDITIONAL INFORMATION

Using the following playbook at the root of this repo:

---
- name: "Playbook for testing."
  hosts: "localhost"
  connection: "local"
  gather_facts: false
  vars:
    resource_group: "test-rg"
  collections:
    - azure.azcollection

  tasks:
    - name: "Include tests"
      include_tasks: tests/integration/targets/azure_rm_sqlserver/tasks/main.yml

@l3ender
Copy link
Contributor Author

l3ender commented Nov 11, 2021

@Fred-sun Here is another PR to review--thank you!

@Fred-sun
Copy link
Collaborator

@l3ender Thank you for your contribution. We will push forward the import process of new SDK as soon as possible and review the PR. Thank you very much!

@Fred-sun Fred-sun added enhancement New feature or request new_feature New feature requirments work in In trying to solve, or in working with contributors medium_priority Medium priority labels Nov 12, 2021
@Fred-sun Fred-sun added the hold The problem holds for a particular reason label Nov 23, 2021
@l3ender
Copy link
Contributor Author

l3ender commented Feb 26, 2022

Hello @Fred-sun, can you please update on this PR? Thank you!!

@Fred-sun
Copy link
Collaborator

@l3ender Ok, I will push forward the merger of this PR as soon as possible. Thank you very much!

@Fred-sun Fred-sun removed the hold The problem holds for a particular reason label Feb 27, 2022
@Fred-sun
Copy link
Collaborator

Fred-sun commented Mar 9, 2022

@l3ender Thank you for your contribution, because our test account does not have permission to create adgroup-related resources, please delete the azure_rm_adgroup related use cases from the use case. Another, Please resolve the conflict file. Thank you!

@l3ender
Copy link
Contributor Author

l3ender commented Mar 10, 2022

Hi @Fred-sun, I have resolved the conflicts and updated the PR to default the azure_rm_adgroup related tasks to not execute. I would like to keep them as optional in case someone wants to run the whole test case from start to finish--this is helpful for someone like me to ensure no breaking changes occur when making updates.

Please take another look. Thank you!

@Fred-sun
Copy link
Collaborator

@l3ender Thank you for your update. Do you have any test cases implemented? And you get a PASS. Thank you very much!

@l3ender
Copy link
Contributor Author

l3ender commented Mar 10, 2022

Hi @Fred-sun! I have run the SQL tests using the following playbook. All tests have passed with no issue.

---
- name: "Playbook for testing."
  hosts: "localhost"
  connection: "local"
  gather_facts: false
  vars:
    resource_group: "automated-testing"
    resource_group_secondary: "automated-testing-secondary"
    azure_tenant: "5fa44015-7a98-419d-a210-311acc1216b9"
  collections:
    - azure.azcollection

  tasks:
    - name: "Include tests"
      include_tasks: "tests/integration/targets/azure_rm_sqlserver/tasks/main.yml"

I ran it like so:

ansible-playbook sandbox.yml -v
Click to view playbook output
(venv) ross@IT-LT207:/mnt/d/repos/azure$ ansible-playbook sandbox.yml -v
No config file found; using defaults
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'

PLAY [Playbook for testing.] *******************************************************************************************

TASK [Include tests] ***************************************************************************************************
included: /mnt/d/repos/azure/tests/integration/targets/azure_rm_sqlserver/tasks/main.yml for localhost

TASK [Prepare random number] *******************************************************************************************
ok: [localhost] => {"ansible_facts": {"random_postfix": "969ef45326", "sql_admin_group": "Test Security Group", "tenant_id": "5fa44015-7a98-419d-a210-311acc1216b9"}, "changed": false}

TASK [Create instance of SQL Server -- check mode] *********************************************************************
[WARNING]: Azure API profile latest does not define an entry for SqlManagementClient
changed: [localhost] => {"changed": true}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of SQL Server] ***********************************************************************************
changed: [localhost] => {"changed": true, "fully_qualified_domain_name": "sqlsrv969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326", "state": "Ready", "version": "12.0"}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create again instance of SQL Server] *****************************************************************************
ok: [localhost] => {"changed": false, "compare": ["new item was empty, using old [][ tags ]"], "fully_qualified_domain_name": "sqlsrv969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326", "modifiers": {}, "state": "Ready", "version": "12.0"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create extended instance of SQL Server] **************************************************************************
changed: [localhost] => {"changed": true, "fully_qualified_domain_name": "sqlsrv-extended-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-extended-969ef45326", "state": "Ready", "version": "12.0"}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create extended instance of SQL Server - idempotent] *************************************************************
ok: [localhost] => {"changed": false, "compare": ["new item was empty, using old [][ tags ]"], "fully_qualified_domain_name": "sqlsrv-extended-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-extended-969ef45326", "modifiers": {}, "state": "Ready", "version": "12.0"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Update SQL admin password] ***************************************************************************************
changed: [localhost] => {"changed": true, "compare": ["changed [/administrator_login_password] ******** != None - default"], "fully_qualified_domain_name": "sqlsrv-extended-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-extended-969ef45326", "modifiers": {}, "state": "Ready", "version": "12.0"}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Get Azure AD group info] *****************************************************************************************
ok: [localhost] => {"ad_groups": [{"display_name": "Test Security Group", "mail": null, "mail_enabled": false, "mail_nickname": "3fe5305c-0", "object_id": "2801231e-a95d-4f7f-a768-133a4a14f8a7", "security_enabled": true}], "changed": false}

TASK [Assert AD group exists] ******************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of SQL Server with Azure AD admin] ***************************************************************
changed: [localhost] => {"changed": true, "fully_qualified_domain_name": "sqlsrv-azuread-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-azuread-969ef45326", "state": "Ready", "version": "12.0"}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of SQL Server with Azure AD admin - idempotent] **************************************************
ok: [localhost] => {"changed": false, "compare": [], "fully_qualified_domain_name": "sqlsrv-azuread-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-azuread-969ef45326", "modifiers": {}, "state": "Ready", "version": "12.0"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Server] *****************************************************************************************
ok: [localhost] => {"changed": false, "servers": {"sqlsrv969ef45326": {"admin_username": "mylogin", "administrators": null, "fully_qualified_domain_name": "sqlsrv969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326", "kind": "v12.0", "location": "eastus", "minimal_tls_version": null, "name": "sqlsrv969ef45326", "public_network_access": "Enabled", "restrict_outbound_network_access": "Disabled", "state": "Ready", "tags": {"aaa": "bbb"}, "type": "Microsoft.Sql/servers", "version": "12.0"}}}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts for extended SQL Server] ****************************************************************************
ok: [localhost] => {"changed": false, "servers": {"sqlsrv-extended-969ef45326": {"admin_username": "mylogin2", "administrators": null, "fully_qualified_domain_name": "sqlsrv-extended-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-extended-969ef45326", "kind": "v12.0", "location": "eastus", "minimal_tls_version": "1.2", "name": "sqlsrv-extended-969ef45326", "public_network_access": "Disabled", "restrict_outbound_network_access": "Enabled", "state": "Ready", "tags": {"aaa": "bbb"}, "type": "Microsoft.Sql/servers", "version": "12.0"}}}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts for SQL Server with Azure AD admin] *****************************************************************
ok: [localhost] => {"changed": false, "servers": {"sqlsrv-azuread-969ef45326": {"admin_username": "sqllogin", "administrators": {"administrator_type": "ActiveDirectory", "azure_ad_only_authentication": false, "login": "Test Security Group", "principal_type": "Group", "sid": "2801231e-a95d-4f7f-a768-133a4a14f8a7", "tenant_id": "5fa44015-7a98-419d-a210-311acc1216b9"}, "fully_qualified_domain_name": "sqlsrv-azuread-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-azuread-969ef45326", "kind": "v12.0", "location": "eastus", "minimal_tls_version": null, "name": "sqlsrv-azuread-969ef45326", "public_network_access": "Enabled", "restrict_outbound_network_access": "Disabled", "state": "Ready", "tags": {}, "type": "Microsoft.Sql/servers", "version": "12.0"}}}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Server - unexisting] ****************************************************************************
ok: [localhost] => {"changed": false, "servers": {}}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Server - list] **********************************************************************************
ok: [localhost] => {"changed": false, "servers": {"sqlsrv-azuread-969ef45326": {"admin_username": "sqllogin", "administrators": {"administrator_type": "ActiveDirectory", "azure_ad_only_authentication": false, "login": "Test Security Group", "principal_type": "Group", "sid": "2801231e-a95d-4f7f-a768-133a4a14f8a7", "tenant_id": "5fa44015-7a98-419d-a210-311acc1216b9"}, "fully_qualified_domain_name": "sqlsrv-azuread-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-azuread-969ef45326", "kind": "v12.0", "location": "eastus", "minimal_tls_version": null, "name": "sqlsrv-azuread-969ef45326", "public_network_access": "Enabled", "restrict_outbound_network_access": "Disabled", "state": "Ready", "tags": {}, "type": "Microsoft.Sql/servers", "version": "12.0"}, "sqlsrv-extended-969ef45326": {"admin_username": "mylogin2", "administrators": null, "fully_qualified_domain_name": "sqlsrv-extended-969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv-extended-969ef45326", "kind": "v12.0", "location": "eastus", "minimal_tls_version": "1.2", "name": "sqlsrv-extended-969ef45326", "public_network_access": "Disabled", "restrict_outbound_network_access": "Enabled", "state": "Ready", "tags": {"aaa": "bbb"}, "type": "Microsoft.Sql/servers", "version": "12.0"}, "sqlsrv969ef45326": {"admin_username": "mylogin", "administrators": null, "fully_qualified_domain_name": "sqlsrv969ef45326.database.windows.net", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326", "kind": "v12.0", "location": "eastus", "minimal_tls_version": null, "name": "sqlsrv969ef45326", "public_network_access": "Enabled", "restrict_outbound_network_access": "Disabled", "state": "Ready", "tags": {"aaa": "bbb"}, "type": "Microsoft.Sql/servers", "version": "12.0"}}}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of SQL Database -- check mode] *******************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of SQL Database] *********************************************************************************
changed: [localhost] => {"changed": true, "database_id": "6ba2eb43-2c9a-40f4-9dc2-a72150fe3a03", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326", "status": "Online"}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create again instance of SQL Database] ***************************************************************************
ok: [localhost] => {"changed": false, "database_id": "6ba2eb43-2c9a-40f4-9dc2-a72150fe3a03", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326", "status": "Online"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Database and wait for restore point] ************************************************************
FAILED - RETRYING: [localhost]: Gather facts SQL Database and wait for restore point (10 retries left).
FAILED - RETRYING: [localhost]: Gather facts SQL Database and wait for restore point (9 retries left).
ok: [localhost] => {"attempts": 3, "changed": false, "databases": [{"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": "2022-03-10T18:41:21.000Z", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326", "kind": "v12.0,user", "location": "eastus", "name": "database969ef45326", "resource_group": "automated-testing", "sku": {"capacity": 250, "name": "P2", "tier": "Premium"}, "status": "Online", "tags": {"aaa": "bbb"}, "zone_redundant": false}]}

TASK [Assert that it can be restored from] *****************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create second SQL Database, restoring from the previous Database] ************************************************
changed: [localhost] => {"changed": true, "database_id": "daec2188-7374-4c73-878c-f80d002b6695", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326PITR", "status": "Online"}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of SQL Database Point in time recovery] **********************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create second SQL Database] **************************************************************************************
changed: [localhost] => {"changed": true, "database_id": "e422ee4e-2137-4b22-b045-0dca32ee071e", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326second", "status": "Online"}

TASK [Gather facts SQL Database] ***************************************************************************************
ok: [localhost] => {"changed": false, "databases": [{"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": "2022-03-10T18:41:21.000Z", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326", "kind": "v12.0,user", "location": "eastus", "name": "database969ef45326", "resource_group": "automated-testing", "sku": {"capacity": 250, "name": "P2", "tier": "Premium"}, "status": "Online", "tags": {"aaa": "bbb"}, "zone_redundant": false}]}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Database] ***************************************************************************************
ok: [localhost] => {"changed": false, "databases": [{"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": null, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326second", "kind": "v12.0,user,vcore", "location": "eastus", "name": "database969ef45326second", "resource_group": "automated-testing", "sku": {"capacity": 2, "name": "GP_Gen5_2", "tier": "GeneralPurpose"}, "status": "Online", "tags": null, "zone_redundant": false}, {"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": null, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/master", "kind": "v12.0,system", "location": "eastus", "name": "master", "resource_group": "automated-testing", "sku": {"capacity": 0, "name": "System2", "tier": "System"}, "status": "Online", "tags": null, "zone_redundant": false}, {"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": "2022-03-10T18:41:21.000Z", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef45326", "kind": "v12.0,user", "location": "eastus", "name": "database969ef45326", "resource_group": "automated-testing", "sku": {"capacity": 250, "name": "P2", "tier": "Premium"}, "status": "Online", "tags": {"aaa": "bbb"}, "zone_redundant": false}]}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of secondary database] ***************************************************************************
changed: [localhost] => {"changed": true}

TASK [Delete instance of SQL Database -- check mode] *******************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of SQL Database] *********************************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete unexisting instance of SQL Database] **********************************************************************
ok: [localhost] => {"changed": false}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create SQL Database with sku -- check mode] **********************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create SQL Database with sku] ************************************************************************************
changed: [localhost] => {"changed": true, "database_id": "7c6d7980-0310-46ab-b62c-9e84428c4401", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef453262", "status": "Online"}

TASK [Assert the resource instance is well created with good SKU] ******************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Database with good SKU] *************************************************************************
ok: [localhost] => {"changed": false, "databases": [{"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": null, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef453262", "kind": "v12.0,user", "location": "eastus", "name": "database969ef453262", "resource_group": "automated-testing", "sku": {"capacity": 10, "name": "S0", "tier": "Standard"}, "status": "Online", "tags": {"aaa": "bbb"}, "zone_redundant": false}]}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create again instance of SQL Database with same SKU] *************************************************************
ok: [localhost] => {"changed": false, "database_id": "7c6d7980-0310-46ab-b62c-9e84428c4401", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef453262", "status": "Online"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create again instance of SQL Database with New SKU] **************************************************************
changed: [localhost] => {"changed": true, "database_id": "7c6d7980-0310-46ab-b62c-9e84428c4401", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef453262", "status": "Online"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Database with good New SKU] *********************************************************************
ok: [localhost] => {"changed": false, "databases": [{"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": null, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/database969ef453262", "kind": "v12.0,user", "location": "eastus", "name": "database969ef453262", "resource_group": "automated-testing", "sku": {"capacity": 125, "name": "P1", "tier": "Premium"}, "status": "Online", "tags": {"aaa": "bbb"}, "zone_redundant": false}]}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of SQL Database] *********************************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Database] ***************************************************************************************
ok: [localhost] => {"changed": false, "databases": []}

TASK [Assert that empty dictionary was returned] ***********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Database] ***************************************************************************************
ok: [localhost] => {"changed": false, "databases": [{"collation": "SQL_Latin1_General_CP1_CI_AS", "earliest_restore_date": null, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/databases/master", "kind": "v12.0,system", "location": "eastus", "name": "master", "resource_group": "automated-testing", "sku": {"capacity": 0, "name": "System2", "tier": "System"}, "status": "Online", "tags": null, "zone_redundant": false}]}

TASK [Assert that empty dictionary was returned (one database is there by default)] ************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of Firewall Rule -- check mode] ******************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create instance of Firewall Rule] ********************************************************************************
changed: [localhost] => {"changed": true, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/firewallRules/firewallrule969ef45326"}

TASK [Assert the resource instance is well created] ********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create again instance of Firewall Rule] **************************************************************************
ok: [localhost] => {"changed": false, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/firewallRules/firewallrule969ef45326"}

TASK [Assert the state has not changed] ********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Create Firewall Rule - second] ***********************************************************************************
changed: [localhost] => {"changed": true, "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/firewallRules/firewallrule969ef45326second"}

TASK [Gather facts SQL Firewall Rule] **********************************************************************************
ok: [localhost] => {"changed": false, "rules": [{"end_ip_address": "172.28.10.138", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/firewallRules/firewallrule969ef45326", "name": "firewallrule969ef45326", "resource_group": "automated-testing", "server_name": "sqlsrv969ef45326", "start_ip_address": "172.28.10.136"}]}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Gather facts SQL Firewall Rule] **********************************************************************************
ok: [localhost] => {"changed": false, "rules": [{"end_ip_address": "172.28.10.138", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/firewallRules/firewallrule969ef45326", "name": "firewallrule969ef45326", "resource_group": "automated-testing", "server_name": "sqlsrv969ef45326", "start_ip_address": "172.28.10.136"}, {"end_ip_address": "172.28.10.138", "id": "/subscriptions/15d7b290-260a-4ea7-a138-37b3f781f644/resourceGroups/automated-testing/providers/Microsoft.Sql/servers/sqlsrv969ef45326/firewallRules/firewallrule969ef45326second", "name": "firewallrule969ef45326second", "resource_group": "automated-testing", "server_name": "sqlsrv969ef45326", "start_ip_address": "172.28.10.136"}]}

TASK [Assert that facts are returned] **********************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of Firewall Rule] ********************************************************************************
changed: [localhost] => {"changed": true}

TASK [Delete instance of Firewall Rule] ********************************************************************************
changed: [localhost] => {"changed": true}

TASK [Gather facts SQL Firewall Rule] **********************************************************************************
ok: [localhost] => {"changed": false, "rules": []}

TASK [Assert that empty dictionary was returned] ***********************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of SQL Server -- check mode] *********************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete instance of SQL Server] ***********************************************************************************
changed: [localhost] => {"changed": true}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete unexisting instance of SQL Server] ************************************************************************
ok: [localhost] => {"changed": false}

TASK [Assert the state has changed] ************************************************************************************
ok: [localhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

TASK [Delete extended instance of SQL Server] **************************************************************************
changed: [localhost] => {"changed": true}

TASK [Delete instance of SQL Server with Azure AD admin] ***************************************************************
changed: [localhost] => {"changed": true}

PLAY RECAP *************************************************************************************************************
localhost                  : ok=95   changed=26   unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Let me know if you have any other questions. Thank you!

@l3ender
Copy link
Contributor Author

l3ender commented Mar 23, 2022

@Fred-sun Were any other changes needed for this PR?

@Fred-sun
Copy link
Collaborator

Fred-sun commented Apr 1, 2022

@l3ender We can do this by adding the use case to sample in the module, not task. Thank you very much!

Error creating the SQL Server instance: (InvalidExternalAdministratorSid) Invalid or missing external administrator object id

@l3ender
Copy link
Contributor Author

l3ender commented Apr 1, 2022

Thanks @Fred-sun! I have modified the playbook so that AzureAD tasks will not run unless explicitly specified at time of run. Please take a look--thank you!

@Fred-sun Fred-sun added ready_for_review The PR has been modified and can be reviewed and merged and removed work in In trying to solve, or in working with contributors labels Apr 7, 2022
@xuzhang3 xuzhang3 merged commit 5f95abb into ansible-collections:dev Apr 21, 2022
@xuzhang3 xuzhang3 deleted the sql-enhancements branch April 21, 2022 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request medium_priority Medium priority new_feature New feature requirments ready_for_review The PR has been modified and can be reviewed and merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants