summaryrefslogtreecommitdiffstats
path: root/ansible_collections/lowlydba/sqlserver
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/lowlydba/sqlserver')
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/FUNDING.yml13
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/bug_report.md25
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/feature_request.md19
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/PULL_REQUEST_TEMPLATE.md22
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/codecov.yml14
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/dependabot.yml8
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/in-solidarity.yml8
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test-windows.yml193
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test.yml172
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/workflows/docs-pr.yml88
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/workflows/docs-push.yml35
-rw-r--r--ansible_collections/lowlydba/sqlserver/.github/workflows/release.yml79
-rw-r--r--ansible_collections/lowlydba/sqlserver/.vscode/extensions.json5
-rw-r--r--ansible_collections/lowlydba/sqlserver/.vscode/settings.json6
-rw-r--r--ansible_collections/lowlydba/sqlserver/CHANGELOG.rst473
-rw-r--r--ansible_collections/lowlydba/sqlserver/CODE_OF_CONDUCT.md3
-rw-r--r--ansible_collections/lowlydba/sqlserver/CONTRIBUTING.md3
-rw-r--r--ansible_collections/lowlydba/sqlserver/FILES.json2910
-rw-r--r--ansible_collections/lowlydba/sqlserver/LICENSE674
-rw-r--r--ansible_collections/lowlydba/sqlserver/MAINTAINERS2
-rw-r--r--ansible_collections/lowlydba/sqlserver/MANIFEST.json32
-rw-r--r--ansible_collections/lowlydba/sqlserver/README.md139
-rw-r--r--ansible_collections/lowlydba/sqlserver/changelogs/changelog.yaml407
-rw-r--r--ansible_collections/lowlydba/sqlserver/changelogs/config.yaml30
-rw-r--r--ansible_collections/lowlydba/sqlserver/changelogs/fragments/.keep0
-rw-r--r--ansible_collections/lowlydba/sqlserver/docs/.gitkeep1
-rw-r--r--ansible_collections/lowlydba/sqlserver/meta/runtime.yml2
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/attributes.py48
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/sql_credentials.py32
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/state.py24
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/module_utils/_SqlServerUtils.psm1186
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.ps186
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.py84
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.ps1193
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.py147
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.ps1133
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.py84
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.ps164
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.py48
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.ps1164
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.py142
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.ps1157
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.py118
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.ps1235
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.py157
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/backup.ps1138
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/backup.py197
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/credential.ps1117
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/credential.py91
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/database.ps1242
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/database.py94
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.ps165
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.py63
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.ps180
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.py84
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.ps171
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.py66
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.ps186
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.py104
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.ps157
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.py34
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/login.ps1144
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/login.py89
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.ps1105
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.py101
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/memory.ps150
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/memory.py46
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.ps151
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.py48
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.ps169
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.py47
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/restore.ps1170
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/restore.py230
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.ps1118
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.py90
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.ps1112
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.py100
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/sa.ps1101
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/sa.py74
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.ps159
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.py50
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.ps157
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.py53
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/spn.ps169
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/spn.py70
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.ps169
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.py70
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.ps167
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.py55
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/user.ps1142
-rw-r--r--ansible_collections/lowlydba/sqlserver/plugins/modules/user.py81
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/.ansible-lint10
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/integration_config.sample.yml4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/inventory2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/inventory.winrm.ci8
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/tasks/main.yml146
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/tasks/main.yml69
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/tasks/main.yml169
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/tasks/main.yml167
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/tasks/main.yml25
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/tasks/main.yml85
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/tasks/main.yml92
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/tasks/main.yml37
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/tasks/main.yml39
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/files/1-select-choice.sql1
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/tasks/main.yml61
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/tasks/main.yml26
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/tasks/main.yml97
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/tasks/main.yml29
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/tasks/main.yml71
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/tasks/main.yml27
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/tasks/main.yml36
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/tasks/main.yml76
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/tasks/main.yml102
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/tasks/main.yml66
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/defaults/main.yml2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/tasks/main.yml9
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/vars/main.yml12
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/README.md9
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py197
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.Basic.cs1481
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.ModuleUtils.AddType.psm1397
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/shell_plugins/pwsh.py376
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/tasks/main.yml6
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/vars/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/tasks/main.yml8
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/vars/main.yml2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/tasks/main.yml67
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/tasks/main.yml46
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/tasks/main.yml90
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/aliases2
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/tasks/main.yml115
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/tasks/main.yml90
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/tasks/main.yml81
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/tasks/main.yml109
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/tasks/main.yml53
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/files/1-select-choice.sql1
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/tasks/main.yml72
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/tasks/main.yml31
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/tasks/main.yml38
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/aliases4
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/tasks/main.yml49
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/meta/main.yml3
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/aliases5
-rw-r--r--ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/meta/main.yml3
248 files changed, 16782 insertions, 0 deletions
diff --git a/ansible_collections/lowlydba/sqlserver/.github/FUNDING.yml b/ansible_collections/lowlydba/sqlserver/.github/FUNDING.yml
new file mode 100644
index 000000000..c235de882
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/FUNDING.yml
@@ -0,0 +1,13 @@
+# These are supported funding model platforms
+
+github: lowlydba
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/bug_report.md b/ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 000000000..dd10bd42c
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,25 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: "[Bug]"
+labels: bug
+assignees: ''
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Versions(please complete the following information):**
+
+* OS: [e.g. iOS]
+* SQL Server: [e.g. 2017, 2019]
+* PowerShell:
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/feature_request.md b/ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 000000000..64d2fc21b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,19 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: "[Request]"
+labels: enhancement
+assignees: ''
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is.
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/ansible_collections/lowlydba/sqlserver/.github/PULL_REQUEST_TEMPLATE.md b/ansible_collections/lowlydba/sqlserver/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..c4f44d398
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,22 @@
+<!-- markdownlint-disable-file -->
+
+## Description
+<!--- Describe your changes in detail -->
+<!--- Why is this change required? What problem does it solve? -->
+
+## How Has This Been Tested?
+<!--- Please describe in detail how you tested your changes. -->
+
+## Types of changes
+<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
+- [ ] Bug fix (non-breaking change which fixes an issue) - Fixes #
+- [ ] New feature (non-breaking change which adds functionality)
+
+## Checklist:
+<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
+<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
+- [ ] I have read/followed the [**CONTRIBUTING**](https://github.com/LowlyDBA/lowlydba.sqlserver/blob/main/CONTRIBUTING.md) document.
+- [ ] I have read/followed the [PR Quick Start Guide](https://docs.ansible.com/ansible/devel/community/create_pr_quick_start.html)
+- [ ] I have added tests to cover my changes or they are N/A.
+- [ ] I have added a [changelog fragment](https://github.com/ansible-community/antsibull-changelog/blob/main/docs/changelogs.rst#changelog-fragment-categories) describing the changes.
+- [ ] New module options/parameters include a [`version_added` property](https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html#documentation-fields).
diff --git a/ansible_collections/lowlydba/sqlserver/.github/codecov.yml b/ansible_collections/lowlydba/sqlserver/.github/codecov.yml
new file mode 100644
index 000000000..afdb55e74
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/codecov.yml
@@ -0,0 +1,14 @@
+fixes:
+ - "/ansible_collections/lowlydba/sqlserver/::"
+
+coverage:
+ status:
+ project:
+ default:
+ # basic
+ target: auto
+ threshold: 5%
+ patch:
+ default:
+ # basic
+ target: 90%
diff --git a/ansible_collections/lowlydba/sqlserver/.github/dependabot.yml b/ansible_collections/lowlydba/sqlserver/.github/dependabot.yml
new file mode 100644
index 000000000..443cf3bec
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/dependabot.yml
@@ -0,0 +1,8 @@
+# Set update schedule for GitHub Actions
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ # Check for updates to GitHub Actions every weekday
+ interval: "daily"
diff --git a/ansible_collections/lowlydba/sqlserver/.github/in-solidarity.yml b/ansible_collections/lowlydba/sqlserver/.github/in-solidarity.yml
new file mode 100644
index 000000000..6079dc1aa
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/in-solidarity.yml
@@ -0,0 +1,8 @@
+rules:
+ master:
+ level: warning
+ignore:
+ - ".github/in-solidarity.yml" # default
+ - "**/*.yml"
+ - "tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py"
+ - "tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.ModuleUtils.AddType.psm1"
diff --git a/ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test-windows.yml b/ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test-windows.yml
new file mode 100644
index 000000000..a30426d3d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test-windows.yml
@@ -0,0 +1,193 @@
+name: CI (Windows)
+on:
+ # Manual triggers
+ workflow_dispatch:
+ # Run CI against all pushes (direct commits, also merged PRs), Pull Requests
+ push:
+ branches:
+ - main
+ - stable-*
+ paths-ignore:
+ - .github/workflows/docs*.yml
+ - .github/workflows/github-release.yml
+ - changelogs/fragments/*.yml
+ - .vscode/*
+ pull_request:
+ paths-ignore:
+ - .github/workflows/docs*.yml
+ - .github/workflows/github-release.yml
+ - changelogs/fragments/*.yml
+ - .vscode/*
+
+ # Run CI once per day (at 06:00 UTC)
+ # This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
+ schedule:
+ - cron: "0 6 * * *"
+
+# Cancel existing runs on new commits to a branch
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+env:
+ NAMESPACE: lowlydba
+ COLLECTION_NAME: sqlserver
+ DBATOOLS_VERSION: "1.1.112"
+
+jobs:
+ ###
+ # Integration tests (RECOMMENDED)
+ #
+ # https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html
+
+ integration:
+ runs-on: ${{ matrix.os }}
+ name: I (Ⓐ${{ matrix.ansible }}+${{ matrix.os }}|grp${{ matrix.group }})
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - windows-2019
+ ansible:
+ - stable-2.11
+ - stable-2.12
+ - stable-2.13
+ - stable-2.14
+ - devel
+ group: # windows/group/#/
+ - "1"
+ - "2"
+ #- '3'
+
+ defaults:
+ run:
+ shell: wsl-bash {0}
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v3
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: Create an admin user
+ shell: cmd
+ run: |
+ net user admin pass123@ /add /y
+ net localgroup Administrators admin /add
+
+ - name: Set up the runner for PowerShell remoting
+ shell: powershell
+ run: |
+ $sb = [ScriptBlock]::Create((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
+ & $sb -Verbose -ForceNewSSLCert 4>&1
+
+ - name: Enable winrm
+ shell: powershell
+ run: |
+ winrm quickconfig -force
+
+ - name: Why is MongoDB running? Disable it.
+ shell: powershell
+ run: |
+ Get-Service -Name MongoDB | Where-Object Status -eq 'Running' | Stop-Service -Force
+
+ - name: Install a SQL Server
+ continue-on-error: true
+ id: mssqlsuite
+ uses: potatoqualitee/mssqlsuite@v1.7
+ with:
+ install: sqlengine
+ sa-password: L0wlydb4
+ version: 2022
+
+ - name: Retry SQL Server install
+ id: retry1
+ if: steps.mssqlsuite.outcome == 'failure'
+ uses: potatoqualitee/mssqlsuite@v1.7
+ with:
+ install: sqlengine
+ sa-password: L0wlydb4
+ version: 2022
+
+ - name: Add a hosts entry
+ shell: cmd
+ run: echo 127.0.0.1 sqlserver >> "%WinDir%\System32\Drivers\etc\hosts"
+
+ - name: Install and cache PowerShell modules
+ uses: potatoqualitee/psmodulecache@v5.2
+ with:
+ modules-to-cache: dbatools
+ shell: powershell
+
+ - uses: Vampire/setup-wsl@v1.3.4
+ with:
+ distribution: Debian
+ additional-packages: |
+ git
+ python3
+ python3-pip
+ openssh-client
+
+ - name: Get Linux workspace path
+ shell: pwsh
+ run: |
+ # $ws = & wslpath --% -u -a "${{ github.workspace }}""
+ # seems wslpath is not available on server 2019
+
+ function ConvertTo-LinuxPathCrappy {
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ $LiteralPath
+ )
+
+ End {
+ $resolved = Resolve-Path -LiteralPath $LiteralPath
+ $drive = ($resolved | Split-Path -Qualifier).TrimEnd(':').ToLower()
+ $rooted = ($resolved | Split-Path -NoQualifier).Replace('\', '/').TrimStart('/')
+
+ '/mnt/{0}/{1}' -f $drive, $rooted
+ }
+ }
+ $ws = ConvertTo-LinuxPathCrappy -LiteralPath "${{ github.workspace }}"
+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "GHWS=$ws"
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: |
+ python3 -m pip install --upgrade pip setuptools pypsrp --disable-pip-version-check --retries 10
+ python3 -m pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check --retries 10
+
+ - name: Install collection dependencies
+ id: collection-dependency
+ run: ansible-galaxy collection install ansible.windows -p "${{ env.GHWS }}"
+ continue-on-error: true
+
+ - name: Retry install collection dependencies
+ if: steps.collection-dependency.outcome == 'failure'
+ run: ansible-galaxy collection install ansible.windows -p "${{ env.GHWS }}"
+
+ - name: Set integration test options
+ shell: bash
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration
+ run: |
+ cp integration_config.sample.yml integration_config.yml
+ cp inventory.winrm.ci inventory.winrm
+
+ # Run the integration tests
+ - name: Run integration test
+ run: |
+ pushd "${{ env.GHWS }}/ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}"
+ ansible-test windows-integration -v --color --retry-on-error --continue-on-error --diff --coverage --requirements windows/group/${{ matrix.group }}/
+
+ # ansible-test support producing code coverage data
+ - name: Generate coverage report
+ run: |
+ pushd "${{ env.GHWS }}/ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}"
+ ansible-test coverage xml -v --requirements
+
+ # See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver
+ - uses: codecov/codecov-action@v3
+ with:
+ fail_ci_if_error: false
diff --git a/ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test.yml b/ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test.yml
new file mode 100644
index 000000000..01f271845
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/workflows/ansible-test.yml
@@ -0,0 +1,172 @@
+# README FIRST
+# 1. replace "NAMESPACE" and "COLLECTION_NAME" with the correct name in the env section (e.g. with 'community' and 'mycollection')
+# 2. If you don't have unit tests remove that section
+# 3. If your collection depends on other collections ensure they are installed, see "Install collection dependencies"
+# If you need help please ask in #ansible-community on the Libera.chat IRC network
+
+name: CI
+on:
+ # Manual triggers
+ workflow_dispatch:
+ # Run CI against all pushes (direct commits, also merged PRs), Pull Requests
+ push:
+ branches:
+ - main
+ - stable-*
+ paths-ignore:
+ - .github/workflows/docs*.yml
+ - .github/workflows/github-release.yml
+ - changelogs/fragments/*.yml
+ - .vscode/*
+ pull_request:
+ paths-ignore:
+ - .github/workflows/docs*.yml
+ - .github/workflows/github-release.yml
+ - changelogs/fragments/*.yml
+ - .vscode/*
+
+ # Run CI once per day (at 06:00 UTC)
+ # This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
+ schedule:
+ - cron: "0 6 * * *"
+
+# Cancel existing runs on new commits to a branch
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+env:
+ NAMESPACE: lowlydba
+ COLLECTION_NAME: sqlserver
+
+jobs:
+ ###
+ # Sanity tests (REQUIRED)
+ #
+ # https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html
+
+ sanity:
+ name: Sanity (Ⓐ${{ matrix.ansible }})
+ strategy:
+ matrix:
+ ansible:
+ # It's important that Sanity is tested against all stable-X.Y branches
+ # Testing against `devel` may fail as new tests are added.
+ - stable-2.11
+ - stable-2.12
+ - stable-2.13
+ - stable-2.14
+ - devel
+ runs-on: ubuntu-latest
+ steps:
+ # ansible-test requires the collection to be in a directory in the form
+ # .../ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/
+
+ - name: Check out code
+ uses: actions/checkout@v3
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ # it is just required to run that once as "ansible-test sanity" in the docker image
+ # will run on all python versions it supports.
+ python-version: 3.9
+
+ # Install the head of the given branch (devel, stable-2.10)
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check --retries 10
+
+ # run ansible-test sanity inside of Docker.
+ # The docker container has all the pinned dependencies that are required
+ # and all python versions ansible supports.
+ - name: Run sanity tests
+ run: ansible-test sanity --docker -v --color --coverage
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ # ansible-test support producing code coverage date
+ - name: Generate coverage report
+ run: ansible-test coverage xml -v --requirements --group-by command --group-by version
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ # See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver
+ - uses: codecov/codecov-action@v3
+ with:
+ fail_ci_if_error: false
+
+ ###
+ # Integration tests (RECOMMENDED)
+ #
+ # https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html
+
+ # If the application you are testing is available as a docker container and you want to test
+ # multiple versions see the following for an example:
+ # https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows
+
+ integration:
+ runs-on: ubuntu-latest
+ name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
+ services:
+ sqlserver:
+ image: mcr.microsoft.com/mssql/server:2022-latest
+ ports:
+ - 1433:1433
+ env:
+ ACCEPT_EULA: "Y"
+ SA_PASSWORD: L0wlydb4
+ strategy:
+ fail-fast: false
+ matrix:
+ ansible:
+ - stable-2.11
+ - stable-2.12
+ - stable-2.13
+ - stable-2.14
+ - devel
+ python:
+ - 3.9
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v3
+ with:
+ path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ # it is just required to run that once as "ansible-test integration" in the docker image
+ # will run on all python versions it supports.
+ python-version: 3.9
+
+ - name: Install ansible-base (${{ matrix.ansible }})
+ run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check --retries 10
+
+ - name: Install collection dependencies
+ id: collection-dependency
+ run: ansible-galaxy collection install community.general -p .
+ continue-on-error: true
+
+ - name: Retry install collection dependencies
+ if: steps.collection-dependency.outcome == 'failure'
+ run: ansible-galaxy collection install community.general -p .
+
+ - name: Set integration test options
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration
+ run: cp integration_config.sample.yml integration_config.yml
+
+ # Run the integration tests
+ - name: Run integration test
+ run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --docker-network="${{ job.services.sqlserver.network }}" --coverage
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ # ansible-test support producing code coverage date
+ - name: Generate coverage report
+ run: ansible-test coverage xml -v --requirements
+ working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
+
+ # See the reports at https://codecov.io/gh/lowlydba/lowlydba.sqlserver
+ - uses: codecov/codecov-action@v3
+ with:
+ fail_ci_if_error: false
diff --git a/ansible_collections/lowlydba/sqlserver/.github/workflows/docs-pr.yml b/ansible_collections/lowlydba/sqlserver/.github/workflows/docs-pr.yml
new file mode 100644
index 000000000..7bfe7c531
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/workflows/docs-pr.yml
@@ -0,0 +1,88 @@
+name: Collection Docs
+concurrency:
+ group: docs-pr-${{ github.head_ref }}
+ cancel-in-progress: true
+on:
+ pull_request_target:
+ types: [opened, synchronize, reopened, closed]
+
+env:
+ GHP_BASE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
+
+jobs:
+ validate-docs:
+ permissions:
+ contents: read
+ name: Validate Ansible Docs
+ if: github.event.action != 'closed'
+ uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-push.yml@main
+ with:
+ artifact-upload: false
+ init-lenient: false
+ init-fail-on-error: true
+ build-ref: refs/pull/${{ github.event.number }}/merge
+
+ build-docs:
+ permissions:
+ contents: read
+ name: Build Ansible Docs
+ uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-pr.yml@main
+ with:
+ init-lenient: true
+ init-fail-on-error: false
+ render-file-line: '> * `$<status>` [$<path_tail>](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr/${{ github.event.number }}/$<path_tail>)'
+
+ publish-docs-gh-pages:
+ # for now we won't run this on forks
+ if: github.repository == 'lowlydba/lowlydba.sqlserver'
+ permissions:
+ contents: write
+ needs: [build-docs]
+ name: Publish Ansible Docs
+ uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-publish-gh-pages.yml@main
+ with:
+ artifact-name: ${{ needs.build-docs.outputs.artifact-name }}
+ action: ${{ (github.event.action == 'closed' || needs.build-docs.outputs.changed != 'true') && 'teardown' || 'publish' }}
+ secrets:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ comment:
+ permissions:
+ pull-requests: write
+ runs-on: ubuntu-latest
+ needs: [publish-docs-gh-pages, build-docs]
+ name: PR comments
+ steps:
+ - name: PR comment
+ uses: ansible-community/github-docs-build/actions/ansible-docs-build-comment@main
+ with:
+ body-includes: '## Docs Build'
+ reactions: heart
+ action: ${{ needs.build-docs.outputs.changed != 'true' && 'remove' || '' }}
+ on-closed-action: remove
+ on-merged-body: |
+ ## Docs Build 📝
+
+ Thank you for contribution!✨
+
+ This PR has been merged and the docs are now incorporated into `main`:
+ ${{ env.GHP_BASE_URL }}/branch/main
+ body: |
+ ## Docs Build 📝
+
+ Thank you for contribution!✨
+
+ The docs for **this PR** have been published here:
+ ${{ env.GHP_BASE_URL }}/pr/${{ github.event.number }}
+
+ You can compare to the docs for the `main` branch here:
+ ${{ env.GHP_BASE_URL }}/branch/main
+
+ The docsite for **this PR** is also available for download as an artifact from this run:
+ ${{ needs.build-docs.outputs.artifact-url }}
+
+ File changes:
+
+ ${{ needs.build-docs.outputs.diff-files-rendered }}
+
+ ${{ needs.build-docs.outputs.diff-rendered }}
diff --git a/ansible_collections/lowlydba/sqlserver/.github/workflows/docs-push.yml b/ansible_collections/lowlydba/sqlserver/.github/workflows/docs-push.yml
new file mode 100644
index 000000000..3a152d0c0
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/workflows/docs-push.yml
@@ -0,0 +1,35 @@
+name: Collection Docs
+concurrency:
+ group: docs-push-${{ github.sha }}
+ cancel-in-progress: true
+on:
+ push:
+ branches:
+ - main
+ tags:
+ - '*'
+ schedule:
+ - cron: '0 13 * * *'
+
+jobs:
+ build-docs:
+ permissions:
+ contents: read
+ name: Build Ansible Docs
+ uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-push.yml@main
+ with:
+ init-lenient: false
+ init-fail-on-error: true
+
+ publish-docs-gh-pages:
+ # for now we won't run this on forks
+ if: github.repository == 'lowlydba/lowlydba.sqlserver'
+ permissions:
+ contents: write
+ needs: [build-docs]
+ name: Publish Ansible Docs
+ uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-publish-gh-pages.yml@main
+ with:
+ artifact-name: ${{ needs.build-docs.outputs.artifact-name }}
+ secrets:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/ansible_collections/lowlydba/sqlserver/.github/workflows/release.yml b/ansible_collections/lowlydba/sqlserver/.github/workflows/release.yml
new file mode 100644
index 000000000..f7a3a9dec
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.github/workflows/release.yml
@@ -0,0 +1,79 @@
+name: GitHub Release
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "Version number to release"
+ required: true
+
+env:
+ GHP_BASE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
+
+jobs:
+ release:
+ name: Create GitHub Release
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: 3.8
+
+ - name: Install PyYaml
+ run: pip install pyyaml
+
+ - name: Publish to Galaxy
+ uses: artis3n/ansible_galaxy_collection@v2.8.2
+ with:
+ api_key: ${{ secrets.GALAXY_API_KEY }}
+
+ - name: Validate version is published to Galaxy
+ run: curl --head -s -f -o /dev/null https://galaxy.ansible.com/download/lowlydba-sqlserver-${{ github.event.inputs.version }}.tar.gz
+
+ - name: Build release description
+ shell: python
+ run: |
+ import os
+ import yaml
+
+ ver = '${{ github.event.inputs.version }}'
+ ver_anchor = str.replace(ver, '.', '-')
+
+ with open('changelogs/changelog.yaml', 'r') as s:
+ ri = yaml.safe_load(s)
+
+ if ('release_summary' not in ri['releases'][ver]['changes']):
+ summary = 'No release summary available.'
+ else:
+ summary = ri['releases'][ver]['changes']['release_summary']
+
+ reldate = ri['releases'][ver]['release_date']
+
+ description = '''## Summary
+ Released: %s
+
+ %s
+
+ ---
+
+ View the [complete changelog](https://github.com/lowlydba/lowlydba.sqlserver/blob/main/CHANGELOG.rst#v%s) to see all changes.
+
+ View the [full documentation for release ${{ github.event.inputs.version }}](${{ env.GHP_BASE_URL }}/tag/${{ github.event.inputs.version }}).
+ ''' % (reldate, summary, ver_anchor)
+
+ with open(os.environ['GITHUB_ENV'], 'a') as e:
+ e.write("RELEASE_DESCRIPTION<<EOF\n%s\nEOF" % description)
+
+ - name: Create Release
+ id: create_release
+ uses: softprops/action-gh-release@v0.1.15
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ token: ${{ env.GITHUB_TOKEN }}
+ tag_name: ${{ github.event.inputs.version }}
+ name: ${{ github.event.inputs.version }}
+ body: ${{ env.RELEASE_DESCRIPTION }}
diff --git a/ansible_collections/lowlydba/sqlserver/.vscode/extensions.json b/ansible_collections/lowlydba/sqlserver/.vscode/extensions.json
new file mode 100644
index 000000000..1450d869d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.vscode/extensions.json
@@ -0,0 +1,5 @@
+{
+ "recommendations": [
+ "redhat.ansible"
+ ]
+}
diff --git a/ansible_collections/lowlydba/sqlserver/.vscode/settings.json b/ansible_collections/lowlydba/sqlserver/.vscode/settings.json
new file mode 100644
index 000000000..46e899024
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/.vscode/settings.json
@@ -0,0 +1,6 @@
+{
+ "files.eol": "\n",
+ "files.insertFinalNewline": true,
+ "files.trimFinalNewlines": true,
+ "files.trimTrailingWhitespace": true
+}
diff --git a/ansible_collections/lowlydba/sqlserver/CHANGELOG.rst b/ansible_collections/lowlydba/sqlserver/CHANGELOG.rst
new file mode 100644
index 000000000..0414e8b66
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/CHANGELOG.rst
@@ -0,0 +1,473 @@
+================================
+lowlydba.sqlserver Release Notes
+================================
+
+.. contents:: Topics
+
+
+v1.3.1
+======
+
+Release Summary
+---------------
+
+Small bugfixes and documentation enhancements.
+
+Minor Changes
+-------------
+
+- Update login module documentation to indicate result will always be changed when a password is supplied. (https://github.com/lowlydba/lowlydba.sqlserver/pull/167)
+
+Bugfixes
+--------
+
+- Fixes to incorrect variable reference in Login module (https://github.com/lowlydba/lowlydba.sqlserver/pull/161)
+
+v1.3.0
+======
+
+Release Summary
+---------------
+
+New module to manage credentials added!
+
+Minor Changes
+-------------
+
+- Adding a new credential module
+
+New Modules
+-----------
+
+- credential - Configures a credential on a SQL server
+
+v1.2.1
+======
+
+Release Summary
+---------------
+
+More Azure SQL Managed Instance compatibility fixes.
+
+Bugfixes
+--------
+
+- Added missing mapping for UseDestinationDefaultDirectories (https://github.com/lowlydba/lowlydba.sqlserver/pull/153)
+- Removed default value for KeepCDC to fix compatability with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/153)
+- Removed default value for UseDestinationDefaultDirectories to fix compatability with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/153)
+
+v1.2.0
+======
+
+Release Summary
+---------------
+
+Azure SQL MI compatibility fixes & indicating required restarts for settings changes.
+
+Minor Changes
+-------------
+
+- Fixed typo in the traceflag module's documentation. (https://github.com/lowlydba/lowlydba.sqlserver/pull/150)
+- Return "RestartRequired" when a module performs changes that require an addition service restart to take effect. (https://github.com/lowlydba/lowlydba.sqlserver/pull/150/)
+
+Bugfixes
+--------
+
+- Removed default value for ReplaceDbNameInFile to fix compatability with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/148)
+
+v1.1.3
+======
+
+Release Summary
+---------------
+
+Another minor fix to increase SQL Managed Instance support.
+
+Bugfixes
+--------
+
+- Removed default value for reuse_source_folder_structure to fix compatability with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/145)
+
+v1.1.2
+======
+
+Release Summary
+---------------
+
+Bug fix for Azure Database Managed Instance compatibility.
+
+Bugfixes
+--------
+
+- Removed the default value for xp_dirtree to allow compatibility with Azure SQL Mangaed instances (https://github.com/lowlydba/lowlydba.sqlserver/pull/141)
+
+v1.1.1
+======
+
+Minor Changes
+-------------
+
+- modules - all modules now document their platform and support for check mode in their attributes documentation (https://github.com/lowlydba/lowlydba.sqlserver/pull/134).
+
+v1.1.0
+======
+
+Release Summary
+---------------
+
+Adding a new user module.
+
+New Modules
+-----------
+
+- user - Configures a user within a database
+
+v1.0.4
+======
+
+Release Summary
+---------------
+
+Minor fixes to resolve new dlevel sanity checks.
+
+Bugfixes
+--------
+
+- Fix cleanup_time default to match documentation default & lint fixes (https://github.com/lowlydba/lowlydba.sqlserver/pull/127).
+
+v1.0.3
+======
+
+Release Summary
+---------------
+
+Minor documentation fixes from the second Ansible inclusion review.
+
+Bugfixes
+--------
+
+- Minor documentation fixes (https://github.com/lowlydba/lowlydba.sqlserver/pull/122).
+
+v1.0.2
+======
+
+Release Summary
+---------------
+
+Minor documentation bugfixes and enhancements as requested in the Ansible inclusion process.
+
+Bugfixes
+--------
+
+- _SqlServerUtils module_util - added explicit license to private module util (https://github.com/lowlydba/lowlydba.sqlserver/pull/119).
+- meta/runtime.yml - updated out of date runtime version info (https://github.com/lowlydba/lowlydba.sqlserver/pull/119).
+- most modules - fixed alignment, formatting, and typos in module documentation (https://github.com/lowlydba/lowlydba.sqlserver/pull/119).
+
+v1.0.1
+======
+
+Release Summary
+---------------
+
+Minor bug fix.
+
+Bugfixes
+--------
+
+- Fixed bug in how the classifier function name is being assigned to the variable in the resource_governor module.
+
+v1.0.0
+======
+
+Release Summary
+---------------
+
+Bumping to version 1.0.0 now that this collection is being used in production in at least one place 🎉
+
+v0.11.2
+=======
+
+Release Summary
+---------------
+
+Bumping required dbatools version to ensure the `restore` module works on MacOS PowerShell Core (https://github.com/dataplat/dbatools/pull/8435).
+
+v0.11.1
+=======
+
+Release Summary
+---------------
+
+Bug fixes for AlwaysOn related modules and fixing errors in some documentation examples.
+
+Bugfixes
+--------
+
+- Fix `availability_group` module so that NUL backups can be properly taken if needed.
+- Fix incorrect examples in `availability_group` module documentation.
+- Fix incorrect examples in `install_script` module documentation.
+- Fix incorrect examples in `spn` module documentationb.
+- Fixed bugs where adding replica did not work properly for several reasons.
+
+v0.11.0
+=======
+
+Release Summary
+---------------
+
+Adding new dbops module.
+
+New Modules
+-----------
+
+- install_script - Runs migration scripts against a database.
+
+v0.10.1
+=======
+
+Release Summary
+---------------
+
+Bug fix for resource_governor.
+
+Bugfixes
+--------
+
+- Fix change detection in resource_governor module.
+
+v0.10.0
+=======
+
+Release Summary
+---------------
+
+The first_responder_kit and tcp_port modules, along with a bump in the required dbatools version.
+
+Minor Changes
+-------------
+
+- Update minimum required DBATools version universally to 1.1.108 to accommodate new tcp module.
+
+New Modules
+-----------
+
+- first_responder_kit - Install/update the First Responder Kit scripts.
+- tcp_port - Sets the TCP port for the instance.
+
+v0.9.3
+======
+
+Release Summary
+---------------
+
+More change detection fixing.
+
+Bugfixes
+--------
+
+- memory - Fix improper changed detection.
+
+v0.9.2
+======
+
+Release Summary
+---------------
+
+Bugfixes for agent related modules that incorrectly reported change statuses.
+
+Bugfixes
+--------
+
+- agent_job - Fix incorrectly reported change status when no change occurred.
+- agent_job_schedule - Fix incorrectly reported change status when no change occurred.
+- agent_job_step - Fix incorrectly reported change status when no change occurred.
+
+v0.9.1
+======
+
+Release Summary
+---------------
+
+Bugfix!
+
+Bugfixes
+--------
+
+- Allow agent job steps to be removed by specifying the step ID only. This is likely needed in cleanup of steps from previous job configurations.
+
+v0.9.0
+======
+
+Bugfixes
+--------
+
+- backup - Only use blocksize when specified.
+
+New Modules
+-----------
+
+- restore - Performs a restore operation.
+
+v0.8.0
+======
+
+Release Summary
+---------------
+
+A few small fixes and the new 'backup' module.
+
+Minor Changes
+-------------
+
+- Standardize use of 'database' vs 'database_name' in all documentation and options specs. Not a breaking change.
+
+Bugfixes
+--------
+
+- Fix inability to enable an agent job schedule after it has been disabled.
+
+New Modules
+-----------
+
+- backup - Performs a backup operation.
+
+v0.7.0
+======
+
+Release Summary
+---------------
+
+Add module for DBA Multitool.
+
+New Modules
+-----------
+
+- dba_multitool - Install/update the DBA Multitool suite by John McCAll
+
+v0.6.0
+======
+
+Release Summary
+---------------
+
+Adding new SPN module
+
+New Modules
+-----------
+
+- spn - Configures SPNs for SQL Server.
+
+v0.5.0
+======
+
+Release Summary
+---------------
+
+CI and testing improvements, along with the final availability group module ag_replica.
+
+Minor Changes
+-------------
+
+- Remove CI support for Ansible 2.10
+
+New Modules
+-----------
+
+- ag_listener - Configures an availability group listener.
+- ag_replica - Configures an availability group replica.
+
+v0.4.0
+======
+
+Release Summary
+---------------
+
+Two new AlwaysOn modules and a few consistency fixes!
+
+Minor Changes
+-------------
+
+- Test for 'Name' property for sa module after dbatools release 1.1.95 standardizes command outputs. (https://github.com/dataplat/dbatools/releases/tag/v1.1.95)
+
+Breaking Changes / Porting Guide
+--------------------------------
+
+- All modules should use a bool 'enabled' instead of a string 'status' to control object state.
+
+New Modules
+-----------
+
+- availability_group - Configures availability group(s).
+- hadr - Enable or disable HADR.
+
+v0.3.0
+======
+
+Release Summary
+---------------
+
+New sa module and fixes for login related modules.
+
+Minor Changes
+-------------
+
+- Fix logic to properly pass password policy options to function in the login module.
+
+New Modules
+-----------
+
+- sa - Configure the 'sa' login for security best practices.
+
+v0.2.0
+======
+
+Release Summary
+---------------
+
+Code cleanup, testing improvements, new _info module!
+
+Minor Changes
+-------------
+
+- Add DbaTools module requirement to documentation and fix missing examples. (https://github.com/lowlydba/lowlydba.sqlserver/pull/47)
+- Utilize PowerShell Requires for dbatools min version needs instead of custom function. Consolidate/standardize credential setup and serialization. (https://github.com/lowlydba/lowlydba.sqlserver/pull/48)
+
+New Modules
+-----------
+
+- instance_info - Returns basic information for a SQL Server instance.
+
+v0.1.1
+======
+
+Release Summary
+---------------
+
+Add database tag for Galaxy
+
+v0.1.0
+======
+
+Release Summary
+---------------
+
+It's a release! First version to publish to Ansible Galaxy.
+
+New Modules
+-----------
+
+- agent_job - Configures a SQL Agent job.
+- agent_job_category - Configures a SQL Agent job category.
+- agent_job_schedule - Configures a SQL Agent job schedule.
+- agent_job_step - Configures a SQL Agent job step.
+- database - Creates and configures a database.
+- login - Configures a login for the target SQL Server instance.
+- maintenance_solution - Install/update Maintenance Solution
+- memory - Sets the maximum memory for a SQL Server instance.
+- nonquery - Executes a generic nonquery.
+- resource_governor - Configures the resource governor on a SQL Server instance.
+- rg_resource_pool - Configures a resource pool for use by the Resource Governor.
+- rg_workload_group - Configures a workload group for use by the Resource Governor.
+- sp_configure - Make instance level system configuration changes via sp_configure.
+- sp_whoisactive - Install/update sp_whoisactive by Adam Mechanic.
+- traceflag - Enable or disable global trace flags on a SQL Server instance.
diff --git a/ansible_collections/lowlydba/sqlserver/CODE_OF_CONDUCT.md b/ansible_collections/lowlydba/sqlserver/CODE_OF_CONDUCT.md
new file mode 100644
index 000000000..0164155b8
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/CODE_OF_CONDUCT.md
@@ -0,0 +1,3 @@
+# Community Code of Conduct
+
+Please see the official [Ansible Community Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
diff --git a/ansible_collections/lowlydba/sqlserver/CONTRIBUTING.md b/ansible_collections/lowlydba/sqlserver/CONTRIBUTING.md
new file mode 100644
index 000000000..b4a17dec0
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/CONTRIBUTING.md
@@ -0,0 +1,3 @@
+# Contributing
+
+Refer to the [Contributing guidelines](https://github.com/ansible/community-docs/blob/main/contributing.rst).
diff --git a/ansible_collections/lowlydba/sqlserver/FILES.json b/ansible_collections/lowlydba/sqlserver/FILES.json
new file mode 100644
index 000000000..3e5785a29
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/FILES.json
@@ -0,0 +1,2910 @@
+{
+ "files": [
+ {
+ "name": ".",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "CODE_OF_CONDUCT.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "14ec928234a7ed52bf8b458d31e4862335111e477e4dbe7fb543686c24115140",
+ "format": 1
+ },
+ {
+ "name": "README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1e5e70b4cf447560cafa47c84e33845abc035f87b349cfebf2395b25c6326094",
+ "format": 1
+ },
+ {
+ "name": ".github",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".github/in-solidarity.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "43f54d1f6c1496d0a02ce3144f73d479f2e37ea3d2bb9e54ba08763ddfd230a2",
+ "format": 1
+ },
+ {
+ "name": ".github/codecov.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a42ee6fd570c21e6f7828ebb71585d819fd3fa126b3d98c39ea79565ce1a0ed6",
+ "format": 1
+ },
+ {
+ "name": ".github/FUNDING.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1a09efd96d758af083de6b9468b6508672806abb882fd9fc16a1a23a67ab3acc",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/release.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3f7766b4e0f1b09cf939d122647613880bf11bb9ee73181e3303069aab2f312d",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/ansible-test-windows.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "027a1dc37e1aed9bbd57e58dc8248504cde6770b1b37fe6e2930e5a1c1d0ba79",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/docs-push.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "9529da03eea03a258ab7ec8613310e62ad06fdbadd293d575070797d716443e9",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/docs-pr.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "84a88873a148150b9b42877fa1c42697c05f631e39e618160bd99bf0f3652abd",
+ "format": 1
+ },
+ {
+ "name": ".github/workflows/ansible-test.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "34e2829089c5883da3e53d7de97ae1b9d50ed573bf27c7d3f42dc232240cb68e",
+ "format": 1
+ },
+ {
+ "name": ".github/ISSUE_TEMPLATE",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".github/ISSUE_TEMPLATE/bug_report.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8d3db528d29f10782cc5b08a68999c7144efbeaa6724817d6c72a69f4c745a31",
+ "format": 1
+ },
+ {
+ "name": ".github/ISSUE_TEMPLATE/feature_request.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "cd5b39aee355194f532b686c62a783c0657d8f7810586a757775769b291461a2",
+ "format": 1
+ },
+ {
+ "name": ".github/dependabot.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a35bab1dd3e838ca5730aae35e4b127a052f8e03d5ed5437549e95f8424e621c",
+ "format": 1
+ },
+ {
+ "name": ".github/PULL_REQUEST_TEMPLATE.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4ea1170a9065ecc1b0effb0e52f06fe42ef9936e86dfddb21c43efdd1c929b7b",
+ "format": 1
+ },
+ {
+ "name": "plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/modules",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/credential.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "16a49e24a042e89e609a22adc1316559025f60bf24fb456c0acda09e611b6ec5",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/hadr.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b2017667c8e572a1582cb076b3d543f4d7eba1ed6d66a7c0249d48b4f793868a",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/database.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "db141212c91271253c7a5438712450894bf47420e50d1e4b916a6d92a6f17e2f",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job_step.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "56da01e0ba38203752b396a705ef7b385109c803de9787456ab9446353ef88db",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/maintenance_solution.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8d1065f37fb4535a0357063b29d0fb65ce71c3dbd953afde1715d9763c8d636d",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/sa.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7ef173d3b99d5ff729f300b637a67adb882be4f7ce7b3d102ea65e64bfb11f4e",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/database.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f91b64cc108c1b7b9926a80fb3d5e689493374b77bfd2228dd06beecbfaa2d0a",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/restore.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c7c556408d4a1778418b6e6b9497939f2760945ddbd8a5744e7f51bb7501fe1f",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/instance_info.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2c1f528f928cb542f56ba5e9f2126288ecff3447ab7cb5ee50bc8cf0db7db000",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/rg_workload_group.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "90cae13aa924431ceddce76eb94f49576b4e8396227a141a2d81c9fbf5f9dd34",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/nonquery.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "28566664f6a3f97f72301bc34fa22af1421ead1ca572d651f241e960acc2be29",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/spn.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c349deb205aeb61078930059b3e8070878cda41fb6a40f866482aebfaaa358a3",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/resource_governor.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a746d1d510e43d66429bc9c1654a6eb1d9c4e431ad451f182e649ed65fe6f36e",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/ag_listener.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c91b831040e354aff0581367dcd1778b898ca424a92abf35786e9835e96c1018",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/tcp_port.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "fcb5a1326cf73886733d6772f7623bd7e792563155c8d72a0d59312998215d91",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/rg_workload_group.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "62b1fd265aecaa6522bd5aaa6d008a33e98d102ee8fba6419043c4374e139b45",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/user.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "33898d0fe3dcf8e85edb9d8dd2fc144a4ebc4ea74b8b54879be48926396bc6f8",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/traceflag.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "aa278d5f9bce404c957a7ff22d18de6f7be083f5f8c32b01c728fa792e6d21f3",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job_schedule.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6d16d9e00eabe5bcc8891e312517df43faa12dc235f9f0c025ae763742a4f371",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job_schedule.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4d8d54b56b4791914d18e982a72bb09231ba85ec59fb7b2772154c6f34dd0762",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/restore.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0f357dea6f735aae072bfee1d35335140a2a4cf3ac617ee68347cde8f7991bad",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/availability_group.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8b3b47b92e9a558181210ab01de6d6637d3b39d61d647630926ac424a08303ef",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/rg_resource_pool.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a18afaa50ed7d7183a0a9458b8b4a62130d92670f5d68197c8272c498eef876e",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/backup.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e7cdc4254a27de68509a53758db8603bb86fe9495f119c3eea3d8431a74b1f33",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/sp_whoisactive.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "26025dd39dc4bea36f72bcb0dd4a279245adde8e6be4792cc40ef90d02ade8e7",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/first_responder_kit.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "bf16bc535cfa590e884e99e3c406c602aca4c1322b9a9c86679d1980f18e5e1a",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/install_script.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e4c06e4e8a0d59008b39a64f468bcc9daa39db69c38b906826b8ae68239ef9c1",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/login.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "094d8b444a09f7b5ae0d43f4ab60f1b5ab726f34a872a8353865e99297807103",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/sa.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e5344b122f26723049886b935d7ec19054845b6fbbdef75225138f318e02844a",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/traceflag.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d08e57033e0da3f63f1c024446f02abdff41400dd0607a400f234468e05260ff",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/memory.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1c3e840a66bb01f5b809b7c9347594cfed73286cb589ca710eb3802f990fe9c8",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/dba_multitool.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b5d35e4d415e3c5f097bafa3e89fafc330800278421bb80b78a28ff0be31fe8d",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/tcp_port.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "819aa2ed914e8989245c83f4af6e6794671e6bede649d71a1d1b68eb67dd57b3",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/memory.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "32ef5d4c7b5195fe126c307bd3fde03dc55b0e09e02bd58db6578c06137dc07f",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/maintenance_solution.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "126a8b7ea648ab2bc6e36db65a9b5ca85ca1c2224ad21445c176ea700b5a00ad",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/backup.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ddffc896a151a1c0a9d1798d1f7796d49aae2886f5aeb9c07ca72378d257a298",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job_category.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "eda9101228bdf9db6dfce794c3d7cb51b2913f43cbfd6d2045179a74dad4f52e",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/instance_info.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c6d60a465bcc5ab23e0ab7688479f2c54ca80c4d15f9a7a6adc0211f8aabd4fd",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/resource_governor.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "27d1f38306c23bfea82dc745425cf6cef0099156054bee4a497d0687866ade97",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/sp_configure.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6b1274247552e09c32acc4442f542a66a5805c90c472ded207da0cd8922e7482",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/first_responder_kit.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e4c552d6cb6dc6da95881c82267085c3cc9bd54b76cd5022bc3b0bcd1c370e8d",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job_step.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7804759c5225d445865cf4a915de70588026ca64a336bd364e1f2b41a6d317cc",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/sp_configure.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2715043d68e455a59bd7ff7028c769c23d662ae04b937128aec461a39c544bf5",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/ag_listener.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b05053dcf1f266a21de546507eeb02bf780854de655bfed76eeaa2240dc2b803",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/hadr.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "be5c12d9c83d950c86a0a2e0b0dca9d4d99a4f4540039b84e64a0bc70d7393a3",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job_category.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "815dc61c98e04d7ff02bff2fd528d02512432323d8cd9c14394a6228e83a3cad",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/dba_multitool.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0236dc7ccb91ecf1e0fdb832a40a8f82ed90ad888d7e02f41b7a2848ddc48bef",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/spn.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "57a8e8f95263b83394aaf4342759ffccbfa20315cf8d208aecee5b54f46d7a72",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/install_script.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1298f7713c30765a05794c4dd8f533084869dd0752199994d6ce885d65b0599b",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/ag_replica.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e8b318c3531976bb59a78d7bff1581a827195458090ddd8777c6de87753392ef",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/rg_resource_pool.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "27b665f6956f9c403232ac75baf94ef429b9ac12c76f89b2160f6faf153ec941",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/user.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "99b2b1074ac11298c64b987414934b55e1e95a482bcc3185285662482dbf55b7",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/nonquery.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "63fbe59992098ce75e62d692b9b4d7cc00b6e2d564496f402f496e51118d28f3",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/ag_replica.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3d7f122d89145949eaeabf78c2e4747ba9158611d9dd28efe19a6c23b61a18cf",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/sp_whoisactive.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5e75ed0cd32bab885f0969ebc9d523a43ee24d2796a956e6a87bbf4a415ae911",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "62efb5344bf2ff3d8201b87dc82ba9b42adb91657d8f44c03736229bf8f52313",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/availability_group.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a4f09ebba1bcbbecbfee5455ab196aa334020ab9bea0ff8a69d38851a774eddf",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/credential.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "19f45fc1ab63a730813bb70e29643ba18f8b43c070a1d15be6aa8867e38d7d26",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/agent_job.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "9476d4b38459e10be25b64c96bf7b2b9bb4f49045d15cd36f959737eec194d34",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/login.ps1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "68c4da04ac19c9b00bd100271b98184df756eb01208f91d5e605c0657ad91760",
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments/sql_credentials.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8319c0f26d235fb9dd33444fe7cfe963324207e64f77423098fb0a6c071be791",
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments/state.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ae0b5a340638525f1d65822b592ccba03c72dd937e8f1f60f41539f80a1af2f7",
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments/attributes.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "cdffff9cfa27f07533b806e63d11b9a752144eb5f2d7d8c8837e7a4efa4da4c7",
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/module_utils/_SqlServerUtils.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4fdfc528ea4a54118f616738c9630066e47e0d010c2b60cbecd851a5b5547c3f",
+ "format": 1
+ },
+ {
+ "name": "docs",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "docs/.gitkeep",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
+ "format": 1
+ },
+ {
+ "name": "changelogs",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "changelogs/config.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1e054fb68c58140c282fbaf0150eee1bf80ad925196dddd74e848e91b7315a1e",
+ "format": 1
+ },
+ {
+ "name": "changelogs/changelog.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "84869c094d776ac71026856552afea3b0b5e31450222ecf2cf743081e019eeea",
+ "format": 1
+ },
+ {
+ "name": "changelogs/fragments",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "changelogs/fragments/.keep",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "format": 1
+ },
+ {
+ "name": "MAINTAINERS",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "29b1b04e645e0c11e59c48cfe7bac3dbe16f787a9d6114847d9a5c3b5990e731",
+ "format": 1
+ },
+ {
+ "name": "CONTRIBUTING.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "eec219dbc09446ed3e9938c8f66378621a0548b056426df33e3ea32e26bb4dc8",
+ "format": 1
+ },
+ {
+ "name": "meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "meta/runtime.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5be7885f2e0f072d87dedbab542a787597a3cd3cabab2826d902233af114edce",
+ "format": 1
+ },
+ {
+ "name": "LICENSE",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986",
+ "format": 1
+ },
+ {
+ "name": "tests",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/integration_config.sample.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "25e1d1343d93da99f01452b27af5f1b290b938b228ff934b0e84e6acd36916ec",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/.ansible-lint",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "982c0b7fe8683e818a27cf59b6a6892d91c277703c81e2db35994f63ef90e7fc",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_category",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_category/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b4a1e70429ec84b35ba19e1696b30a39c4baeed6712c12ad93fd7ff62c42649a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_category/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_category/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "637bd5e4ab78efba6ef44acb927e9d2188743d9d62d8ef4577ba8ca596dbd7f6",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "105c5f0785da8d117d54b796fedefa4ddbd7ec65b52058539abe49f327d06db8",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "339b0338ba60e7a9f16ef083d385fd1df922c058bc10e044eda5f7f436a61ff5",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0717e3c911ac3a45ebb713a535b723d4ebc229a24910a45349c2e8f9ce88cae8",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/vars",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_win_sqlserver/vars/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f773fabf54dffb1da94c9a66e897675dd8831d87d1ff525edeaa581ac0963c7e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/traceflag",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/traceflag/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/traceflag/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/traceflag/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "50cc511e187bab0f47387422459e654018bb6d5b8c408c49fe074cc92466560d",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/traceflag/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/traceflag/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_configure",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_configure/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_configure/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_configure/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c17643d6398d807c079ed122d9afc3f7d121e4720ac460693e3a6dc1bf9eb355",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_configure/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_configure/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_whoisactive",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_whoisactive/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_whoisactive/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_whoisactive/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6ea486055f1c09c041e9b353582799bb37ed536cb8e7e6bf89920a1d79cc361f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_whoisactive/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sp_whoisactive/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_spn",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_spn/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b522894638086953bde369a5f6c194a90c32338fefab24021b399659246ee20b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_spn/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_spn/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "25fe644417d284f14218215aed1e5e3ae8f920c32cdba3b349e8574f10c41f7c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_spn/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_spn/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_workload_group",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_workload_group/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "30128d716d50ee4404c8f9a1e5f921f3a830a18171470a5de586eac0799cfe5c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_workload_group/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_workload_group/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ace519beeabaa6fff00bf4230f11205f2eb88ef957a29ff4991e717ab3cd8ed2",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_workload_group",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_workload_group/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_workload_group/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_workload_group/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "20da00d72375b1ce6f9644d75d1c7d8066bd92e88c919abfd0e6813363a19b92",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_workload_group/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_workload_group/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_first_responder_kit",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_first_responder_kit/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "eb9346a60cae33ea572746b34b03e115c6d4f06b6c1f39bf1fa4eb12ee42e6bb",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_first_responder_kit/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_first_responder_kit/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "880bb341d99af44927b4791c9df077901daca5219411d812b36303e6b7c6d95c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_credential",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_credential/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "db8628e2c4d331f6b0a0263ae6c01220b719d3aa44e806849ba93acff90b3e53",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_credential/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_credential/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c4531eb647b3263f0f9611fea8ff1c0b2ce30c06437ffe41963e146f94a023a4",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_resource_pool",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_resource_pool/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f514a090cace343c41b298fa180e6a993fc535cf9fd0498424e1db2f097261a4",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_resource_pool/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_rg_resource_pool/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "cfce66e3f2dc81d8b04d033c770f490560112a14e8de1c28c7b93e93757dfda8",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_restore",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_restore/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b522894638086953bde369a5f6c194a90c32338fefab24021b399659246ee20b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_restore/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_restore/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "25cec2155a81c7e38f39a8124b49ae2daf98d279ca19a1d2fe4e2dc16d406c9c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_restore/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_restore/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/user",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/user/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/user/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/user/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "772de87469867e5ba4167ca395dd6a50004daeddff4cf8a6ca345cf97ca12077",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/user/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/user/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_dba_multitool",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_dba_multitool/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "65187564e8be2b9da7c1a7bc5e86687aa032caca1a4b8517e9cfe2b50ebc1965",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_dba_multitool/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_dba_multitool/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f119d90651290bfdbd959b50880d02d480f375e19cb06989384d3b018e3b95dc",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_nonquery",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_nonquery/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "eb1fa7982c88abde5d789d5b541bc8016f99025f732bef1cca7ba4ca457b6f7b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_nonquery/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_nonquery/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0dae571f5e423080bf9bdaac127360812ea64380e435c29f03142c56aadb4484",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/files",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/files/1-select-choice.sql",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "fde2acd9de812005948b5935c0c335889828e14ee58dbcc58a205096cdb2266f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "823c89dbff7ce470f0ab6e7e3c41e7fa02b7b38fd4a1d5bcda2ecbcb98a4dbd7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f6dc29e973e9e7c8c7396cda456a513614d795455331165968588cbfc622726e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_install_script/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_resource_pool",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_resource_pool/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_resource_pool/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_resource_pool/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "669c18b75e00a7e66b58ecbb24511bc42825b97529a6e3ad085ef35ff944ffaa",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_resource_pool/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/rg_resource_pool/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b36f45734e2fa1f527c185e1e9bfff3695f8b0fdbed70713ecbd72aaedd5b2fd",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver/vars",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver/vars/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "25da9d954dd20e30473963a6a1eeb48664272bfa186c934ffc5bd9121dc0858f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver/defaults",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver/defaults/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "454653b07873ad71128411eba4df7f2b86352fd4b884e667e045cab2b83ff4aa",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_login",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_login/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "71529f18c9a617354c7ae2d0942307ee460e46dcf304073e6b83f0d9e5e3261a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_login/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_login/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "18dbd3b87064b3336556de28cdb4a48564c66a2ae9123c90cce8bdb1860e97d9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_configure",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_configure/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f9f102cc9b61991c72e62216c363357b58ba6ef812f7838b194d76b9a37ee6dd",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_configure/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_configure/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4c58bedc5bf4354f6a8e46bd6e292a388f347a5babcc36a61cebd68081a3d1c7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_whoisactive",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_whoisactive/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0e25bc398118036b0ab0185bdf43aeb2f586af8d25ba057222e7794aab2cf3b2",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_whoisactive/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sp_whoisactive/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6d70bd8678381b8aab8b6ce600856a34b6c6f3307744f0340bc8ebaa3f846fb4",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/nonquery",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/nonquery/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/nonquery/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/nonquery/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "851bf7899fb14d2c976f6d2b1df869b108ab5f4440e2c57af920e06f7c59f07f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/nonquery/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/nonquery/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/resource_governor",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/resource_governor/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/resource_governor/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/resource_governor/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b0e5d378ac5c85985d61002fb7ac7f22f8f37326bb10d5fd09c3553beea37731",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/resource_governor/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/resource_governor/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/memory",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/memory/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/memory/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/memory/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "571c3ec667aa8c42235cf6a6d91e9ce5bcc8785653474f6a1d7bdd6166256705",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/memory/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/memory/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sa",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sa/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3e5a273fb8fb0ecaa330c5beed437ab0d77fc765042c1baa4b97034f3d63de58",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sa/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_sa/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f8a1f159fe12e4baf75982b00a0fff57296bd8b19e469913458531f0af2307d1",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "80886616ffe77f72ad8654dd26e3c88268215eceda9fd2fcee6eb98288aadae1",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "92d7d87955e27c2d9511ab6e1d62ecf60b9d0ed81895b1a5692c3cc620a29780",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_user",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_user/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4d4819a1314f1ea6a500be90e727a92fb9b964511644c7162c869e351037c2f2",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_user/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_user/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "805393b91b743ad8f62db1f7301c2c9c85cd78b64633986e456aa3add70d5419",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/files",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/files/1-select-choice.sql",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "fde2acd9de812005948b5935c0c335889828e14ee58dbcc58a205096cdb2266f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "85e9885a3bb1a9621c0ac183c3c831efe453bbb5eddbb4d6351a620164b33672",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/install_script/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_traceflag",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_traceflag/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b60d4d845847bbd2c2a976e26c6d39e4943a1466503642ee370b84b634b07ed5",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_traceflag/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_traceflag/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7ff30f930e0f6004866fed58759768dfdda5f2354cea27c69d3a9636e7dcef02",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "31c7e5478ab71d9b16cad90042519bd6cef26068f73dab84bf1b12fe6c6b1dcf",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/shell_plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/shell_plugins/pwsh.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5ca3b46418c90e0d21b48a05afd0aeab5a62bc3b49311dd709d3468c34524829",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6ee78c7c3661d0afd27fd340bbad2f302cf790e96b56911fd5b67761eab941f7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6e549bfeb53c72c6fc09b96c9d405f6b74d217080be03874c0ea6331af4b7e79",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/vars",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/vars/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "dae30dbe118009b07fecf11b4b0eb721706ce833d2f4ea1999bec0db5965de1e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0156f30e8a101162732454cb62f5a072d412ab650cdb74b52724816ee466dddb",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/module_utils",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.ModuleUtils.AddType.psm1",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f87af398727a2cf732f475c988271054b15446abc32b0c615d7a26480b9e6f40",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.Basic.cs",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8505c6c00f88db32518401563e3fd3d1b414cbe4ac1a79959d8e3773765d836a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_hadr",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_hadr/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "823c89dbff7ce470f0ab6e7e3c41e7fa02b7b38fd4a1d5bcda2ecbcb98a4dbd7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_hadr/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_hadr/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e5341d244291343a5efba167280a123556be0ce4480c8cab2282fc3e2c288609",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_hadr/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_hadr/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/first_responder_kit",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/first_responder_kit/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/first_responder_kit/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/first_responder_kit/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f5ff819f29604f94044eecbb7448dfe33b47718cff9cd972a3e149bb81516aad",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/first_responder_kit/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/first_responder_kit/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_step",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_step/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "47352893485e47a64c32139b049f01c0aa68e79591c0595922e0acffa2665523",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_step/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_step/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "bd6596491fb29701a783f70e0cc7e04bcb54c3af0306ff39166d7ffd01e57143",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_schedule",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_schedule/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a5361cb2dc2de454e750c31de04aed891a17b82ae1d09ed36de2ce628e4f3542",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_schedule/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_agent_job_schedule/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "471a1229e4fd010cbc5f53e8f58a3816415bb9f7f3ff1b6a50d697c54ea52eeb",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_backup",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_backup/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f4894d7d372026d355a62fe57e4c54da2b6588eb2df68b2bcfb3d6620525da09",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_backup/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_backup/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "9e6816dbbf21d3dba22fc22b8da0f0cc4cef6ac1dd82aefaab45a38c0fe3ecee",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sa",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sa/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sa/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sa/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4ab5c5e605be645cc3e9b27e4c767366504d3191f99d9bb8aac1be6faea59e81",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sa/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/sa/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_maintenance_solution",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_maintenance_solution/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7d262d00ae91b2b827898ae863725e5579f68d3390fb255cc591560b4f616367",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_maintenance_solution/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_maintenance_solution/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "51ae5e4c8a06b47364e63ec20fc30138f7d30ef5c0fda58701a248cdaad0481c",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_listener",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_listener/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "823c89dbff7ce470f0ab6e7e3c41e7fa02b7b38fd4a1d5bcda2ecbcb98a4dbd7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_listener/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_listener/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "23fed7e50228fa01b7b19994f71440ad28b0684f89fd08f7906062fe77602421",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_listener/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_listener/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_availability_group",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_availability_group/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b522894638086953bde369a5f6c194a90c32338fefab24021b399659246ee20b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_availability_group/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_availability_group/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8f66aa5fd04f4ae573bafb0e037877232be65d063c0569b6a7fa9020081507c3",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_availability_group/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_availability_group/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_database",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_database/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "291c6f9c2e41aa8c04d6b8feb47807d97cdf9f02b487eb63f4507fbac044fae1",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_database/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_database/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c90756dd3934d30739814f2f25f6bed9190409f7134a21b6547594842dedeade",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_resource_governor",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_resource_governor/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8f9e2da9d3feca4c1b60f565a53f4dc7e62f3a7eef4444e82b29d46d28c0bed3",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_resource_governor/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_resource_governor/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "da6570816fbce650c248033a1d6442e212b4d61baa00d6fbc449ae2e9b00777a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dba_multitool",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dba_multitool/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dba_multitool/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dba_multitool/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "9c2dc342256920c670d472b94856269834490da88bd511ce501d7158dd080ecd",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dba_multitool/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/dba_multitool/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/login",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/login/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/login/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/login/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e43e68379e5d021d42afa83f87c2239ed1532ed52a0bba45a8bb0b5352193e9b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/login/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/login/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_tcp_port",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_tcp_port/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "823c89dbff7ce470f0ab6e7e3c41e7fa02b7b38fd4a1d5bcda2ecbcb98a4dbd7",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_tcp_port/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_tcp_port/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d692ce8436946b398e6cb3ff85f4c0e6a500468fb623d144566b25db71a60af5",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_tcp_port/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_tcp_port/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/maintenance_solution",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/maintenance_solution/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/maintenance_solution/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/maintenance_solution/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d6841548d89da6e201186a5bd9ba2f370aff1ed3818fc9d5609a26a7405bd088",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/maintenance_solution/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/maintenance_solution/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/instance_info",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/instance_info/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/instance_info/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/instance_info/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "22e5f3e538dfd862aebe6429f2d06293499bcd83a7b8da0f6afbee5f8033366b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/instance_info/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/instance_info/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_step",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_step/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_step/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_step/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6adff290d0afbfbf88a488083531374c89338499ae35daea7d73599e83f88e16",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_step/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_step/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/credential",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/credential/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/credential/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/credential/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "502c966d269ba16b8f50711aa3413b89361ca26241b95ea42bfadbb543078190",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/credential/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/credential/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_category",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_category/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_category/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_category/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0544826a56fa9285258e41f18f989bad46a9a333c4508b6ff52991cb820ef6dd",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_category/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_category/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_instance_info",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_instance_info/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "96874064bd5afc3782b688417ee53a256f2aeee2b3f7be9db26ef14760752d33",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_instance_info/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_instance_info/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ce5de48e8e8a42b74d629f088dc4e10650fe45b811ef394b852884e11ac3d20b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/database",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/database/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/database/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/database/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "096c592c99e22c947444c3cefe3007bdc7b6370b7c814b0c6cc0e8bd1b6f77c5",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/database/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/database/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/backup",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/backup/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/backup/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/backup/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "78fe28d8507ece20158769c69efa631fdde989b9f2ef8d62cd5ac65e059eaa50",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/backup/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/backup/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_schedule",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_schedule/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "79821e9e38c38952ccfdbe45b988082364c67d537d5753dfbb0a5f8716c48ab9",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_schedule/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_schedule/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "30a85b8a191383a79170a54c720a886e461ac3ac35a69ef79920b5fb6aef7447",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_schedule/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/agent_job_schedule/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_replica",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_replica/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b522894638086953bde369a5f6c194a90c32338fefab24021b399659246ee20b",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_replica/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_replica/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d2635b4ff57bb61b0691b4577c5c8ab6dae4dd5a8f815d00abf9d849695cb392",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_replica/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_ag_replica/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a170d576026b40f2e8d93ced0dcaff0108bd61e8f9d62bc3bee3bb14dba13b83",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_memory",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_memory/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "29e8c25ab424e16e434d902ced6f408da8a4f1f9363126caa03092f62bcb43aa",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_memory/meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/win_memory/meta/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c32e78042afc05d5738763ed9a9281f6e6a5e03231c2124087400143409ec6d6",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/inventory",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0a28c1f749c45ff439aeeb826635429412f65c284d7d52ca7ff51b9dde495551",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/inventory.winrm.ci",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d1a9b5a526214d256d89f06ac3180e7d73b63b7cd199a536888405e21f8768de",
+ "format": 1
+ },
+ {
+ "name": ".vscode",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".vscode/extensions.json",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f72b83e1aa1301adb18ce0fe71ce6613d3cfb148f881b3e39c55359d41d3277f",
+ "format": 1
+ },
+ {
+ "name": ".vscode/settings.json",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "129f69fd05d6feacc20ea9f2edf00332ce20639fa3c35f4f4b0a42dea2835bac",
+ "format": 1
+ },
+ {
+ "name": "CHANGELOG.rst",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "9f5ed35870b957394be3dca618c29c35bdf6628666678226aae495cdd366b6e8",
+ "format": 1
+ }
+ ],
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/lowlydba/sqlserver/LICENSE b/ansible_collections/lowlydba/sqlserver/LICENSE
new file mode 100644
index 000000000..f288702d2
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/ansible_collections/lowlydba/sqlserver/MAINTAINERS b/ansible_collections/lowlydba/sqlserver/MAINTAINERS
new file mode 100644
index 000000000..2357003fc
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/MAINTAINERS
@@ -0,0 +1,2 @@
+lowlydba
+briantist
diff --git a/ansible_collections/lowlydba/sqlserver/MANIFEST.json b/ansible_collections/lowlydba/sqlserver/MANIFEST.json
new file mode 100644
index 000000000..8ce4fe513
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/MANIFEST.json
@@ -0,0 +1,32 @@
+{
+ "collection_info": {
+ "namespace": "lowlydba",
+ "name": "sqlserver",
+ "version": "1.3.1",
+ "authors": [
+ "John McCall (github.com/lowlydba)"
+ ],
+ "readme": "README.md",
+ "tags": [
+ "sqlserver",
+ "mssql",
+ "database"
+ ],
+ "description": "Ansible collection using PowerShell to configure and maintain SQL Server.",
+ "license": [],
+ "license_file": "LICENSE",
+ "dependencies": {},
+ "repository": "https://github.com/LowlyDBA/lowlydba.sqlserver",
+ "documentation": "https://lowlydba.github.io/lowlydba.sqlserver",
+ "homepage": "https://github.com/LowlyDBA/lowlydba.sqlserver",
+ "issues": "https://github.com/LowlyDBA/lowlydba.sqlserver/issues"
+ },
+ "file_manifest_file": {
+ "name": "FILES.json",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "84cd6ed3f803e766ba81e7a8b79a2347820c2c28333e7720260378cfcb58831d",
+ "format": 1
+ },
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/lowlydba/sqlserver/README.md b/ansible_collections/lowlydba/sqlserver/README.md
new file mode 100644
index 000000000..8b0b7873f
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/README.md
@@ -0,0 +1,139 @@
+# lowlydba.sqlserver Collection for Ansible
+
+![GPL v3](https://img.shields.io/github/license/lowlydba/lowlydba.sqlserver)
+[![CI](https://github.com/lowlydba/lowlydba.sqlserver/actions/workflows/ansible-test.yml/badge.svg)](https://github.com/lowlydba/lowlydba.sqlserver/actions/workflows/ansible-test.yml)
+[![CI (Windows)](https://github.com/lowlydba/lowlydba.sqlserver/actions/workflows/ansible-test-windows.yml/badge.svg)](https://github.com/lowlydba/lowlydba.sqlserver/actions/workflows/ansible-test-windows.yml)
+[![codecov](https://codecov.io/gh/lowlydba/lowlydba.sqlserver/branch/main/graph/badge.svg?token=3TW3VBCn9N)](https://codecov.io/gh/lowlydba/lowlydba.sqlserver)
+
+- [Modules](#modules)
+- [Code of Conduct](#code-of-conduct)
+- [Communication](#communication)
+- [Contributing to this collection](#contributing-to-this-collection)
+- [Collection maintenance](#collection-maintenance)
+- [Tested with](#tested-with)
+- [External requirements](#external-requirements)
+- [Using this collection](#using-this-collection)
+ - [Installing the Collection from Ansible Galaxy](#installing-the-collection-from-ansible-galaxy)
+- [Release notes](#release-notes)
+- [Releasing](#releasing)
+
+## Modules
+
+For the most up to date information, see the [plugin section](https://lowlydba.github.io/lowlydba.sqlserver/branch/main/collections/lowlydba/sqlserver/index.html#plugins-in-lowlydba-sqlserver) of the documentation for this collection (<https://lowlydba.github.io/lowlydba.sqlserver>).
+
+For the current version contained in the Ansible Community General Collection, see the [official documentation](https://docs.ansible.com/ansible/latest/collections/lowlydba/sqlserver/index.html).
+
+## Code of Conduct
+
+We follow the [Ansible Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html) in all our interactions within this project.
+
+If you encounter abusive behavior, please refer to the [policy violations](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html#policy-violations) section of the Code for information on how to raise a complaint.
+
+## Communication
+
+Join us in the `#ansible` (general use questions and support), `#ansible-community` (community and collection development questions), and other [IRC channels](https://docs.ansible.com/ansible/devel/community/communication.html#irc-channels).
+
+We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit) virtually or in-person. Track [The Bullhorn newsletter](https://eepurl.com/gZmiEP) and join us.
+
+For more information about communication, refer to the [Ansible Communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
+
+## Contributing to this collection
+
+The content of this collection is made by people like you, a community of individuals collaborating on making the world better through developing automation software. We are actively accepting new contributors.
+
+We use the following guidelines:
+
+- [CONTRIBUTING.md](CONTRIBUTING.md)
+- [REVIEW_CHECKLIST.md](REVIEW_CHECKLIST.md)
+- [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html)
+- [Ansible Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/index.html)
+- [Ansible Collection Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#contributing-to-collections)
+
+## Collection maintenance
+
+The current maintainers are listed in the [MAINTAINERS](MAINTAINERS) file. If you have questions or need help, feel free to mention them in the proposals.
+
+To learn how to maintain / become a maintainer of this collection, refer to the [Maintainer guidelines](MAINTAINING.md).
+
+## Tested with
+
+### Ansible
+
+- 2.11
+- 2.12
+- 2.13
+- 2.14
+- dlevel
+
+### SQL Server
+
+- SQL Server 2000 - current (via DBATools)
+- Azure SQL Database Managed Instance - YMMV
+
+## External requirements
+
+- PowerShell modules
+ - [dbatools][dbatools] >= 1.1.112
+ - [dbops][dbops] >= 0.8.0
+
+## Using this collection
+
+### Installing the Collection from Ansible Galaxy
+
+Before using this collection, you need to install it with the Ansible Galaxy command-line tool:
+
+```bash
+ansible-galaxy collection install lowlydba.sqlserver
+```
+
+You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format:
+
+```yaml
+---
+collections:
+ - name: lowlydba.sqlserver
+```
+
+Note that if you install the collection from Ansible Galaxy, it will not be upgraded automatically when you upgrade the `ansible` package. To upgrade the collection to the latest available version, run the following command:
+
+```bash
+ansible-galaxy collection install lowlydba.sqlserver --upgrade
+```
+
+You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version `0.1.0`:
+
+```bash
+ansible-galaxy collection install lowlydba.sqlserver:==0.1.0
+```
+
+See [Ansible Using collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details.
+
+## Releasing
+
+### Release notes
+
+See the [changelog](https://github.com/lowlydba/lowlydba.sqlserver/tree/main/CHANGELOG.rst).
+
+### Next Release
+
+No major release planned currently.
+
+### Schedule
+
+- Minor releases and patches will aim to be released within 2 weeks of being merged into `main` or when necessary.
+- Non-current minor versions will not generally be patched, since there is little expected breaking of backwards compatibility.
+ - If this does occur, an exception can be made.
+
+### Versioning
+
+This project adheres to [semantic versioning](https://semver.org/) as tracked in [`galaxy.yml`](https://github.com/lowlydba/lowlydba.sqlserver/blob/main/galaxy.yml).
+
+### Deprecation
+
+- Deprecations are done by version number (not by date).
+- New deprecations can be added during every minor release, under the condition that they do not break backwards compatibility.
+- Deprecations are expected to have a deprecation cycle of at least 2 major versions (i.e. ~1 year). Maintainers can use a longer deprecation cycle if they want to support the old code for that long.
+
+<!-- Link shortcuts -->
+[dbatools]: https://dbatools.io
+[dbops]: https://github.com/dataplat/dbops
diff --git a/ansible_collections/lowlydba/sqlserver/changelogs/changelog.yaml b/ansible_collections/lowlydba/sqlserver/changelogs/changelog.yaml
new file mode 100644
index 000000000..33237c7b7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/changelogs/changelog.yaml
@@ -0,0 +1,407 @@
+ancestor: null
+releases:
+ 0.1.0:
+ changes:
+ release_summary: It's a release! First version to publish to Ansible Galaxy.
+ fragments:
+ - v0.1.0_summary.yml
+ modules:
+ - description: Configures a SQL Agent job.
+ name: agent_job
+ namespace: ''
+ - description: Configures a SQL Agent job category.
+ name: agent_job_category
+ namespace: ''
+ - description: Configures a SQL Agent job schedule.
+ name: agent_job_schedule
+ namespace: ''
+ - description: Configures a SQL Agent job step.
+ name: agent_job_step
+ namespace: ''
+ - description: Creates and configures a database.
+ name: database
+ namespace: ''
+ - description: Configures a login for the target SQL Server instance.
+ name: login
+ namespace: ''
+ - description: Install/update Maintenance Solution
+ name: maintenance_solution
+ namespace: ''
+ - description: Sets the maximum memory for a SQL Server instance.
+ name: memory
+ namespace: ''
+ - description: Executes a generic nonquery.
+ name: nonquery
+ namespace: ''
+ - description: Configures the resource governor on a SQL Server instance.
+ name: resource_governor
+ namespace: ''
+ - description: Configures a resource pool for use by the Resource Governor.
+ name: rg_resource_pool
+ namespace: ''
+ - description: Configures a workload group for use by the Resource Governor.
+ name: rg_workload_group
+ namespace: ''
+ - description: Make instance level system configuration changes via sp_configure.
+ name: sp_configure
+ namespace: ''
+ - description: Install/update sp_whoisactive by Adam Mechanic.
+ name: sp_whoisactive
+ namespace: ''
+ - description: Enable or disable global trace flags on a SQL Server instance.
+ name: traceflag
+ namespace: ''
+ release_date: '2022-03-30'
+ 0.1.1:
+ changes:
+ release_summary: Add database tag for Galaxy
+ fragments:
+ - v0.1.1_summary.yml
+ release_date: '2022-03-31'
+ 0.10.0:
+ changes:
+ minor_changes:
+ - Update minimum required DBATools version universally to 1.1.108 to accommodate
+ new tcp module.
+ release_summary: The first_responder_kit and tcp_port modules, along with a
+ bump in the required dbatools version.
+ fragments:
+ - 105-update-dbatools-version.yml
+ - v0-10-0-release-summary.yml
+ modules:
+ - description: Install/update the First Responder Kit scripts.
+ name: first_responder_kit
+ namespace: ''
+ - description: Sets the TCP port for the instance.
+ name: tcp_port
+ namespace: ''
+ release_date: '2022-06-27'
+ 0.10.1:
+ changes:
+ bugfixes:
+ - Fix change detection in resource_governor module.
+ release_summary: Bug fix for resource_governor.
+ fragments:
+ - 108-rg-bug-fix.yml
+ - v0-10-1-release-summary.yml
+ release_date: '2022-06-28'
+ 0.11.0:
+ changes:
+ release_summary: Adding new dbops module.
+ fragments:
+ - 0-11-0-release-summary.yml
+ modules:
+ - description: Runs migration scripts against a database.
+ name: install_script
+ namespace: ''
+ release_date: '2022-07-03'
+ 0.11.1:
+ changes:
+ bugfixes:
+ - Fix `availability_group` module so that NUL backups can be properly taken
+ if needed.
+ - Fix incorrect examples in `availability_group` module documentation.
+ - Fix incorrect examples in `install_script` module documentation.
+ - Fix incorrect examples in `spn` module documentationb.
+ - Fixed bugs where adding replica did not work properly for several reasons.
+ release_summary: Bug fixes for AlwaysOn related modules and fixing errors in
+ some documentation examples.
+ fragments:
+ - 0-11-1-release-summary.yml
+ - 113-fix-ag-module.yml
+ - x-fix-spn-docs.yml
+ release_date: '2022-07-06'
+ 0.11.2:
+ changes:
+ release_summary: Bumping required dbatools version to ensure the `restore` module
+ works on MacOS PowerShell Core (https://github.com/dataplat/dbatools/pull/8435).
+ fragments:
+ - 0-11-2-release-summary.yml
+ release_date: '2022-07-09'
+ 0.2.0:
+ changes:
+ minor_changes:
+ - Add DbaTools module requirement to documentation and fix missing examples.
+ (https://github.com/lowlydba/lowlydba.sqlserver/pull/47)
+ - Utilize PowerShell Requires for dbatools min version needs instead of custom
+ function. Consolidate/standardize credential setup and serialization. (https://github.com/lowlydba/lowlydba.sqlserver/pull/48)
+ release_summary: Code cleanup, testing improvements, new _info module!
+ fragments:
+ - 47-improve-module-documentation.yml
+ - 48-cleanup-utils.yml
+ modules:
+ - description: Returns basic information for a SQL Server instance.
+ name: instance_info
+ namespace: ''
+ release_date: '2022-04-04'
+ 0.3.0:
+ changes:
+ minor_changes:
+ - Fix logic to properly pass password policy options to function in the login
+ module.
+ release_summary: New sa module and fixes for login related modules.
+ fragments:
+ - 55-fix-login-param.yml
+ - v0.3.0-release-summary.yml
+ modules:
+ - description: Configure the 'sa' login for security best practices.
+ name: sa
+ namespace: ''
+ release_date: '2022-04-05'
+ 0.4.0:
+ changes:
+ breaking_changes:
+ - All modules should use a bool 'enabled' instead of a string 'status' to control
+ object state.
+ minor_changes:
+ - Test for 'Name' property for sa module after dbatools release 1.1.95 standardizes
+ command outputs. (https://github.com/dataplat/dbatools/releases/tag/v1.1.95)
+ release_summary: Two new AlwaysOn modules and a few consistency fixes!
+ fragments:
+ - 0.4.0-release-summary.yml
+ - 56-test-for-login-name.yml
+ - 60-standardize-enabled-option.yml
+ modules:
+ - description: Configures availability group(s).
+ name: availability_group
+ namespace: ''
+ - description: Enable or disable HADR.
+ name: hadr
+ namespace: ''
+ release_date: '2022-04-27'
+ 0.5.0:
+ changes:
+ minor_changes:
+ - Remove CI support for Ansible 2.10
+ release_summary: CI and testing improvements, along with the final availability
+ group module ag_replica.
+ fragments:
+ - 70-deprecate-ansible-2.10.yml
+ - release-summary.yml
+ modules:
+ - description: Configures an availability group listener.
+ name: ag_listener
+ namespace: ''
+ - description: Configures an availability group replica.
+ name: ag_replica
+ namespace: ''
+ release_date: '2022-05-11'
+ 0.6.0:
+ changes:
+ release_summary: Adding new SPN module
+ fragments:
+ - release-summary-0-6-0.yml
+ modules:
+ - description: Configures SPNs for SQL Server.
+ name: spn
+ namespace: ''
+ release_date: '2022-05-20'
+ 0.7.0:
+ changes:
+ release_summary: Add module for DBA Multitool.
+ fragments:
+ - release-summary-0-7-0.yml
+ modules:
+ - description: Install/update the DBA Multitool suite by John McCAll
+ name: dba_multitool
+ namespace: ''
+ release_date: '2022-05-21'
+ 0.8.0:
+ changes:
+ bugfixes:
+ - Fix inability to enable an agent job schedule after it has been disabled.
+ minor_changes:
+ - Standardize use of 'database' vs 'database_name' in all documentation and
+ options specs. Not a breaking change.
+ release_summary: A few small fixes and the new 'backup' module.
+ fragments:
+ - 83-fix-agent-schedule.yml
+ - 84-standardize-database-option.yml
+ modules:
+ - description: Performs a backup operation.
+ name: backup
+ namespace: ''
+ release_date: '2022-05-31'
+ 0.9.0:
+ changes:
+ bugfixes:
+ - backup - Only use blocksize when specified.
+ fragments:
+ - 90-fix-backup-blocksize.yml
+ modules:
+ - description: Performs a restore operation.
+ name: restore
+ namespace: ''
+ release_date: '2022-06-18'
+ 0.9.1:
+ changes:
+ bugfixes:
+ - Allow agent job steps to be removed by specifying the step ID only. This is
+ likely needed in cleanup of steps from previous job configurations.
+ release_summary: Bugfix!
+ fragments:
+ - 0-9-1-release_sumary.yml
+ - 95-fix-agent-job-step-removal.yml
+ release_date: '2022-06-21'
+ 0.9.2:
+ changes:
+ bugfixes:
+ - agent_job - Fix incorrectly reported change status when no change occurred.
+ - agent_job_schedule - Fix incorrectly reported change status when no change
+ occurred.
+ - agent_job_step - Fix incorrectly reported change status when no change occurred.
+ release_summary: Bugfixes for agent related modules that incorrectly reported
+ change statuses.
+ fragments:
+ - 97-fix-agent-related-status.yml
+ - 97-release-summary.yml
+ release_date: '2022-06-22'
+ 0.9.3:
+ changes:
+ bugfixes:
+ - memory - Fix improper changed detection.
+ release_summary: More change detection fixing.
+ fragments:
+ - 100-fix-memory.yml
+ - v0-9-3-release-summary.yml
+ release_date: '2022-06-22'
+ 1.0.0:
+ changes:
+ release_summary: "Bumping to version 1.0.0 now that this collection is being
+ used in production in at least one place \U0001F389"
+ fragments:
+ - v1-release-summary.yml
+ release_date: '2022-08-03'
+ 1.0.1:
+ changes:
+ bugfixes:
+ - Fixed bug in how the classifier function name is being assigned to the variable
+ in the resource_governor module.
+ release_summary: Minor bug fix.
+ fragments:
+ - 1-0-1-release_summary.yml
+ - resource_governor.yml
+ release_date: '2022-08-20'
+ 1.0.2:
+ changes:
+ bugfixes:
+ - _SqlServerUtils module_util - added explicit license to private module util
+ (https://github.com/lowlydba/lowlydba.sqlserver/pull/119).
+ - meta/runtime.yml - updated out of date runtime version info (https://github.com/lowlydba/lowlydba.sqlserver/pull/119).
+ - most modules - fixed alignment, formatting, and typos in module documentation
+ (https://github.com/lowlydba/lowlydba.sqlserver/pull/119).
+ release_summary: Minor documentation bugfixes and enhancements as requested
+ in the Ansible inclusion process.
+ fragments:
+ - 119-doc-updates.yml
+ - v1-0-2-release-summary.yml
+ release_date: '2022-08-29'
+ 1.0.3:
+ changes:
+ bugfixes:
+ - Minor documentation fixes (https://github.com/lowlydba/lowlydba.sqlserver/pull/122).
+ release_summary: Minor documentation fixes from the second Ansible inclusion
+ review.
+ fragments:
+ - 122-doc-fixes.yml
+ - v1-0-3-release-summary.yml
+ release_date: '2022-09-03'
+ 1.0.4:
+ changes:
+ bugfixes:
+ - Fix cleanup_time default to match documentation default & lint fixes (https://github.com/lowlydba/lowlydba.sqlserver/pull/127).
+ release_summary: Minor fixes to resolve new dlevel sanity checks.
+ fragments:
+ - 127-fix-doc-check.yml
+ - release-summary.yml
+ release_date: '2022-11-05'
+ 1.1.0:
+ changes:
+ release_summary: Adding a new user module.
+ modules:
+ - description: Configures a user within a database
+ name: user
+ namespace: ''
+ release_date: '2022-11-12'
+ 1.1.1:
+ changes:
+ minor_changes:
+ - modules - all modules now document their platform and support for check mode
+ in their attributes documentation (https://github.com/lowlydba/lowlydba.sqlserver/pull/134).
+ fragments:
+ - 137-add-attributes.yml
+ release_date: '2022-11-28'
+ 1.1.2:
+ changes:
+ bugfixes:
+ - Removed the default value for xp_dirtree to allow compatibility with Azure
+ SQL Mangaed instances (https://github.com/lowlydba/lowlydba.sqlserver/pull/141)
+ release_summary: Bug fix for Azure Database Managed Instance compatibility.
+ fragments:
+ - 1-1-2-release-summary.yml
+ - xpdirtree_sql_mi_bugfix.yml
+ release_date: '2022-12-02'
+ 1.1.3:
+ changes:
+ bugfixes:
+ - Removed default value for reuse_source_folder_structure to fix compatability
+ with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/145)
+ release_summary: Another minor fix to increase SQL Managed Instance support.
+ fragments:
+ - reuse_source_folder_structure_sql_mi_bugfix.yml
+ - v1-1-3-release-summary.yml
+ release_date: '2022-12-05'
+ 1.2.0:
+ changes:
+ bugfixes:
+ - Removed default value for ReplaceDbNameInFile to fix compatability with SQL
+ MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/148)
+ minor_changes:
+ - Fixed typo in the traceflag module's documentation. (https://github.com/lowlydba/lowlydba.sqlserver/pull/150)
+ - Return "RestartRequired" when a module performs changes that require an addition
+ service restart to take effect. (https://github.com/lowlydba/lowlydba.sqlserver/pull/150/)
+ release_summary: Azure SQL MI compatibility fixes & indicating required restarts
+ for settings changes.
+ fragments:
+ - 1-2-0-release-summary.yml
+ - 150-restart-indicator.yml
+ - ReplaceDbNameInFile_sql_mi_bugfix.yml
+ release_date: '2022-12-05'
+ 1.2.1:
+ changes:
+ bugfixes:
+ - Added missing mapping for UseDestinationDefaultDirectories (https://github.com/lowlydba/lowlydba.sqlserver/pull/153)
+ - Removed default value for KeepCDC to fix compatability with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/153)
+ - Removed default value for UseDestinationDefaultDirectories to fix compatability
+ with SQL MI (https://github.com/lowlydba/lowlydba.sqlserver/pull/153)
+ release_summary: More Azure SQL Managed Instance compatibility fixes.
+ fragments:
+ - 1-2-1-release_summary.yml
+ - 153-additional_sql_mi_fixes.yml
+ release_date: '2022-12-06'
+ 1.3.0:
+ changes:
+ minor_changes:
+ - Adding a new credential module
+ release_summary: New module to manage credentials added!
+ fragments:
+ - 1-3-0-release_summary.yml
+ - add_credential_module.yml
+ modules:
+ - description: Configures a credential on a SQL server
+ name: credential
+ namespace: ''
+ release_date: '2022-12-09'
+ 1.3.1:
+ changes:
+ bugfixes:
+ - Fixes to incorrect variable reference in Login module (https://github.com/lowlydba/lowlydba.sqlserver/pull/161)
+ minor_changes:
+ - Update login module documentation to indicate result will always be changed
+ when a password is supplied. (https://github.com/lowlydba/lowlydba.sqlserver/pull/167)
+ release_summary: Small bugfixes and documentation enhancements.
+ fragments:
+ - 1-3-1-release_summary.yml
+ - 167-update-login-docs.yml
+ - fix_sa.yml
+ release_date: '2022-12-18'
diff --git a/ansible_collections/lowlydba/sqlserver/changelogs/config.yaml b/ansible_collections/lowlydba/sqlserver/changelogs/config.yaml
new file mode 100644
index 000000000..6fa3e9ae8
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/changelogs/config.yaml
@@ -0,0 +1,30 @@
+# https://github.com/ansible-community/antsibull-changelog/blob/main/docs/changelogs.rst
+changelog_filename_template: ../CHANGELOG.rst
+changelog_filename_version_depth: 0
+changes_file: changelog.yaml
+changes_format: combined
+keep_fragments: false
+mention_ancestor: true
+new_plugins_after_name: removed_features
+notesdir: fragments
+prelude_section_name: release_summary
+prelude_section_title: Release Summary
+sections:
+- - major_changes
+ - Major Changes
+- - minor_changes
+ - Minor Changes
+- - breaking_changes
+ - Breaking Changes / Porting Guide
+- - deprecated_features
+ - Deprecated Features
+- - removed_features
+ - Removed Features (previously deprecated)
+- - security_fixes
+ - Security Fixes
+- - bugfixes
+ - Bugfixes
+- - known_issues
+ - Known Issues
+title: lowlydba.sqlserver
+trivial_section_name: trivial
diff --git a/ansible_collections/lowlydba/sqlserver/changelogs/fragments/.keep b/ansible_collections/lowlydba/sqlserver/changelogs/fragments/.keep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/changelogs/fragments/.keep
diff --git a/ansible_collections/lowlydba/sqlserver/docs/.gitkeep b/ansible_collections/lowlydba/sqlserver/docs/.gitkeep
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/docs/.gitkeep
@@ -0,0 +1 @@
+
diff --git a/ansible_collections/lowlydba/sqlserver/meta/runtime.yml b/ansible_collections/lowlydba/sqlserver/meta/runtime.yml
new file mode 100644
index 000000000..03c25c9ac
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/meta/runtime.yml
@@ -0,0 +1,2 @@
+---
+requires_ansible: ">=2.11"
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/attributes.py b/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/attributes.py
new file mode 100644
index 000000000..76cf703cd
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/attributes.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+
+class ModuleDocFragment(object):
+
+ DOCUMENTATION = r'''
+options: {}
+'''
+
+ CHECK_MODE = r'''
+options: {}
+attributes:
+ check_mode:
+ support: full
+ description: Can run in check_mode and return changed status prediction without modifying target.
+'''
+
+ CHECK_MODE_READ_ONLY = r'''
+options: {}
+attributes:
+ check_mode:
+ support: full
+ description: This module is "read only" and operates the same regardless of check mode.
+'''
+
+ PLATFORM_ALL = r'''
+options: {}
+attributes:
+ platform:
+ platforms: all
+ support: full
+ description: Target OS/families that can be operated against.
+'''
+
+ PLATFORM_WIN = r'''
+options: {}
+attributes:
+ platform:
+ platforms: Windows
+ support: full
+ description: Target OS/families that can be operated against.
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/sql_credentials.py b/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/sql_credentials.py
new file mode 100644
index 000000000..1af7e9a44
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/sql_credentials.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Options for authenticating with SQL Authentication.
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+
+
+class ModuleDocFragment(object):
+
+ DOCUMENTATION = r'''
+options:
+ sql_instance:
+ description:
+ - The SQL Server instance to modify.
+ type: str
+ required: true
+ sql_username:
+ description:
+ - Username for SQL Authentication.
+ type: str
+ required: false
+ sql_password:
+ description:
+ - Password for SQL Authentication.
+ type: str
+ required: false
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/state.py b/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/state.py
new file mode 100644
index 000000000..d2ede689a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/doc_fragments/state.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Options for object state.
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+
+
+class ModuleDocFragment(object):
+
+ DOCUMENTATION = r'''
+options:
+ state:
+ description:
+ - Whether or not the object should be C(present) or C(absent).
+ required: false
+ type: str
+ default: 'present'
+ choices: ['present', 'absent']
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/module_utils/_SqlServerUtils.psm1 b/ansible_collections/lowlydba/sqlserver/plugins/module_utils/_SqlServerUtils.psm1
new file mode 100644
index 000000000..e45b7c743
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/module_utils/_SqlServerUtils.psm1
@@ -0,0 +1,186 @@
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+# Private
+
+function Get-LowlyDbaSqlServerAuthSpec {
+ <#
+ .SYNOPSIS
+ Output the auth spec used by every module.
+
+ .DESCRIPTION
+ Standardized way to access the common auth spec for modules.
+ Uses the recommended Ansible naming convention.
+ #>
+ @{
+ options = @{
+ sql_instance = @{type = 'str'; required = $true }
+ sql_username = @{type = 'str'; required = $false }
+ sql_password = @{type = 'str'; required = $false; no_log = $true }
+ }
+ required_together = @(
+ , @('sql_username', 'sql_password')
+ )
+ }
+}
+
+function Get-SqlCredential {
+ <#
+ .SYNOPSIS
+ Build a credential object for SQL Authentication.
+
+ .DESCRIPTION
+ Standardized way to build a SQL Credential object that is required for SQL Authentication.
+ #>
+ [CmdletBinding()]
+ param (
+ [Parameter(Mandatory = $true)]
+ [ValidateScript({ $_.GetType().FullName -eq 'Ansible.Basic.AnsibleModule' })]
+ $Module
+ )
+ try {
+ $sqlInstance = $module.Params.sql_instance
+ if ($null -ne $Module.Params.sql_username) {
+ [securestring]$secPassword = ConvertTo-SecureString $Module.Params.sql_password -AsPlainText -Force
+ [pscredential]$sqlCredential = New-Object System.Management.Automation.PSCredential ($Module.Params.sql_username, $secPassword)
+ }
+ else {
+ $sqlCredential = $null
+ }
+ return $sqlInstance, $sqlCredential
+ }
+ catch {
+ Write-Error ("Error building Credential for SQL Authentication spec.")
+ }
+}
+
+function ConvertTo-SerializableObject {
+ <#
+ .SYNOPSIS
+ Transforms some members of a DbaTools result objects to be more serialization-friendly and prevent infinite recursion.
+
+ .DESCRIPTION
+ Stringifies version properties so we don't get serialized [System.Version] objects which aren't very useful.
+ #>
+ [CmdletBinding()]
+ param(
+ [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
+ [Object]
+ $InputObject,
+ [Parameter()]
+ [string[]]
+ $ExcludeProperty = @(
+ <#
+ Returning a list of properties as a property is redundant.
+ #>
+ 'Properties',
+ <#
+ Urn is not useful.
+ #>
+ 'Urn',
+ <#
+ ExecutionManager can contain a login password in plain text.
+ #>
+ 'ExecutionManager',
+ <#
+ UserData is not useful.
+ #>
+ 'UserData',
+ <#
+ ParentCollection is redundant.
+ #>
+ 'ParentCollection',
+ <#
+ DatabaseEngineEdition is not useful.
+ #>
+ 'DatabaseEngineEdition',
+ <#
+ DatabaseEngineType is not useful.
+ #>
+ 'DatabaseEngineType',
+ <#
+ ServerVersion is not useful.
+ #>
+ 'ServerVersion',
+ <#
+ Server is redundant.
+ #>
+ 'Server',
+ <#
+ Parent is not useful.
+ #>
+ 'Parent'
+ ),
+ [bool]$UseDefaultProperty = $true
+ )
+
+ Begin {
+ # We need to remove this type data so that arrays don't get serialized weirdly.
+ # In some cases, an array gets serialized as an object with a Count and Value property where the value is the actual array.
+ # See: https://stackoverflow.com/a/48858780/3905079
+ # This only affects Windows PowerShell.
+ # This has to come after the AnsibleModule is created, otherwise it will break the sanity tests.
+ if (-not $IsLinux) {
+ Remove-TypeData -TypeName System.Array -ErrorAction SilentlyContinue
+ }
+ }
+
+ Process {
+ $defaultProperty = $InputObject.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames
+ if ($defaultProperty -and $UseDefaultProperty) {
+ $objectProperty = $InputObject.PSObject.Properties | Where-Object { $_.Name -in $defaultProperty -and $_.Name -notin $ExcludeProperty }
+ }
+ else {
+ $objectProperty = $InputObject.PSObject.Properties | Where-Object { $_.Name -notin $ExcludeProperty }
+ }
+ $properties = foreach ($p in $objectProperty) {
+ $pName = $p.Name
+ $pValue = $p.Value
+
+ switch ($p) {
+ { $null -eq $pValue } {
+ @{
+ Name = $pName
+ Expression = { $null }.GetNewClosure()
+ }
+ break
+ }
+ { $pValue -is [datetime] } {
+ @{
+ Name = $pName
+ Expression = { $pValue.ToString('o') }.GetNewClosure()
+ }
+ break
+ }
+ { $pValue -is [enum] -or $pValue -is [type] } {
+ @{
+ Name = $pName
+ Expression = { $pValue.ToString() }.GetNewClosure()
+ }
+ break
+ }
+ { $pValue.GetType().Name -like '*Collection' } {
+ @{
+ Name = $pName
+ Expression = { [string[]]($pValue.Name) }.GetNewClosure()
+ }
+ break
+ }
+ { $pValue.GetType().Name -eq 'User' } {
+ @{
+ Name = $pName
+ Expression = { [string[]]($pValue.Name) }.GetNewClosure()
+ }
+ break
+ }
+ default { $pName }
+ }
+ }
+ return $InputObject | Select-Object -Property $properties
+ }
+}
+
+$exportMembers = @("Get-SqlCredential", "ConvertTo-SerializableObject", "Get-LowlyDbaSqlServerAuthSpec")
+Export-ModuleMember -Function $exportMembers
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.ps1
new file mode 100644
index 000000000..dd377141b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.ps1
@@ -0,0 +1,86 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ ag_name = @{type = 'str'; required = $true }
+ listener_name = @{type = 'str'; required = $true }
+ ip_address = @{type = 'str'; required = $false }
+ subnet_ip = @{type = 'str'; required = $false }
+ subnet_mask = @{type = 'str'; required = $false; default = '255.255.255.0' }
+ port = @{type = 'int'; required = $false; default = 1433 }
+ dhcp = @{type = 'bool'; required = $false; default = $false }
+ state = @{type = "str"; required = $false; default = "present"; choices = @("present", "absent") }
+ }
+}
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$agName = $module.Params.ag_name
+$listenerName = $module.Params.listener_name
+$subnetIp = $module.Params.subnet_ip
+$subnetMask = $module.Params.subnet_mask
+$ipAddress = $module.Params.ip_address
+$port = $module.Params.port
+$dhcp = $module.Params.dhcp
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{
+ "*:SqlInstance" = $sqlInstance
+ "*:SqlCredential" = $sqlCredential
+ "*:EnableException" = $true
+ "*:Confirm" = $false
+ "*:WhatIf" = $checkMode
+}
+
+try {
+ $existingListener = Get-DbaAgListener -AvailabilityGroup $agName -Listener $listenerName
+ if ($state -eq "present") {
+ if ($null -eq $existingListener) {
+ $listenerParams = @{
+ AvailabilityGroup = $agName
+ Name = $listenerName
+ Port = $port
+ Dhcp = $dhcp
+ SubnetMask = $subnetMask
+ }
+ if ($null -ne $ipAddress) {
+ $listenerParams.Add("IPAddress", $ipAddress)
+ }
+ if ($null -ne $subnetIp) {
+ $listenerParams.Add("SubnetIP", $subnetIp)
+ }
+ $output = Add-DbaAgListener @listenerParams
+ $module.Result.changed = $true
+ }
+ elseif ($existingListener.Port -ne $port) {
+ $output = Set-DbaAgListener -AvailabilityGroup $agName -Listener $listenerName -Port $port
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "absent") {
+ if ($null -ne $existingListener) {
+ $output = Remove-DbaAgListener -AvailabilityGroup $agName -Listener $listenerName
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring availability group listener failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.py
new file mode 100644
index 000000000..12f0ec635
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_listener.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: ag_listener
+short_description: Configures an availability group listener
+description:
+ - Creates an Availability Group Listener for an existing availability group.
+version_added: 0.5.0
+options:
+ ag_name:
+ description:
+ - Name of the target availability group.
+ type: str
+ required: true
+ listener_name:
+ description:
+ - Name of the Listener to be configured.
+ type: str
+ required: true
+ ip_address:
+ description:
+ - IP address(es) of the listener. Comma separated if multiple.
+ type: str
+ required: false
+ subnet_ip:
+ description:
+ - Subnet IP address(es) of the listener. Comma separated if multiple.
+ type: str
+ required: false
+ subnet_mask:
+ description:
+ - Sets the subnet IP mask(s) of the availability group listener. Comma separated if multiple.
+ type: str
+ required: false
+ default: 255.255.255.0
+ port:
+ description:
+ - Sets the port number used to communicate with the availability group.
+ type: int
+ required: false
+ default: 1433
+ dhcp:
+ description:
+ - Indicates whether the listener uses DHCP.
+ type: bool
+ required: false
+ default: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create Availability Group
+ lowlydba.sqlserver.availability_group:
+ sql_instance: sql-01.myco.io
+ ag_name: AG_MyDatabase
+
+- name: Create AG Listener
+ lowlydba.sqlserver.ag_listener:
+ sql_instance_primary: sql-01.myco.io
+ ag_name: AG_MyDatabase
+ listener_name: aglMyDatabase
+ ip_address: 10.0.20.20,10.1.77.77
+ subnet_ip: 255.255.252.0
+ subnet_mask: 255.255.255.0
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Add-DbaAgListener) or C(Set-DbaAgListener) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.ps1
new file mode 100644
index 000000000..cd7d09306
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.ps1
@@ -0,0 +1,193 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ sql_instance_replica = @{type = 'str'; required = $true }
+ sql_username_replica = @{type = 'str'; required = $false }
+ sql_password_replica = @{type = 'str'; required = $false; no_log = $true }
+ ag_name = @{type = 'str'; required = $true }
+ endpoint = @{type = 'str'; required = $false; default = 'hadr_endpoint' }
+ endpoint_url = @{type = 'str'; required = $false }
+ backup_priority = @{type = 'int'; required = $false; default = 50 }
+ failover_mode = @{
+ type = 'str'
+ required = $false
+ default = 'Manual'
+ choices = @('Manual', 'Automatic')
+ }
+ availability_mode = @{
+ type = 'str'
+ required = $false; default = 'AsynchronousCommit'
+ choices = @('SynchronousCommit', 'AsynchronousCommit')
+ }
+ seeding_mode = @{
+ type = 'str'
+ required = $false
+ default = 'Automatic'
+ choices = @('Manual', 'Automatic')
+ }
+ connection_mode_in_primary_role = @{
+ type = 'str'
+ required = $false
+ default = 'AllowAllConnections'
+ choices = @('AllowReadIntentConnectionsOnly', 'AllowAllConnections')
+ }
+ connection_mode_in_secondary_role = @{
+ type = 'str'
+ required = $false
+ default = 'AllowNoConnections'
+ choices = @('AllowNoConnections', 'AllowReadIntentConnectionsOnly', 'AllowAllConnections')
+ }
+ read_only_routing_connection_url = @{
+ type = 'str'
+ required = $false
+ }
+ read_only_routing_list = @{
+ type = 'str'
+ required = $false
+ }
+ cluster_type = @{
+ type = 'str'
+ required = $false
+ default = 'Wsfc'
+ choices = @('Wsfc', 'External', 'None')
+ }
+ configure_xe_session = @{ type = 'bool'; required = $false; default = $false }
+ session_timeout = @{ type = 'int'; required = $false }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+ required_together = @(
+ , @('sql_username_replica', 'sql_password_replica')
+ )
+}
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$readOnlyRoutingConnectionUrl = $module.params.read_only_routing_connection_url
+$readOnlyRoutingList = $module.Params.read_only_routing_list
+$failoverMode = $module.Params.failover_mode
+$seedingMode = $module.Params.seeding_mode
+$agName = $module.Params.ag_name
+$clusterType = $module.Params.cluster_type
+$availabilityMode = $module.Params.availability_mode
+$replicaSqlInstance = $module.Params.sql_instance_replica
+$connectionModeInPrimaryRole = $module.Params.connection_mode_in_primary_role
+$connectionModeInSecondaryRole = $module.Params.connection_mode_in_secondary_role
+$configureXESession = $module.Params.configure_xe_session
+$state = $module.Params.state
+[nullable[int]]$sessionTimeout = $module.Params.session_timeout
+$endpoint = $module.Params.endpoint
+$endpointUrl = $module.Params.endpoint_url
+$backupPriority = $module.Params.backup_priority
+
+if ($null -ne $module.Params.sql_username_replica) {
+ [securestring]$replicaSecPassword = ConvertTo-SecureString $Module.Params.sql_password_replica -AsPlainText -Force
+ [pscredential]$replicaSqlCredential = New-Object System.Management.Automation.PSCredential ($Module.Params.sql_username_replica, $replicaSecPassword)
+}
+if ($null -eq $replicaSqlCredential) {
+ $replicaSqlCredential = $sqlCredential
+}
+$module.Result.changed = $false
+$checkMode = $module.CheckMode
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $replicaInstance = Connect-DbaInstance -SqlInstance $replicaSqlInstance -SqlCredential $replicaSqlCredential
+ $allReplicas = Get-DbaAgReplica -SqlInstance $replicaSqlInstance -SqlCredential $replicaSqlCredential -AvailabilityGroup $agName
+ $existingReplica = $allReplicas | Where-Object Name -eq $replicaInstance.DomainInstanceName
+
+ if ($state -eq "present") {
+ $addReplicaSplat = @{
+ SqlInstance = $replicaSqlInstance
+ SqlCredential = $replicaSqlCredential
+ Endpoint = $endpoint
+ AvailabilityMode = $availabilityMode
+ FailoverMode = $failoverMode
+ BackupPriority = $backupPriority
+ ConnectionModeInPrimaryRole = $connectionModeInPrimaryRole
+ ConnectionModeInSecondaryRole = $connectionModeInSecondaryRole
+ SeedingMode = $seedingMode
+ ClusterType = $clusterType
+ }
+ if ($null -ne $readOnlyRoutingList) {
+ $addReplicaSplat.Add("ReadOnlyRoutingList", $readOnlyRoutingList)
+ }
+ if ($null -ne $readOnlyRoutingConnectionUrl) {
+ $addReplicaSplat.Add("ReadOnlyRoutingConnectionUrl", $readOnlyRoutingConnectionUrl)
+ }
+ if ($null -ne $endpointUrl) {
+ $addReplicaSplat.Add("EndpointUrl", $endpointUrl)
+ }
+ if ($configureXESession -eq $true) {
+ $addReplicaSplat.Add("ConfigureXESession", $true)
+ }
+ if ($null -ne $sessionTimeout) {
+ $addReplicaSplat.Add("SessionTimeout", $sessionTimeout)
+ }
+
+ if ($null -eq $existingReplica) {
+ $availabilityGroup = Get-DbaAvailabilityGroup -SqlInstance $sqlInstance -SqlCredential $sqlCredential -AvailabilityGroup $agName
+ $output = $availabilityGroup | Add-DbaAgReplica @addReplicaSplat
+ $module.Result.changed = $true
+ }
+ else {
+ $compareReplicaProperty = @(
+ 'AvailabilityMode'
+ 'FailoverMode'
+ 'BackupPriority'
+ 'ConnectionModeInPrimaryRole'
+ 'ConnectionModeInSecondaryRole'
+ 'SeedingMode'
+ 'SessionTimeout'
+ 'EndpointUrl'
+ )
+ $setReplicaSplat = @{}
+ $addReplicaSplat.GetEnumerator() | Where-Object Key -in $compareReplicaProperty | ForEach-Object { $setReplicaSplat.Add($_.Key, $_.Value) }
+ [string[]]$compareProperty = $setReplicaSplat.Keys
+ $replicaDiff = Compare-Object -ReferenceObject $setReplicaSplat -DifferenceObject $existingReplica -Property $compareProperty
+ $setReplicaSplat.Add("SqlInstance", $sqlInstance)
+ $setReplicaSplat.Add("SqlCredential", $sqlCredential)
+ $setReplicaSplat.Add("Replica", $existingReplica.Name)
+ $setReplicaSplat.Add("AvailabilityGroup", $agName)
+ if ($replicaDiff) {
+ $output = Set-DbaAgReplica @setReplicaSplat
+ $module.Result.changed = $true
+ }
+ }
+ }
+}
+catch {
+ $module.FailJson("Configuring Availability Group replica failed: $($_.Exception.Message)")
+}
+try {
+ if ($state -eq "absent") {
+ if ($null -ne $existingReplica) {
+ $output = $existingReplica | Remove-DbaAgReplica
+ $module.Result.changed = $true
+ }
+ }
+}
+catch {
+ $module.FailJson("Removing Availability Group replica failed: $($_.Exception.Message)")
+}
+
+try {
+ if ($output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error parsing results - operation likely completed: $($_.Exception.Message)")
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.py
new file mode 100644
index 000000000..d817d3331
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/ag_replica.py
@@ -0,0 +1,147 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: ag_replica
+short_description: Configures an availability group replica
+description:
+ - Configures an availability group replica.
+version_added: 0.5.0
+options:
+ sql_instance_replica:
+ description:
+ - The SQL Server instance where of the replica to be configured.
+ type: str
+ required: true
+ sql_username_replica:
+ description:
+ - Username for SQL Authentication for the secondary replica.
+ type: str
+ required: false
+ sql_password_replica:
+ description:
+ - Password for SQL Authentication for the secondary replica.
+ type: str
+ required: false
+ ag_name:
+ description:
+ - Name of the Availability Group that will have the new replica joined to it.
+ type: str
+ required: true
+ endpoint:
+ description:
+ - By default, this command will attempt to find a DatabaseMirror endpoint. If one does not exist, it will create it.
+ type: str
+ required: false
+ default: 'hadr_endpoint'
+ endpoint_url:
+ description:
+ - By default, the property C(Fqdn) of C(Get-DbaEndpoint) is used as I(endpoint_url).
+ Use I(endpoint_url) if a different URL is required due to special network configurations.
+ type: str
+ required: false
+ backup_priority:
+ description:
+ - Sets the backup priority availability group replica.
+ type: int
+ default: 50
+ failover_mode:
+ description:
+ - Whether the replica have Automatic or Manual failover.
+ type: str
+ required: false
+ default: 'Manual'
+ choices: ['Automatic', 'Manual']
+ availability_mode:
+ description:
+ - Whether the replica should be Asynchronous or Synchronous.
+ type: str
+ required: false
+ default: 'AsynchronousCommit'
+ choices: ['AsynchronousCommit', 'SynchronousCommit']
+ seeding_mode:
+ description:
+ - Default seeding mode for the replica. Should remain as the default otherwise manual setup may be required.
+ type: str
+ required: false
+ default: 'Automatic'
+ choices: ['Automatic', 'Manual']
+ connection_mode_in_primary_role:
+ description:
+ - Which connections can be made to the database when it is in the primary role.
+ type: str
+ required: false
+ default: 'AllowAllConnections'
+ choices: ['AllowReadIntentConnectionsOnly','AllowAllConnections']
+ connection_mode_in_secondary_role:
+ description:
+ - Which connections can be made to the database when it is in the secondary role.
+ type: str
+ required: false
+ default: 'AllowNoConnections'
+ choices: ['AllowNoConnections','AllowReadIntentConnectionsOnly','AllowAllConnections']
+ read_only_routing_connection_url:
+ description:
+ - Sets the read only routing connection url for the availability replica.
+ type: str
+ required: false
+ read_only_routing_list:
+ description:
+ - Sets the read only routing ordered list of replica server names to use when redirecting read-only connections through this availability replica.
+ type: str
+ required: false
+ cluster_type:
+ description:
+ - Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.
+ type: str
+ required: false
+ default: 'Wsfc'
+ choices: ['Wsfc', 'External', 'None']
+ configure_xe_session:
+ description:
+ - Configure the AlwaysOn_health extended events session to start automatically as the SSMS wizard would do.
+ type: bool
+ default: false
+ session_timeout:
+ description:
+ - How many seconds an availability replica waits for a ping response from a connected replica before considering the connection to have failed.
+ type: int
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create Availability Group
+ lowlydba.sqlserver.availability_group:
+ sql_instance: sql-01.myco.io
+ ag_name: AG_MyDatabase
+
+- name: Add a DR replica
+ lowlydba.sqlserver.ag_replica:
+ ag_name: 'AG_MyDatabase'
+ sql_instance_primary: sql-01.myco.io
+ sql_instance_replica: sql-02.myco.io
+ failover_mode: 'Manual'
+ availability_mode: 'Asynchronous'
+ seeding_mode: 'Automatic'
+ connection_mode_in_primary_role: 'AllowAllConnections'
+ connection_mode_in_secondary_role: 'AllowNoConnections'
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Add-DbaAgReplica) or C(Set-DbaAgReplica) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.ps1
new file mode 100644
index 000000000..cf261f3e2
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.ps1
@@ -0,0 +1,133 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ job = @{type = 'str'; required = $true }
+ description = @{type = 'str'; required = $false; }
+ category = @{type = 'str'; required = $false; }
+ enabled = @{type = 'bool'; required = $false; default = $true }
+ owner_login = @{type = 'str'; required = $false; }
+ start_step_id = @{type = 'int'; required = $false; }
+ schedule = @{type = 'str'; required = $false; }
+ force = @{type = 'bool'; required = $false; default = $false }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$job = $module.Params.job
+$description = $module.Params.description
+$enabled = $module.Params.enabled
+$ownerLogin = $module.Params.owner_login
+$category = $module.Params.category
+$schedule = $module.Params.schedule
+[nullable[int]]$startStepId = $module.Params.start_step_id
+$force = $module.Params.force
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+# Configure Agent job
+try {
+ $existingJob = Get-DbaAgentJob -SqlInstance $sqlInstance -SqlCredential $sqlCredential -Job $job -EnableException
+ $output = $existingJob
+
+ if ($state -eq "absent") {
+ if ($null -ne $existingJob) {
+ $output = $existingJob | Remove-DbaAgentJob -Confirm:$false -WhatIf:$checkMode -EnableException
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "present") {
+ $jobParams = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Job = $job
+ WhatIf = $checkMode
+ Force = $force
+ EnableException = $true
+ }
+
+ if ($enabled -eq $false) {
+ $jobParams.add("Disabled", $true)
+ }
+
+ if ($null -ne $ownerLogin) {
+ $jobParams.add("OwnerLogin", $ownerLogin)
+ }
+
+ if ($null -ne $schedule) {
+ $jobParams.add("Schedule", $schedule)
+ }
+
+ if ($null -ne $category) {
+ $jobParams.add("Category", $category)
+ }
+
+ if ($null -ne $description) {
+ $jobParams.add("Description", $description)
+ }
+
+ if ($null -ne $startStepID) {
+ $jobParams.add("StartStepId", $startStepID)
+ }
+
+ # Create new job
+ if ($null -eq $existingJob) {
+ try {
+ $null = New-DbaAgentJob @jobParams
+ # Explicitly fetch the new job to make sure results don't suffer from SMO / Agent stale data bugs
+ $output = Get-DbaAgentJob -SqlInstance $sqlInstance -SqlCredential $sqlCredential -Job $job -EnableException
+ }
+ catch {
+ $module.FailJson("Failed creating new agent job: $($_.Exception.Message)", $_)
+ }
+ $module.Result.changed = $true
+ }
+ # Job exists
+ else {
+ # Need to serialize to prevent SMO auto refreshing
+ $old = ConvertTo-SerializableObject -InputObject $existingJob -UseDefaultProperty $false
+ if ($enabled -eq $true) {
+ $jobParams.Add("Enabled", $true)
+ }
+ $output = Set-DbaAgentJob @jobParams
+ if ($null -ne $output) {
+ $compareProperty = @(
+ "Category"
+ "Enabled"
+ "Name"
+ "OwnerLoginName"
+ "HasSchedule"
+ "Description"
+ "StartStepId"
+ )
+ $diff = Compare-Object -ReferenceObject $output -DifferenceObject $old -Property $compareProperty
+ if ($diff -or $checkMode) {
+ $module.Result.changed = $true
+ }
+ }
+ }
+ }
+
+ if ($output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error configuring SQL Agent job: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.py
new file mode 100644
index 000000000..dbd3043f6
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: agent_job
+short_description: Configures a SQL Agent job
+description:
+ - Configure a SQL Agent job, including which schedules and category it belongs to.
+version_added: 0.1.0
+options:
+ job:
+ description:
+ - The name of the target SQL Agent job.
+ type: str
+ required: true
+ description:
+ description:
+ - Description for the SQL Agent job.
+ type: str
+ required: false
+ category:
+ description:
+ - Category for the target SQL Agent job. Must already exist.
+ type: str
+ required: false
+ enabled:
+ description:
+ - Whether the SQL Agent job should be enabled or disabled.
+ type: bool
+ required: false
+ default: true
+ version_added: '0.4.0'
+ owner_login:
+ description:
+ - The owning login for the database. Will default to the current user if
+ the database is being created and none supplied.
+ type: str
+ required: false
+ start_step_id:
+ description:
+ - What step number the job should begin with when run.
+ type: int
+ required: false
+ schedule:
+ description:
+ - The name of the schedule the job should be associated with. Only one schedule per job is supported.
+ type: str
+ required: false
+ force:
+ description:
+ - If I(force=true), any job categories will be created if they don't exist already.
+ type: bool
+ default: false
+author: "John McCall (@lowlydba)"
+notes:
+ - On slower hardware, stale job component data may be returned (i.e., a previous or default job category).
+ Configuring each component (schedule, step, category, etc.) individually is recommended for this reason.
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a job
+ lowlydba.sqlserver.agent_job:
+ sql_instance: sql-01.myco.io
+ job: MyJob
+ force: true
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaAgentJob), C(Set-DbaAgentJob), or C(Remove-DbaAgentJob) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.ps1
new file mode 100644
index 000000000..1e5c033a9
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.ps1
@@ -0,0 +1,64 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ category = @{type = 'str'; required = $true }
+ category_type = @{type = 'str'; required = $false; choices = @('LocalJob', 'MultiServerJob', 'None') }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$category = $module.Params.category
+$categoryType = $module.Params.category_type
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+try {
+ $agentJobCategorySplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Category = $category
+ EnableException = $true
+ }
+ if ($null -ne $categoryType) {
+ $agentJobCategorySplat.Add("CategoryType", $categoryType)
+ }
+ $existingCategory = Get-DbaAgentJobCategory @agentJobCategorySplat
+
+ if ($state -eq "present") {
+ # Create new job category
+ if ($null -eq $existingCategory) {
+ $output = New-DbaAgentJobCategory @agentJobCategorySplat -WhatIf:$checkMode
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "absent") {
+ if ($null -ne $existingCategory) {
+ $output = $existingCategory | Remove-DbaAgentJobCategory -WhatIf:$checkMode -EnableException -Confirm:$false
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error configuring SQL Agent job category.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.py
new file mode 100644
index 000000000..ce480c4cc
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_category.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: agent_job_category
+short_description: Configures a SQL Agent job category
+description:
+ - Configures a SQL Agent job category. Creates if it does not exist, else does nothing.
+version_added: 0.1.0
+options:
+ category:
+ description:
+ - Name of the category.
+ required: true
+ type: str
+ category_type:
+ description:
+ - The type of category.
+ required: false
+ type: str
+ choices: ['LocalJob', 'MultiServerJob', 'None']
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a maintenance job category
+ lowlydba.sqlserver.agent_job_category:
+ sql_instance: sql-01.myco.io
+ category: "Index Maintenance"
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaAgentJobCategory) or C(Remove-DbaAgentJobCategory) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.ps1
new file mode 100644
index 000000000..6681dcffd
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.ps1
@@ -0,0 +1,164 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ schedule = @{type = 'str'; required = $true }
+ job = @{type = 'str'; required = $true }
+ enabled = @{type = 'bool'; required = $false }
+ force = @{type = 'bool'; required = $false }
+ frequency_type = @{type = 'str'; required = $false
+ choices = @('Once', 'OneTime', 'Daily', 'Weekly', 'Monthly', 'MonthlyRelative', 'AgentStart', 'AutoStart', 'IdleComputer', 'OnIdle')
+ }
+ frequency_interval = @{type = 'str'; required = $false; }
+ frequency_subday_type = @{type = 'str'; required = $false; choices = @('Time', 'Seconds', 'Minutes', 'Hours') }
+ frequency_subday_interval = @{type = 'int'; required = $false }
+ frequency_relative_interval = @{type = 'str'; required = $false; choices = @('Unused', 'First', 'Second', 'Third', 'Fourth', 'Last') }
+ frequency_recurrence_factor = @{type = 'int'; required = $false }
+ start_date = @{type = 'str'; required = $false }
+ end_date = @{type = 'str'; required = $false }
+ start_time = @{type = 'str'; required = $false }
+ end_time = @{type = 'str'; required = $false }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$schedule = $module.Params.schedule
+$job = $module.Params.job
+[nullable[bool]]$enabled = $module.Params.enabled
+$force = $module.Params.force
+$frequencyType = $module.Params.frequency_type
+$frequencyInterval = $module.Params.frequency_interval
+$frequencySubdayType = $module.Params.frequency_subday_type
+[nullable[int]]$frequencySubdayInterval = $module.Params.frequency_subday_interval
+$frequencyRelativeInterval = $module.Params.frequency_relative_interval
+[nullable[int]]$frequencyRecurrenceFactor = $module.Params.frequency_recurrence_factor
+$startDate = $module.Params.start_date
+$endDate = $module.Params.end_date
+$startTime = $module.Params.start_time
+$endTime = $module.Params.end_time
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+$scheduleParams = @{
+ SqlInstance = $SqlInstance
+ SqlCredential = $sqlCredential
+ Force = $force
+ Schedule = $schedule
+}
+
+if ($enabled -eq $false) {
+ $scheduleParams.add("Disabled", $true)
+}
+if ($null -ne $job) {
+ $scheduleParams.add("Job", $job)
+}
+if ($null -ne $startDate) {
+ $scheduleParams.add("StartDate", $startDate)
+}
+if ($null -ne $endDate) {
+ $scheduleParams.add("EndDate", $endDate)
+}
+if ($null -ne $startTime) {
+ $scheduleParams.add("StartTime", $startTime)
+}
+if ($null -ne $endTime) {
+ $scheduleParams.add("EndTime", $endTime)
+}
+if ($null -ne $frequencyType) {
+ $scheduleParams.add("FrequencyType", $frequencyType)
+}
+if ($null -ne $frequencyInterval) {
+ $scheduleParams.add("FrequencyInterval", $frequencyInterval)
+}
+if ($null -ne $frequencySubdayType) {
+ $scheduleParams.add("FrequencySubdayType", $frequencySubdayType)
+}
+if ($null -ne $frequencySubdayInterval) {
+ $scheduleParams.add("FrequencySubdayInterval", $frequencySubdayInterval)
+}
+if ($null -ne $frequencyRelativeInterval) {
+ $scheduleParams.add("FrequencyRelativeInterval", $frequencyRelativeInterval)
+}
+if ($null -ne $frequencyRecurrenceFactor) {
+ $scheduleParams.add("FrequencyRecurrenceFactor", $frequencyRecurrenceFactor)
+}
+
+try {
+ $existingSchedule = Get-DbaAgentSchedule -SqlInstance $SqlInstance -SqlCredential $sqlCredential -Schedule $schedule
+ if ($state -eq "present") {
+ if ($enabled -eq $true) {
+ $scheduleParams.Add("Enabled", $true)
+ }
+ # Update schedule
+ if ($null -ne $existingSchedule) {
+ # Need to serialize to prevent SMO auto refreshing
+ $old = ConvertTo-SerializableObject -InputObject $existingSchedule -UseDefaultProperty $false
+ $output = Set-DbaAgentSchedule @scheduleParams
+ if ($null -ne $output) {
+ $compareProperty = @(
+ "ActiveEndDate"
+ "ActiveEndTimeOfDay"
+ "ActiveEndTimeOfDay"
+ "ActiveStartTimeOfDay"
+ "Description"
+ "FrequencyInterval"
+ "FrequencyRecurrenceFactor"
+ "FrequencyRelativeIntervals"
+ "FrequencySubDayInterval"
+ "FrequencySubDayTypes"
+ "FrequencyTypes"
+ "IsEnabled"
+ "ScheduleName"
+ )
+ $diff = Compare-Object -ReferenceObject $output -DifferenceObject $old -Property $compareProperty
+
+ # # Check if schedule was actually changed
+ # $modifiedSchedule = Get-DbaAgentSchedule -SqlInstance $SqlInstance -SqlCredential $sqlCredential -Schedule $ScheduleName -EnableException
+ # $scheduleDiff = Compare-Object -ReferenceObject $existingSchedule -DifferenceObject $modifiedSchedule
+ if ($diff -or $checkMode) {
+ $module.Result.changed = $true
+ }
+ }
+ }
+ # Create schedule
+ else {
+ $output = New-DbaAgentSchedule @scheduleParams
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "absent") {
+ # Nothing to remove
+ if ($null -eq $existingSchedule) {
+ $module.ExitJson()
+ }
+ # Remove schedule
+ else {
+ $output = $existingSchedule | Remove-DbaAgentSchedule -Force
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error configuring SQL Agent job schedule.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.py
new file mode 100644
index 000000000..008efca2a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_schedule.py
@@ -0,0 +1,142 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: agent_job_schedule
+short_description: Configures a SQL Agent job schedule
+description:
+ - Configures settings for an agent schedule that can be applied to one or more agent jobs.
+version_added: 0.1.0
+options:
+ schedule:
+ description:
+ - The name of the schedule.
+ type: str
+ required: true
+ job:
+ description:
+ - The name of the job that has the schedule.
+ - Schedules and jobs can also be associated via M(lowlydba.sqlserver.agent_job).
+ - See U(https://docs.dbatools.io/New-DbaAgentSchedule) for more detailed usage.
+ type: str
+ required: true
+ enabled:
+ description:
+ - Whether the schedule is enabled or disabled.
+ type: bool
+ required: false
+ force:
+ description:
+ - The force option will ignore some errors in the options and assume defaults.
+ - It will also remove the any present schedules with the same name for the specific job.
+ type: bool
+ frequency_type:
+ description:
+ - A value indicating when a job is to be executed.
+ - If I(force=true) the default will be C(Once).
+ type: str
+ required: false
+ choices: ['Once', 'OneTime', 'Daily', 'Weekly', 'Monthly', 'MonthlyRelative', 'AgentStart', 'AutoStart', 'IdleComputer', 'OnIdle']
+ frequency_interval:
+ description:
+ - The days that a job is executed.
+ - Allowed values for I(frequency_type=Daily) - C(EveryDay) or a number between C(1) and C(365) inclusive.
+ - >-
+ Allowed values for I(frequency_type=Weekly) -
+ C(Sunday), C(Monday), C(Tuesday), C(Wednesday), C(Thursday), C(Friday), C(Saturday),
+ C(Weekdays), C(Weekend) or C(EveryDay).
+ - Allowed values for I(frequency_type=Monthly) - Numbers C(1) through C(31) for each day of the month.
+ - If C(Weekdays), C(Weekend) or C(EveryDay) is used it overwrites any other value that has been passed before.
+ - If I(force=true) the default will be C(1).
+ type: str
+ required: false
+ frequency_subday_type:
+ description:
+ - Specifies the units for the subday I(frequency_interval).
+ type: str
+ required: false
+ choices: ['Time', 'Seconds', 'Minutes', 'Hours']
+ frequency_subday_interval:
+ description:
+ - The number of subday type periods to occur between each execution of a job.
+ type: int
+ required: false
+ frequency_relative_interval:
+ description:
+ - A job's occurrence of I(frequency_interval) in each month. If I(frequency_interval=32) (C(MonthlyRelative)).
+ type: str
+ required: false
+ choices: ['Unused', 'First', 'Second', 'Third', 'Fourth', 'Last']
+ frequency_recurrence_factor:
+ description:
+ - The number of weeks or months between the scheduled execution of a job.
+ - Required if I(frequency_type=Weekly), I(frequency_type=Monthly) or I(frequency_type=MonthlyRelative).
+ type: int
+ required: false
+ start_date:
+ description:
+ - The date on which execution of a job can begin.
+ - If I(force=true)the start date will be the current day.
+ - Format is C(YYYY-MM-DD).
+ type: str
+ required: false
+ end_date:
+ description:
+ - The date on which execution of a job can stop.
+ - If I(force=true) the end date will be C(9999-12-31).
+ - Format is C(YYYY-MM-DD).
+ type: str
+ required: false
+ start_time:
+ description:
+ - The time on any day to begin execution of a job. Format C(HHMMSS) (24 hour clock).
+ - If I(force=true) the start time will be C(00:00:00).
+ type: str
+ required: false
+ end_time:
+ description:
+ - The time on any day to end execution of a job. Format C(HHMMSS) (24 hour clock).
+ - If (force=true) the start time will be C(23:59:59).
+ type: str
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a job schedule
+ lowlydba.sqlserver.agent_job_schedule:
+ sql_instance: sql-01.myco.io
+ schedule: DailySchedule
+ force: true
+ enabled: true
+ start_date: 2020-05-25 # May 25, 2020
+ end_date: 2099-05-25 # May 25, 2099
+ start_time: 010500 # 01:05:00 AM
+ end_time: 140030 # 02:00:30 PM
+ state: present
+
+- name: Create a job with schedule
+ lowlydba.sqlserver.agent_job:
+ sql_instance: sql-01.myco.io
+ job: MyJob
+ force: true
+ schedule: DailySchedule
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaAgentJobSchedule) or C(Remove-DbaAgentJobSchedule) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.ps1
new file mode 100644
index 000000000..1bbbeb2e1
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.ps1
@@ -0,0 +1,157 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ job = @{type = 'str'; required = $true }
+ step_id = @{type = 'int'; required = $false }
+ step_name = @{type = 'str'; required = $false }
+ database = @{type = 'str'; required = $false; default = 'master' }
+ subsystem = @{type = 'str'; required = $false; default = 'TransactSql'
+ choices = @('CmdExec', 'Distribution', 'LogReader', 'Merge', 'PowerShell', 'QueueReader', 'Snapshot', 'Ssis', 'TransactSql')
+ }
+ command = @{type = 'str'; required = $false }
+ on_success_action = @{type = 'str'; required = $false; default = 'QuitWithSuccess'
+ choices = @('QuitWithSuccess', 'QuitWithFailure', 'GoToNextStep', 'GoToStep')
+ }
+ on_success_step_id = @{type = 'int'; required = $false; default = 0 }
+ on_fail_action = @{type = 'str'; required = $false; default = 'QuitWithFailure'
+ choices = @('QuitWithSuccess', 'QuitWithFailure', 'GoToNextStep', 'GoToStep')
+ }
+ on_fail_step_id = @{type = 'int'; required = $false; default = 0 }
+ retry_attempts = @{type = 'int'; required = $false; default = 0 }
+ retry_interval = @{type = 'int'; required = $false; default = 0 }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+ required_together = @(
+ , @('retry_attempts', 'retry_interval')
+ )
+ required_one_of = @(
+ , @('step_id', 'step_name')
+ )
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$job = $module.Params.job
+$stepId = $module.Params.step_id
+$stepName = $module.Params.step_name
+$database = $module.Params.database
+$subsystem = $module.Params.subsystem
+$command = $module.Params.command
+$onSuccessAction = $module.Params.on_success_action
+[nullable[int]]$onSuccessStepId = $module.Params.on_success_step_id
+$onFailAction = $module.Params.on_fail_action
+[nullable[int]]$onFailStepId = $module.Params.on_fail_step_id
+[int]$retryAttempts = $module.Params.retry_attempts
+[nullable[int]]$retryInterval = $module.Params.retry_interval
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+# Configure Agent job step
+try {
+ $existingJobSteps = Get-DbaAgentJobStep -SqlInstance $SqlInstance -SqlCredential $sqlCredential -Job $job
+ $existingJobStep = $existingJobSteps | Where-Object Name -eq $stepName
+
+ if ($state -eq "absent") {
+ if ($null -eq $existingJobStep) {
+ # try fetching name by id if we only care about removing
+ $existingJobStep = $existingJobSteps | Where-Object Id -eq $stepId
+ $stepName = $existingJobStep.Name
+ }
+ if ($existingJobStep) {
+ $removeStepSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Job = $job
+ StepName = $stepName
+ }
+ $output = Remove-DbaAgentJobStep @removeStepSplat
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "present") {
+ if (!($stepName) -or !($stepId)) {
+ $module.FailJson("Step name must be specified when state=present.")
+ }
+ $jobStepParams = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Job = $job
+ StepName = $stepName
+ Database = $database
+ SubSystem = $subsystem
+ OnSuccessAction = $onSuccessAction
+ OnSuccessStepId = $onSuccessStepId
+ OnFailAction = $onFailAction
+ OnFailStepId = $onFailStepId
+ RetryAttempts = $retryAttempts
+ RetryInterval = $retryInterval
+ WhatIf = $checkMode
+ }
+ if ($null -ne $command) {
+ $jobStepParams.Add("Command", $command)
+ }
+
+ # No existing job step
+ if ($null -eq $existingJobStep) {
+ $jobStepParams.Add("StepId", $stepId)
+ $output = New-DbaAgentJobStep @jobStepParams
+ $module.Result.changed = $true
+ }
+ # Update existing
+ else {
+ # Validate step name isn't taken already - must be unique within a job
+ if ($existingJobStep.Name -eq $StepName -and $existingJobStep.ID -ne $stepId) {
+ $module.FailJson("There is already a step named '$StepName' for this job with an ID of $($existingJobStep.ID).")
+ }
+
+ # Reference by old name in case new name differs for step id
+ $jobStepParams.StepName = $existingJobStep.Name
+ $jobStepParams.Add("NewName", $StepName)
+
+ # Need to serialize to prevent SMO auto refreshing
+ $old = ConvertTo-SerializableObject -InputObject $existingJobStep -UseDefaultProperty $false
+ $output = Set-DbaAgentJobStep @jobStepParams
+ if ($null -ne $output) {
+ $compareProperty = @(
+ "Name"
+ "DatabaseName"
+ "Command"
+ "Subsystem"
+ "OnFailAction"
+ "OnFailActionStep"
+ "OnSuccessAction"
+ "OnSuccessActionStep"
+ "RetryAttempts"
+ "RetryInterval"
+ )
+ $diff = Compare-Object -ReferenceObject $output -DifferenceObject $old -Property $compareProperty
+ }
+ if ($diff -or $checkMode) {
+ $module.Result.changed = $true
+ }
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error configuring SQL Agent job step.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.py
new file mode 100644
index 000000000..1e3e9891a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/agent_job_step.py
@@ -0,0 +1,118 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: agent_job_step
+short_description: Configures a SQL Agent job step
+description:
+ - Configures a step for an agent job.
+version_added: 0.1.0
+options:
+ job:
+ description:
+ - The name of the job to which to add the step.
+ required: true
+ type: str
+ step_id:
+ description:
+ - The sequence identification number for the job step. Step identification numbers start at C(1) and increment without gaps.
+ - Required if I(state=present).
+ required: false
+ type: int
+ step_name:
+ description:
+ - The name of the step. Required if I(state=present).
+ required: false
+ type: str
+ database:
+ description:
+ - The name of the database in which to execute a Transact-SQL step.
+ required: false
+ type: str
+ default: 'master'
+ subsystem:
+ description:
+ - The subsystem used by the SQL Server Agent service to execute command.
+ required: false
+ type: str
+ default: 'TransactSql'
+ choices: ['CmdExec', 'Distribution', 'LogReader', 'Merge', 'PowerShell', 'QueueReader', 'Snapshot', 'Ssis', 'TransactSql']
+ command:
+ description:
+ - The commands to be executed by SQLServerAgent service through subsystem.
+ required: false
+ type: str
+ on_success_action:
+ description:
+ - The action to perform if the step succeeds.
+ required: false
+ type: str
+ default: 'QuitWithSuccess'
+ choices: ['QuitWithSuccess', 'QuitWithFailure', 'GoToNextStep', 'GoToStep']
+ on_success_step_id:
+ description:
+ - The ID of the step in this job to execute if the step succeeds and I(on_success_action=GoToStep).
+ required: false
+ type: int
+ default: 0
+ on_fail_action:
+ description:
+ - The action to perform if the step fails.
+ required: false
+ type: str
+ default: 'QuitWithFailure'
+ choices: ['QuitWithSuccess', 'QuitWithFailure', 'GoToNextStep', 'GoToStep']
+ on_fail_step_id:
+ description:
+ - The ID of the step in this job to execute if the step fails and I(on_fail_action=GoToStep).
+ required: false
+ type: int
+ default: 0
+ retry_attempts:
+ description:
+ - The number of retry attempts to use if this step fails. The default is C(0).
+ required: false
+ type: int
+ default: 0
+ retry_interval:
+ description:
+ - The amount of time in minutes between retry attempts.
+ required: false
+ type: int
+ default: 0
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a job
+ lowlydba.sqlserver.agent_job:
+ sql_instance: sql-01.myco.io
+ job: MyJob
+ force: true
+
+- name: Create a job step
+ lowlydba.sqlserver.agent_job_step:
+ sql_instance: sql-01.myco.io
+ job: MyJob
+ step_name: Step1
+ step_id: 1
+ command: "TRUNCATE TABLE dbo.TestData;"
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaAgentJobStep), C(Set-DbaAgentJobStep), or C(Remove-DbaAgentJobStep) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.ps1
new file mode 100644
index 000000000..177a6d109
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.ps1
@@ -0,0 +1,235 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ sql_instance_secondary = @{type = "str"; required = $false }
+ sql_username_secondary = @{type = 'str'; required = $false }
+ sql_password_secondary = @{type = 'str'; required = $false; no_log = $true }
+ database = @{type = "str"; required = $false; aliases = @('database_name') }
+ ag_name = @{type = "str"; required = $true }
+ all_ags = @{type = "bool"; required = $false; }
+ shared_path = @{type = "str"; required = $false; default = $null }
+ dtc_support_enabled = @{type = "bool"; required = $false; }
+ basic_availability_group = @{type = "bool"; required = $false; }
+ database_health_trigger = @{type = "bool"; required = $false; }
+ is_distributed_ag = @{type = "bool"; required = $false; }
+ use_last_backup = @{type = "bool"; required = $false; }
+ healthcheck_timeout = @{type = "int"; required = $false; }
+ availability_mode = @{
+ type = "str"
+ required = $false
+ default = "SynchronousCommit"
+ choices = @("SynchronousCommit", "AsynchronousCommit")
+ }
+ failure_condition_level = @{
+ type = "str"
+ required = $false
+ choices = @(
+ "OnAnyQualifiedFailureCondition",
+ "OnCriticalServerErrors",
+ "OnModerateServerErrors",
+ "OnServerDown",
+ "OnServerUnresponsive"
+ )
+ }
+ failover_mode = @{
+ type = "str"
+ required = $false
+ default = "Automatic"
+ choices = @("Manual", "Automatic")
+ }
+ seeding_mode = @{
+ type = "str"
+ required = $false
+ default = "Manual"
+ choices = @("Manual", "Automatic")
+ }
+ automated_backup_preference = @{
+ type = "str"
+ required = $false
+ default = "Secondary"
+ choices = @("None", "Primary", "Secondary", "SecondaryOnly")
+ }
+ cluster_type = @{
+ type = "str"
+ required = $false
+ default = "Wsfc"
+ choices = @("Wsfc", "External", "None")
+ }
+ allow_null_backup = @{type = "bool"; required = $false }
+ force = @{type = "bool"; required = $false }
+ state = @{type = "str"; required = $false; default = "present"; choices = @("present", "absent") }
+ }
+ required_together = @(
+ , @('sql_username_secondary', 'sql_password_secondary')
+ )
+}
+
+# Setup var
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$ProgressPreference = "SilentlyContinue"
+
+# Var
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$secondary = $module.Params.sql_instance_secondary
+if ($null -ne $module.Params.sql_username_secondary) {
+ [securestring]$secondarySecPassword = ConvertTo-SecureString $Module.Params.sql_password_secondary -AsPlainText -Force
+ [pscredential]$secondarySqlCredential = New-Object System.Management.Automation.PSCredential ($Module.Params.sql_username_secondary, $secondarySecPassword)
+}
+$agName = $module.Params.ag_name
+$database = $module.Params.database
+$seedingMode = $module.Params.seeding_mode
+$sharedPath = $module.Params.shared_path
+$healthCheckTimeout = $module.Params.healthcheck_timeout
+$availabilityMode = $module.Params.availability_mode
+$failureConditionLevel = $module.Params.failure_condition_level
+$failoverMode = $module.Params.failover_mode
+$automatedBackupPreference = $module.Params.automated_backup_preference
+$clusterType = $module.Params.cluster_type
+$state = $module.Params.state
+[nullable[bool]]$all_ags = $module.Params.all_ags
+[nullable[bool]]$useLastBackup = $module.Params.use_last_backup
+[nullable[bool]]$dtcSupportEnabled = $module.Params.dtc_support_enabled
+[nullable[bool]]$basicAvailabilityGroup = $module.Params.basic_availability_group
+[nullable[bool]]$databaseHealthTrigger = $module.Params.database_health_trigger
+[nullable[bool]]$isDistributedAg = $module.Params.is_distributed_ag
+[nullable[bool]]$force = $module.Params.force
+[nullable[bool]]$allowNullBackup = $module.Params.allow_null_backup
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $existingAG = Get-DbaAvailabilityGroup -SqlInstance $sqlInstance -SqlCredential $sqlCredential -AvailabilityGroup $agName
+
+ if ($state -eq "present") {
+ $agSplat = @{
+ Primary = $sqlInstance
+ PrimarySqlCredential = $sqlCredential
+ Name = $agName
+ SeedingMode = $seedingMode
+ FailoverMode = $failoverMode
+ AvailabilityMode = $availabilityMode
+ AutomatedBackupPreference = $automatedBackupPreference
+ ClusterType = $clusterType
+ }
+ if ($null -ne $sharedPath -and $seedingMode -eq "Manual") {
+ $agSplat.Add("SharedPath", $sharedPath)
+ }
+ if ($useLastBackup -eq $true) {
+ $agSplat.Add("UseLastBackup", $useLastBackup)
+ }
+ if ($dtcSupportEnabled -eq $true) {
+ $agSplat.Add("DtcSupport", $dtcSupportEnabled)
+ }
+ if ($basicAvailabilityGroup -eq $true) {
+ $agSplat.Add("Basic", $basicAvailabilityGroup)
+ }
+ if ($databaseHealthTrigger -eq $true) {
+ $agSplat.Add("DatabaseHealthTrigger", $databaseHealthTrigger)
+ }
+ if ($null -ne $healthCheckTimeout) {
+ $agSplat.Add("HealthCheckTimeout", $healthCheckTimeout)
+ }
+ if ($null -ne $failureConditionLevel) {
+ $agSplat.Add("FailureConditionLevel", $failureConditionLevel)
+ }
+ if ($null -ne $database) {
+ $agSplat.Add("Database", $database)
+ }
+ if ($null -ne $secondary) {
+ $agSplat.Add("Secondary", $secondary)
+ }
+ if ($null -ne $secondarySqlCredential) {
+ $agSplat.Add("SecondarySqlCredential", $secondarySqlCredential)
+ }
+ if ($force -eq $true) {
+ $agSplat.Add("Force", $force)
+ }
+
+ # Create the AG with initial replica(s)
+ if ($null -eq $existingAG) {
+ # Full backup requirement for new AG via automatic seeding
+ if ($seedingMode -eq "automatic" -and $null -ne $database) {
+ $dbBackup = Get-DbaLastBackup -SqlInstance $sqlInstance -SqlCredential $sqlCredential -Database $database
+ if ($null -eq $dbBackup.LastFullBackup -and $allowNullBackup -eq $true) {
+ $backupSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ FilePath = "NUL"
+ Type = "Full"
+ }
+ $null = Backup-DbaDatabase @backupSplat
+ }
+ }
+ $output = New-DbaAvailabilityGroup @agSplat
+ $module.Result.changed = $true
+ }
+ # Configure existing AG
+ else {
+ $setAgSplat = @{
+ AutomatedBackupPreference = $automatedBackupPreference
+ ClusterType = $clusterType
+ }
+ if ($all_ags -eq $true) {
+ $setAgSplat.Add("AllAvailabilityGroups", $all_ags)
+ }
+ if ($dtcSupportEnabled -eq $true) {
+ $setAgSplat.Add("DtcSupportEnabled", $dtcSupportEnabled)
+ }
+ if ($basicAvailabilityGroup -eq $true) {
+ $setAgSplat.Add("BasicAvailabilityGroup", $basicAvailabilityGroup)
+ }
+ if ($databaseHealthTrigger -eq $true) {
+ $setAgSplat.Add("DatabaseHealthTrigger", $databaseHealthTrigger)
+ }
+ if ($null -ne $failureConditionLevel) {
+ $setAgSplat.Add("FailureConditionLevel", $failureConditionLevel)
+ }
+ if ($null -ne $healthCheckTimeout) {
+ $setAgSplat.Add("HealthCheckTimeout", $healthCheckTimeout)
+ }
+ if ($isDistributedAg -eq $true) {
+ $setAgSplat.Add("IsDistributedAvailabilityGroup", $isDistributedAg)
+ }
+ $compareProperty = ($existingAG.Properties | Where-Object Name -in $setAgSplat.Keys).Name
+ $agDiff = Compare-Object -ReferenceObject $existingAG -DifferenceObject $setAgSplat -Property $compareProperty
+ if ($null -ne $agDiff) {
+ $output = $existingAG | Set-DbaAvailabilityGroup @setAgSplat
+ $module.Result.changed = $true
+ }
+ }
+ }
+ elseif ($state -eq "absent") {
+ if ($null -ne $existingAG) {
+ if ($all_ags -eq $true) {
+ $existingAG | Remove-DbaAvailabilityGroup -AllAvailabilityGroups
+ }
+ else {
+ $existingAG | Remove-DbaAvailabilityGroup
+ }
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring Availability Group failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.py
new file mode 100644
index 000000000..15f78191a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/availability_group.py
@@ -0,0 +1,157 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: availability_group
+short_description: Configures availability group(s)
+description:
+ - Configures SQL Server Availability Group(s) with up to one replica.
+version_added: 0.4.0
+options:
+ sql_instance_secondary:
+ description:
+ - The secondary SQL Server instance for the new Availability Group.
+ type: str
+ required: false
+ sql_username_secondary:
+ description:
+ - Username for SQL Authentication for the secondary replica.
+ type: str
+ required: false
+ sql_password_secondary:
+ description:
+ - Password for SQL Authentication for the secondary replica.
+ type: str
+ required: false
+ database:
+ description:
+ - Name of the database to create the Availability Group for.
+ type: str
+ required: false
+ aliases:
+ - database_name
+ ag_name:
+ description:
+ - Name of the Availability Group.
+ type: str
+ required: true
+ all_ags:
+ description:
+ - Apply changes to all availability groups on the instance. Only used for configuring existing availability groups.
+ type: bool
+ required: false
+ shared_path:
+ description:
+ - The network share where the backups will be backed up and restored from.
+ type: str
+ required: false
+ dtc_support_enabled:
+ description:
+ - Enables Dtc support.
+ type: bool
+ required: false
+ basic_availability_group:
+ description:
+ - Indicates whether the availability group is Basic Availability Group.
+ type: bool
+ required: false
+ database_health_trigger:
+ description:
+ - Indicates whether the availability group triggers the database health.
+ type: bool
+ required: false
+ is_distributed_ag:
+ description:
+ - Indicates whether the availability group is distributed.
+ type: bool
+ required: false
+ healthcheck_timeout:
+ description:
+ - This setting used to specify the length of time, in milliseconds,
+ that the SQL Server resource DLL should wait for information returned by the C(sp_server_diagnostics)
+ stored procedure before reporting the Always On Failover Cluster Instance (FCI) as unresponsive.
+ - Changes that are made to the timeout settings are effective immediately and do not require a restart of the SQL Server resource.
+ type: int
+ required: false
+ failure_condition_level:
+ description:
+ - Specifies the different conditions that can trigger an automatic failover in Availability Group.
+ type: str
+ required: false
+ choices: ['OnAnyQualifiedFailureCondition', 'OnCriticalServerErrors', 'OnModerateServerErrors', 'OnServerDown', 'OnServerUnresponsive']
+ cluster_type:
+ description:
+ - Cluster type of the Availability Group. Only supported in SQL Server 2017 and above.
+ type: str
+ required: false
+ default: 'Wsfc'
+ choices: ['Wsfc', 'External', 'None']
+ failover_mode:
+ description:
+ - Whether the replica have Automatic or Manual failover.
+ type: str
+ required: false
+ default: 'Automatic'
+ choices: ['Automatic', 'Manual']
+ availability_mode:
+ description:
+ - Whether the replica should be Asynchronous or Synchronous.
+ - Only used in creating a new availability group.
+ type: str
+ required: false
+ default: 'SynchronousCommit'
+ choices: ['AsynchronousCommit', 'SynchronousCommit']
+ seeding_mode:
+ description:
+ - Default seeding mode for the replica. Should remain as the default otherwise manual setup may be required.
+ type: str
+ required: false
+ default: 'Manual'
+ choices: ['Automatic', 'Manual']
+ automated_backup_preference:
+ description:
+ - How to handle backup requests by default.
+ type: str
+ required: false
+ default: 'Secondary'
+ choices: ['None', 'Primary', 'Secondary', 'SecondaryOnly']
+ allow_null_backup:
+ description:
+ - Allow taking a full backup to C(NULL) if one does not exist and I(seeding_mode=Automatic).
+ type: bool
+ required: false
+ force:
+ description:
+ - Drop and recreate the database on remote servers using fresh backup.
+ type: bool
+ use_last_backup:
+ description:
+ - Use the last full and log backup of database. A log backup must be the last backup.
+ type: bool
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create Availability Group
+ lowlydba.sqlserver.availability_group:
+ sql_instance: sql-01.myco.io
+ ag_name: AG_MyDatabase
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaAvailabilityGroup) or C(Set-DbaAvailabilityGroup) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/backup.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/backup.ps1
new file mode 100644
index 000000000..163d45036
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/backup.ps1
@@ -0,0 +1,138 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ database = @{type = 'str'; required = $true }
+ path = @{type = 'str'; required = $false }
+ file_path = @{type = 'str'; required = $false }
+ increment_prefix = @{type = 'bool'; required = $false; default = $false }
+ replace_in_name = @{type = 'bool'; required = $false; default = $false }
+ copy_only = @{type = 'bool'; required = $false; default = $false }
+ type = @{type = 'str'; required = $false; default = 'database'; choices = @('full', 'log', 'differential', 'diff', 'database') }
+ timestamp_format = @{type = 'str'; required = $false }
+ encryption_certificate = @{type = 'str'; required = $false }
+ encryption_algorithm = @{type = 'str'; required = $false; choices = @('AES128', 'AES192', 'AES256', 'TRIPLEDES') }
+ create_folder = @{type = 'bool'; required = $false; default = $false }
+ file_count = @{type = 'int'; required = $false; default = 0 }
+ compress = @{type = 'bool'; required = $false; default = $false }
+ checksum = @{type = 'bool'; required = $false; default = $false }
+ verify = @{type = 'bool'; required = $false; default = $false }
+ no_recovery = @{type = 'bool'; required = $false; default = $false }
+ build_path = @{type = 'bool'; required = $false; default = $false }
+ max_transfer_size = @{type = 'int'; required = $false; default = 0 }
+ with_format = @{type = 'bool'; required = $false; default = $false }
+ initialize = @{type = 'bool'; required = $false; default = $false }
+ ignore_file_checks = @{type = 'bool'; required = $false; default = $false }
+ block_size = @{type = 'str'; required = $false; choices = @('0.5kb', '1kb', '2kb', '4kb', '8kb', '16kb', '32kb', '64kb') }
+ buffer_count = @{type = 'int'; required = $false; default = 0 }
+ azure_base_url = @{type = 'str'; required = $false }
+ azure_credential = @{type = 'str'; required = $false }
+ }
+ mutually_exclusive = @(
+ , @('path', 'azure_base_url')
+ )
+ required_together = @(
+ , @('encryption_algorithm', 'encryption_certificate')
+ )
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$path = $module.Params.path
+$filePath = $module.Params.file_path
+$incrementPrefix = $module.Params.increment_prefix
+$replaceInName = $module.Params.replace_in_name
+$copyOnly = $module.Params.copy_only
+$type = $module.Params.type
+$createFolder = $module.Params.create_folder
+$fileCount = $module.Params.file_count
+$compressBackup = $module.Params.compress_backup
+$checkSum = $module.Params.checksum
+$verify = $module.Params.verify
+$maxTransferSize = $module.Params.max_transfer_size
+$blockSize = $module.Params.block_size
+$bufferCount = $module.Params.buffer_count
+$noRecovery = $module.Params.no_recovery
+$buildPath = $module.Params.build_path
+$withFormat = $module.Params.with_format
+$initialize = $module.Params.initialize
+$timestampFormat = $module.Params.timestamp_format
+$ignoreFileChecks = $module.Params.ignore_file_checks
+$encryptionAlgorithm = $module.Params.encryption_algorithm
+$encryptionCertificate = $modules.Params.encryption_certificate
+$azureBaseUrl = $modules.Params.azure_base_url
+$azureCredential = $modules.Param.azure_credential
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $backupSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ IncrementPrefix = $incrementPrefix
+ ReplaceInName = $replaceInName
+ CopyOnly = $copyOnly
+ Type = $type
+ CreateFolder = $createFolder
+ FileCount = $fileCount
+ CompressBackup = $compressBackup
+ Checksum = $checkSum
+ Verify = $verify
+ MaxTransferSize = $maxTransferSize
+ BufferCount = $bufferCount
+ NoRecovery = $noRecovery
+ BuildPath = $buildPath
+ WithFormat = $withFormat
+ Initialize = $initialize
+ IgnoreFileChecks = $ignoreFileChecks
+ }
+ if ($null -ne $path) {
+ $backupSplat.Add("Path", $path)
+ }
+ if ($null -ne $filePath) {
+ $backupSplat.Add("FilePath", $filePath)
+ }
+ if ($null -ne $blockSize) {
+ $backupSplat.Add("BlockSize", ($blockSize / 1))
+ }
+ if ($null -ne $timestampFormat) {
+ $backupSplat.Add("TimestampFormat", $timestampFormat)
+ }
+ if ($null -ne $encryptionAlgorithm) {
+ $backupSplat.Add("EncryptionAlgorithm", $encryptionAlgorithm)
+ }
+ if ($null -ne $encryptionCertificate) {
+ $backupSplat.Add("EncryptionCertificate", $encryptionCertificate)
+ }
+ if ($null -ne $azureBaseUrl) {
+ $backupSplat.Add("AzureBaseURL", $azureBaseUrl)
+ }
+ if ($null -ne $azureCredential) {
+ $backupSplat.Add("AzureCredential", $azureCredential)
+ }
+ $output = Backup-DbaDatabase @backupSplat
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ $module.Result.changed = $true
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error backing up database: $($_.Exception.Message).", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/backup.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/backup.py
new file mode 100644
index 000000000..962b0cfcf
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/backup.py
@@ -0,0 +1,197 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: backup
+short_description: Performs a backup operation
+description:
+ - Performs any type of database backup operation.
+version_added: 0.8.0
+options:
+ database:
+ description:
+ - The database to process.
+ type: str
+ required: true
+ path:
+ description:
+ - Path in which to place the backup files.
+ - If not specified, the backups will be placed in the default backup location for SqlInstance.
+ type: str
+ required: false
+ file_path:
+ description:
+ - The name of the file to backup to.
+ - If no name is specified then the backup files will be named C(DatabaseName_yyyyMMddHHmm) (i.e. C(Database1_201714022131))
+ type: str
+ required: false
+ increment_prefix:
+ description:
+ - If set, this will prefix backup files with an incrementing integer (ie; C(1-), C(2-)).
+ - Using this has been alleged to improved restore times on some Azure based SQL Database platforms.
+ type: bool
+ required: false
+ default: false
+ replace_in_name:
+ description:
+ - If set, the following list of strings will be replaced in the FilePath and Path strings.
+ C(instancename) - will be replaced with the instance Name
+ C(servername) - will be replaced with the server name
+ C(dbname) - will be replaced with the database name
+ C(timestamp) - will be replaced with the timestamp (either the default, or the format provided)
+ C(backuptype) - will be replaced with C(Full), C(Log), or C(Differential) as appropriate
+ type: bool
+ required: false
+ default: false
+ copy_only:
+ description:
+ - The backup will be CopyOnly.
+ type: bool
+ required: false
+ default: false
+ type:
+ description:
+ - The type of backup to perform.
+ type: str
+ required: false
+ default: 'database'
+ choices: ['full', 'log', 'differential', 'diff', 'database']
+ create_folder:
+ description:
+ - If set, database is backed up to its own subfolder within the path.
+ type: bool
+ required: false
+ default: false
+ file_count:
+ description:
+ - The number of striped files to create the backup with.
+ type: int
+ required: false
+ default: 0
+ compress:
+ description:
+ - If set, use compression when creating the backup if it is supported by the version and edition.
+ type: bool
+ required: false
+ default: false
+ checksum:
+ description:
+ - If set, the backup checksum will be calculated.
+ type: bool
+ required: false
+ default: false
+ verify:
+ description:
+ - If set, the backup will be verified via C(RESTORE VERIFYONLY)
+ type: bool
+ required: false
+ default: false
+ max_transfer_size:
+ description:
+ - Sets the size of the unit of transfer. Values must be a multiple of 64kb.
+ type: int
+ required: false
+ default: 0
+ block_size:
+ description:
+ - Specifies block size to use.
+ type: str
+ required: false
+ choices: ['0.5kb','1kb','2kb','4kb','8kb','16kb','32kb','64kb']
+ buffer_count:
+ description:
+ - Number of I/O buffers to use.
+ type: int
+ required: false
+ default: 0
+ azure_base_url:
+ description:
+ - The URL to the base container of an Azure Storage account to write backups to.
+ type: str
+ required: false
+ azure_credential:
+ description:
+ - The name of the credential on the SQL instance that can write to the I(azure_base_url),
+ only needed if using Storage access keys If using SAS credentials, the command will look for a credential with a name matching the I(azure_base_url).
+ type: str
+ required: false
+ no_recovery:
+ description:
+ - If set, performs a tail log backup.
+ type: bool
+ required: false
+ default: false
+ build_path:
+ description:
+ - By default this command will not attempt to create missing paths, this switch will change the behaviour so that it will.
+ type: bool
+ required: false
+ default: false
+ with_format:
+ description:
+ - Formats the media as the first step of the backup operation.
+ type: bool
+ required: false
+ default: false
+ initialize:
+ description:
+ - Initializes the media as part of the backup operation.
+ type: bool
+ required: false
+ default: false
+ timestamp_format:
+ description:
+ - By default the command timestamps backups using the format C(yyyyMMddHHmm). Using this option this can be overridden.
+ type: str
+ required: false
+ ignore_file_checks:
+ description:
+ - If set, stops the function from checking path validity.
+ type: bool
+ required: false
+ default: false
+ encryption_algorithm:
+ description:
+ - Specifies the Encryption Algorithm to used.
+ type: str
+ required: false
+ choices: ['AES128','AES192','AES256','TRIPLEDES']
+ encryption_certificate:
+ description:
+ - The name of the certificate to be used to encrypt the backups.
+ type: str
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Create striped full database backup in default dir
+ lowlydba.sqlserver.backup:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB
+ type: full
+ file_count: 8
+
+- name: Create t-log backup
+ lowlydba.sqlserver.backup:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB
+ type: log
+'''
+
+RETURN = r'''
+data:
+ description: Modified output from the C(Backup-DbaDatabase) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/credential.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/credential.ps1
new file mode 100644
index 000000000..29631b11a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/credential.ps1
@@ -0,0 +1,117 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ identity = @{type = 'str'; required = $true }
+ name = @{type = 'str'; required = $false }
+ password = @{type = 'str'; required = $false; no_log = $true }
+ mapped_class_type = @{type = 'str'; required = $false; choices = @('CryptographicProvider', 'None') }
+ provider_name = @{type = 'str'; required = $false }
+ force = @{type = 'bool'; required = $false; default = $false }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$identity = $module.Params.identity
+$name = $module.Params.name
+if ($null -ne $module.Params.password) {
+ $secure_password = ConvertTo-SecureString -String $module.Params.password -AsPlainText -Force
+}
+$mapped_class_type = $module.Params.mapped_class_type
+$provider_name = $module.Params.provider_name
+$state = $module.Params.state
+$force = $module.Params.force
+$checkMode = $module.CheckMode
+
+$module.Result.changed = $false
+
+try {
+ $getCredendtialSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Identity = $identity
+ EnableException = $true
+ }
+ $existingCredential = Get-DbaCredential @getCredendtialSplat
+
+ if ($state -eq "absent") {
+ # Remove credential if it exists
+ if ($null -ne $existingCredential) {
+ try {
+ $removeCredentialSplat = @{
+ EnableException = $true
+ WhatIf = $checkMode
+ Confirm = $false
+ }
+ $output = $existingCredential | Remove-DbaCredential @removeCredentialSplat
+ $module.Result.changed = $true
+ }
+ catch {
+ $module.FailJson("Removing credential failed: $($_.Exception.Message)", $_)
+ }
+ }
+ }
+ elseif ($state -eq "present") {
+ # Create credential
+ if (($null -ne $existingCredential -and $force -eq $true) -or $null -eq $existingCredential) {
+ try {
+ $newCredentialSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Identity = $identity
+ EnableException = $true
+ WhatIf = $checkMode
+ Force = $force
+ Confirm = $false
+ }
+ if ($null -ne $name) {
+ $newCredentialSplat.Add("Name", $name)
+ }
+ if ($null -ne $secure_password) {
+ $newCredentialSplat.Add("SecurePassword", $secure_password)
+ }
+ if ($null -ne $mapped_class_type) {
+ $newCredentialSplat.Add("MappedClassType", $mapped_class_type)
+ }
+ if ($null -ne $provider_name) {
+ $newCredentialSplat.Add("ProviderName", $provider_name)
+ }
+ $output = New-DbaCredential @newCredentialSplat
+ $module.result.changed = $true
+ }
+ catch {
+ $module.FailJson("Creating credential failed: $($_.Exception.Message)", $_)
+ }
+ }
+ # Return existing credential if nothing is changed
+ elseif ($null -ne $existingCredential) {
+ $output = $existingCredential
+ }
+ }
+ try {
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+ }
+ catch {
+ $module.FailJson("Failure: $($_.Exception.Message)", $_)
+ }
+}
+catch {
+ $module.FailJson("Configuring credential failed: $($_.Exception.Message) ; $getCredendtialSplat", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/credential.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/credential.py
new file mode 100644
index 000000000..e83b8ed3c
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/credential.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: credential
+short_description: Configures a credential on a SQL server
+description:
+ - Creates, replaces, or removes a credential on a SQL server.
+version_added: 1.3.0
+options:
+ identity:
+ description:
+ - The Credential Identity.
+ type: str
+ required: true
+ name:
+ description:
+ - The Credential name.
+ type: str
+ required: false
+ password:
+ description:
+ - Password used to authenticate the Credential Identity.
+ type: str
+ required: false
+ mapped_class_type:
+ description:
+ - Sets the class associated with the credential.
+ type: str
+ required: false
+ choices: ['CryptographicProvider','None']
+ provider_name:
+ description:
+ - Specifies the cryptographic provider name for the Enterprise Key Management Provider.
+ type: str
+ required: false
+ force:
+ description:
+ - If this switch is enabled, the existing credential will be dropped and recreated.
+ type: bool
+ default: false
+author:
+ - "Joe Krilov (@Joey40)"
+ - "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a credential with a password
+ lowlydba.sqlserver.credential:
+ sql_instance: sql-01.myco.io
+ identity: ad\\user
+ name: MyCredential
+ password : <Password>
+
+- name: Replace an existing credential
+ lowlydba.sqlserver.credential:
+ sql_instance: sql-01.myco.io
+ identity: MyIdentity
+ force: true
+
+- name: Create a credential using a SAS token for a backup URL
+ lowlydba.sqlserver.credential:
+ sql_instance: sql-01.myco.io
+ identity: SHARED ACCESS SIGNATURE
+ name: https://<azure storage account name>.blob.core.windows.net/<blob container>
+ password : <Shared Access Token>
+
+- name: Remove a credential
+ lowlydba.sqlserver.credential:
+ sql_instance: sql-01.myco.io
+ identity: MyIdentity
+ state: absent
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaDbCredential), C(Get-DbaDbCredential), or C(Remove-DbaDbCredential) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/database.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/database.ps1
new file mode 100644
index 000000000..4c3e3c9d0
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/database.ps1
@@ -0,0 +1,242 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ database = @{type = 'str'; required = $true }
+ recovery_model = @{type = 'str'; required = $false; choices = @('Full', 'Simple', 'BulkLogged') }
+ data_file_path = @{type = 'str'; required = $false }
+ log_file_path = @{type = 'str'; required = $false }
+ owner = @{type = 'str'; required = $false; }
+ maxdop = @{type = 'int'; required = $false; }
+ secondary_maxdop = @{type = 'int'; required = $false; }
+ compatibility = @{type = 'str'; required = $false; }
+ rcsi = @{type = 'bool'; required = $false; }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$recoveryModel = $module.Params.recovery_model
+$dataFilePath = $module.Params.data_file_path
+$logFilePath = $module.Params.log_file_path
+$owner = $module.Params.owner
+$compatibility = $module.Params.compatibility
+[nullable[bool]]$rcsiEnabled = $module.Params.rcsi
+[nullable[int]]$maxDop = $module.Params.maxdop
+[nullable[int]]$secondaryMaxDop = $module.Params.secondary_maxdop
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+
+try {
+ # Get database status
+ try {
+ $server = Connect-DbaInstance -SqlInstance $sqlInstance -SqlCredential $sqlCredential
+ $getDatabaseSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ OnlyAccessible = $true
+ ExcludeSystem = $true
+ EnableException = $true
+ }
+ $existingDatabase = Get-DbaDatabase @getDatabaseSplat
+ $output = $existingDatabase
+ }
+ catch {
+ $module.FailJson("Error checking database status.", $_.Exception.Message)
+ }
+
+ if ($state -eq "absent") {
+ if ($null -ne $existingDatabase) {
+ $existingDatabase | Remove-DbaDatabase -WhatIf:$checkMode -EnableException -Confirm:$false
+ $module.Result.changed = $true
+ }
+ $module.ExitJson()
+ }
+ elseif ($state -eq "present") {
+ # Create database
+ if ($null -eq $existingDatabase) {
+ try {
+ $newDbParams = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ WhatIf = $checkMode
+ EnableException = $true
+ }
+ if ($null -ne $dataFilePath) {
+ $newDbParams.Add("DataFilePath", $dataFilePath)
+ }
+ if ($null -ne $logFilePath) {
+ $newDbParams.Add("LogFilePath", $logFilePath)
+ }
+ if ($null -ne $owner) {
+ $newDbParams.Add("Owner", $owner)
+ }
+ $output = New-DbaDatabase @newDbParams
+ $module.Result.changed = $true
+ }
+ catch {
+ $module.FailJson("Creating database [$database] failed.", $_)
+ }
+ }
+ # Set Owner
+ elseif ($null -ne $owner) {
+ try {
+ if ($existingDatabase.Owner -ne $owner) {
+ $setDbParams = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ TargetLogin = $owner
+ WhatIf = $checkMode
+ EnableException = $true
+ }
+ $null = Set-DbaDbOwner @setDbParams
+ $output = Get-DbaDatabase @getDatabaseSplat
+ $module.Result.changed = $true
+ }
+ }
+ catch {
+ $module.FailJson("Setting database owner for [$database] failed.", $_)
+ }
+ }
+
+ # Add non-standard fields to output
+ if ($null -ne $output) {
+ # Secondary MaxDop
+ [int]$existingSecondaryMaxDop = $server.Databases[$database].SecondaryMaxDop
+ $output | Add-Member -MemberType NoteProperty -Name "SecondaryMaxDop" -Value $existingSecondaryMaxDop
+ $output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("SecondaryMaxDop")
+
+ # MaxDop (exists, but is not in default display)
+ $existingMaxDop = $server.Databases[$database].MaxDop
+ $output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("MaxDop")
+
+ # RCSI
+ $existingRCSI = $server.Databases[$database].IsReadCommittedSnapshotOn
+ $output | Add-Member -MemberType NoteProperty -Name "RCSI" -Value $existingRCSI
+ $output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("RCSI")
+ }
+
+ # Recovery Model
+ if ($null -ne $recoveryModel) {
+ try {
+ if ($recoveryModel -ne $output.RecoveryModel) {
+ $recoveryModelSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ RecoveryModel = $recoveryModel
+ WhatIf = $checkMode
+ EnableException = $true
+ Confirm = $false
+ }
+ $null = Set-DbaDbRecoveryModel @recoveryModelSplat
+ $output.RecoveryModel = $recoveryModel
+ $module.Result.changed = $true
+ }
+ }
+ catch {
+ $module.FailJson("Setting recovery model for [$database] failed.", $_)
+ }
+ }
+
+ # Compatibility Mode
+ if ($null -ne $compatibility) {
+ try {
+ $existingCompatibility = $output.Compatibility
+ if ($compatibility -ne $existingCompatibility) {
+ $compatSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ Compatibility = $compatibility
+ WhatIf = $checkMode
+ EnableException = $true
+ }
+ $null = Set-DbaDbCompatibility @compatSplat
+ $output.Compatibility = $compatibility
+ $module.Result.changed = $true
+ }
+ }
+ catch {
+ $module.FailJson("Setting Compatibility for [$database] failed.", $_)
+ }
+ }
+
+ # RCSI
+ if ($null -ne $rcsiEnabled) {
+ try {
+ if ($rcsiEnabled -ne $existingRCSI) {
+ if (-not $checkMode) {
+ $server.Databases[$database].IsReadCommittedSnapshotOn = $rcsiEnabled
+ $server.Databases[$database].Alter()
+ $output.RCSI = $rcsiEnabled
+ }
+ $module.Result.changed = $true
+ }
+ }
+ catch {
+ $module.FailJson("Setting Read Commmitted Snapshot Isolation for [$database] failed.", $_)
+ }
+ }
+
+ # Configure MAXDOPs
+ ## Database Scoped MaxDop
+ if ($null -ne $MaxDop) {
+ try {
+ if ($MaxDop -ne $existingMaxDop) {
+ if (-not $checkMode) {
+ $server.Databases[$database].MaxDop = $maxDop
+ $server.Databases[$database].Alter()
+ $output.MaxDop = $MaxDOP
+ }
+ $module.Result.changed = $true
+ }
+ }
+ catch {
+ $module.FailJson("Setting MAXDOP for [$database] failed.", $_)
+ }
+ }
+
+ ## Secondary Mode MaxDop
+ if ($null -ne $secondaryMaxDOP) {
+ try {
+ if ($secondaryMaxDop -ne $existingSecondaryMaxDop) {
+ if (-not $checkMode) {
+ $server.Databases[$database].MaxDopForSecondary = $secondaryMaxDOP
+ $server.Databases[$database].Alter()
+ $output.SecondaryMaxDop = $secondaryMaxDop
+ }
+ $module.Result.changed = $true
+ }
+ }
+ catch {
+ $module.FailJson("Setting MaxDop for secondary mode failed.", $_)
+ }
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring database failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/database.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/database.py
new file mode 100644
index 000000000..97551c718
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/database.py
@@ -0,0 +1,94 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: database
+short_description: Creates and configures a database
+description:
+ - Adds a new database to an existing SQL Server instance.
+version_added: 0.1.0
+options:
+ database:
+ description:
+ - Name of the target database.
+ type: str
+ required: true
+ recovery_model:
+ description:
+ - Choose the recovery model for the database.
+ type: str
+ required: false
+ choices: ['Full', 'Simple', 'BulkLogged']
+ data_file_path:
+ description:
+ - Directory where the data files should be placed. Uses SQL Server's default if not supplied.
+ - Only used if database is being created.
+ type: str
+ required: false
+ log_file_path:
+ description:
+ - Directory where the log files should be placed. Uses SQL Server's default if not supplied.
+ - Only used if database is being created.
+ type: str
+ required: false
+ owner:
+ description:
+ - Database owner login.
+ type: str
+ required: false
+ maxdop:
+ description:
+ - MAXDOP value for the database.
+ required: false
+ type: int
+ secondary_maxdop:
+ description:
+ - MAXDOP value for the database when it is a non-primary replica in an availability group.
+ required: false
+ type: int
+ compatibility:
+ description:
+ - Compatibility mode for the database. Follows the format of C(Version90), C(Version100), and so on.
+ - String is validated by C(Set-DbaDbCompatibility).
+ required: false
+ type: str
+ rcsi:
+ description:
+ - Whether or not to enable Read Committed Snapshot Isolation.
+ required: false
+ type: bool
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create database
+ lowlydba.sqlserver.database:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB
+
+- name: Create database with customizations
+ lowlydba.sqlserver.database:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB
+ owner: sa
+ maxdop: 2
+ recovery_model: Simple
+'''
+
+RETURN = r'''
+data:
+ description: Modified output from the C(New-DbaDatabase), C(Set-DbaDatabase), or C(Remove-DbaDatabase) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.ps1
new file mode 100644
index 000000000..ef52bdd6d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.ps1
@@ -0,0 +1,65 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ branch = @{type = 'str'; required = $false; choices = @('master', 'development') }
+ local_file = @{type = 'str'; required = $false }
+ database = @{type = 'str'; required = $true }
+ force = @{type = 'bool'; required = $false; default = $false }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$branch = $module.Params.branch
+$localFile = $module.Params.local_file
+$force = $module.Params.force
+$checkMode = $module.Checkmode
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+$multiToolSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ Force = $force
+}
+if ($null -ne $localFile) {
+ $multiToolSplat.LocalFile = $localFile
+}
+if ($null -ne $branch) {
+ $multiToolSplat.Branch = $branch
+}
+
+try {
+ $output = Install-DbaMultiTool @multiToolSplat
+ $module.Result.changed = $true
+
+ # output is an array for each stored proc,
+ # rollup output into a single result
+ $errorProcs = $output | Where-Object Status -eq "Error"
+ if ($errorProcs) {
+ $output = $errorProcs[0] | Select-Object -ExcludeProperty Name
+ }
+ else {
+ $output = $output[0] | Select-Object -ExcludeProperty Name
+ }
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Installing DBA-MultiTool failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.py
new file mode 100644
index 000000000..6daeef3d9
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/dba_multitool.py
@@ -0,0 +1,63 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: dba_multitool
+short_description: Install/update the DBA Multitool suite by John McCall
+description:
+ - A wrapper for C(Install-DbaMultiTool) to fetch the latest version of the scripts, or install from a local cached version.
+version_added: 0.7.0
+options:
+ sql_instance:
+ description:
+ - The target SQL Server instance or instances. Server version must be SQL Server version 2005 or higher.
+ type: str
+ required: true
+ local_file:
+ description:
+ - Specifies the path to a local file to install DBA MultiTool from. This should be the zip file as distributed by the maintainers.
+ - If this option is not specified, the latest version will be downloaded and installed from https://github.com/LowlyDBA/dba-multitool/.
+ type: str
+ required: false
+ branch:
+ description:
+ - Specifies an alternate branch of the DBA MultiTool to install.
+ type: str
+ required: false
+ choices: ['master', 'development']
+ database:
+ description:
+ - Name of the target database.
+ type: str
+ required: true
+ force:
+ description:
+ - If this switch is enabled, the DBA MultiTool will be downloaded from the internet even if previously cached.
+ type: bool
+ default: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Install DBA MultiTool
+ lowlydba.sqlserver.dba_multitool:
+ sql_instance: test-server.my.company.com
+ database: dba_tools
+'''
+
+RETURN = r'''
+data:
+ description: Modified output from the C(Install-DbaMultitool) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.ps1
new file mode 100644
index 000000000..1e19ce62f
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.ps1
@@ -0,0 +1,80 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ branch = @{type = 'str'; required = $false; choices = @('main', 'dev') }
+ local_file = @{type = 'str'; required = $false }
+ only_script = @{type = 'str'; required = $false; default = 'Install-All-Scripts.sql'; choices = @('Install-All-Scripts.sql'
+ 'Install-Core-Blitz-No-Query-Store.sql'
+ 'Install-Core-Blitz-With-Query-Store.sql'
+ 'sp_Blitz.sql'
+ 'sp_BlitzFirst.sql'
+ 'sp_BlitzIndex.sql'
+ 'sp_BlitzCache.sql'
+ 'sp_BlitzWho.sql'
+ 'sp_BlitzQueryStore.sql'
+ 'sp_BlitzAnalysis.sql'
+ 'sp_BlitzBackups.sql'
+ 'sp_BlitzInMemoryOLTP.sql'
+ 'sp_BlitzLock.sql'
+ 'sp_AllNightLog.sql'
+ 'sp_AllNightLog_Setup.sql'
+ 'sp_DatabaseRestore.sql'
+ 'sp_ineachdb.sql'
+ 'SqlServerVersions.sql'
+ 'Uninstall.sql')
+ }
+ database = @{type = 'str'; required = $true }
+ force = @{type = 'bool'; required = $false; default = $false }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$branch = $module.Params.branch
+$onlyScript = $module.Params.only_script
+$localFile = $module.Params.local_file
+$force = $module.Params.force
+$checkMode = $module.Checkmode
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+$firstResponderKitSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ Force = $force
+}
+if ($localFile) {
+ $firstResponderKitSplat.Add("LocalFile", $localFile)
+}
+if ($branch) {
+ $firstResponderKitSplat.Add("Branch", $branch)
+}
+if ($onlyScript) {
+ $firstResponderKitSplat.Add("OnlyScript", $onlyScript)
+}
+
+try {
+ $output = Install-DbaFirstResponderKit @firstResponderKitSplat
+ $module.Result.changed = $true
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Installing First Responder Kit failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.py
new file mode 100644
index 000000000..fba6fad97
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/first_responder_kit.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: first_responder_kit
+short_description: Install/update the First Responder Kit scripts
+description:
+ - A wrapper for C(Install-DbaFirstResponderKit) to fetch the latest version of the scripts, or install from a local cached version.
+version_added: 0.10.0
+options:
+ local_file:
+ description:
+ - Specifies the path to a local file to install FRK from. This should be the zip file as distributed by the maintainers.
+ - If this option is not specified, the latest version will be downloaded and installed Github.
+ type: str
+ required: false
+ only_script:
+ description:
+ - Specifies the name(s) of the script(s) to run for installation. Wildcards are permitted.
+ - This way only part of the First Responder Kit can be installed.
+ type: str
+ required: false
+ default: 'Install-All-Scripts.sql'
+ choices: ['Install-All-Scripts.sql',
+ 'Install-Core-Blitz-No-Query-Store.sql',
+ 'Install-Core-Blitz-With-Query-Store.sql',
+ 'sp_Blitz.sql',
+ 'sp_BlitzFirst.sql',
+ 'sp_BlitzIndex.sql',
+ 'sp_BlitzCache.sql',
+ 'sp_BlitzWho.sql',
+ 'sp_BlitzQueryStore.sql',
+ 'sp_BlitzAnalysis.sql',
+ 'sp_BlitzBackups.sql',
+ 'sp_BlitzInMemoryOLTP.sql',
+ 'sp_BlitzLock.sql',
+ 'sp_AllNightLog.sql',
+ 'sp_AllNightLog_Setup.sql',
+ 'sp_DatabaseRestore.sql',
+ 'sp_ineachdb.sql',
+ 'SqlServerVersions.sql',
+ 'Uninstall.sql']
+ branch:
+ description:
+ - Specifies an alternate branch of the First Responder Kit to install.
+ type: str
+ required: false
+ choices: ['main', 'dev']
+ database:
+ description:
+ - Name of the target database.
+ type: str
+ required: true
+ force:
+ description:
+ - If this switch is enabled, the FRK will be downloaded from the internet even if previously cached.
+ type: bool
+ default: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Install FRK
+ lowlydba.sqlserver.first_responder_kit:
+ sql_instance: test-server.my.company.com
+ database: dba_tools
+'''
+
+RETURN = r'''
+data:
+ description: Modified output from the C(Install-DbaFirstResponderKit) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.ps1
new file mode 100644
index 000000000..473ad4802
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.ps1
@@ -0,0 +1,71 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ username = @{type = 'str'; required = $false }
+ password = @{type = 'str'; required = $false; no_log = $true }
+ enabled = @{type = 'bool'; required = $false; default = $true }
+ force = @{type = 'bool'; required = $false; default = $false }
+ }
+ required_together = @(
+ , @('username', 'password')
+ )
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+if ($null -ne $Module.Params.username) {
+ [securestring]$secPassword = ConvertTo-SecureString $Module.Params.password -AsPlainText -Force
+ [pscredential]$credential = New-Object System.Management.Automation.PSCredential ($Module.Params.username, $secPassword)
+}
+$enabled = $module.Params.enabled
+$force = $module.Params.force
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+try {
+ $server = Connect-DbaInstance -SqlInstance $sqlInstance -SqlCredential $sqlCredential
+ $existingHadr = $server | Get-DbaAgHadr -EnableException
+ $output = $existingHadr
+ if ($existingHadr.IsHadrEnabled -ne $enabled) {
+ $setHadr = @{
+ Credential = $credential
+ WhatIf = $checkMode
+ Force = $force
+ Confirm = $false
+ EnableException = $true
+ }
+ if ($enabled -eq $false) {
+ $output = $server | Disable-DbaAgHadr @setHadr
+ }
+ else {
+ $output = $server | Enable-DbaAgHadr @setHadr
+ }
+
+ if ($force -ne $true) {
+ $output | Add-Member -MemberType NoteProperty -Name "RestartRequired" -Value $true
+ }
+ $module.Result.changed = $true
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error configuring Hadr.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.py
new file mode 100644
index 000000000..0fc91d22d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/hadr.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: hadr
+short_description: Enable or disable HADR
+description:
+ - Enable or disable the High Availability Disaster Recovery (HADR) feature.
+version_added: 0.4.0
+options:
+ sql_instance:
+ description:
+ - The SQL Server instance to modify.
+ type: str
+ required: true
+ username:
+ description:
+ - Username for alternative credential to authenticate with Windows.
+ type: str
+ required: false
+ password:
+ description:
+ - Password for alternative credential to authenticate with Windows.
+ type: str
+ required: false
+ enabled:
+ description:
+ - Flag to enable or disable the feature.
+ type: bool
+ required: false
+ default: true
+ force:
+ description:
+ - Restart SQL Server and SQL Agent services automatically.
+ type: bool
+ required: false
+ default: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_win
+'''
+
+EXAMPLES = r'''
+- name: Enable hadr with service restart
+ lowlydba.sqlserver.hadr:
+ sql_instance: sql-01.myco.io
+ enabled: true
+ force: true
+'''
+
+RETURN = r'''
+data:
+ description:
+ - Output from the C(Enable-DbaAgHadr) or C(Disable-DbaAgHadr) function.
+ - RestartRequired returned if the setting requires a service restart to take effect.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.ps1
new file mode 100644
index 000000000..5c26588eb
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.ps1
@@ -0,0 +1,86 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+#Requires -Modules @{ ModuleName="dbops"; ModuleVersion="0.8.0" }
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ database = @{type = 'str'; required = $true }
+ path = @{type = 'str'; required = $true }
+ deployment_method = @{type = 'str'; required = $false; default = 'NoTransaction'
+ choices = @('NoTransaction', 'SingleTransaction', 'TransactionPerScript')
+ }
+ schema_version_table = @{type = 'str'; required = $false }
+ no_log_version = @{type = 'bool'; required = $false; default = $false }
+ connection_timeout = @{type = 'int'; required = $false; default = 30 }
+ execution_timeout = @{type = 'int'; required = $false; default = 0 }
+ output_file = @{type = 'str'; required = $false }
+ create_database = @{type = 'bool'; required = $false; default = $false }
+ no_recurse = @{type = 'bool'; required = $false; default = $false }
+ match = @{type = 'str'; required = $false }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$schemaVersionTable = $module.Params.schema_version_table
+$path = $module.Params.path
+$outputFile = $module.Params.output_file
+$match = $module.Params.match
+$connectionTimeout = $module.Params.connection_timeout
+$executionTimeout = $module.Params.execution_timeout
+$createDatabase = $module.Params.create_database
+$noRecurse = $module.Params.no_recurse
+$noLogVersion = $module.Params.no_log_version
+$checkMode = $module.Checkmode
+$PSDefaultParameterValues = @{ "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $installSplat = @{
+ SqlInstance = $sqlInstance
+ Credential = $sqlCredential
+ Database = $database
+ Path = $path
+ ConnectionTimeout = $connectionTimeout
+ ExecutionTimeout = $executionTimeout
+ CreateDatabase = $createDatabase
+ NoRecurse = $noRecurse
+ Silent = $true
+ Type = "SqlServer"
+ }
+ if ($schemaVersionTable) {
+ $installSplat.Add("SchemaVersionTable", $schemaVersionTable)
+ }
+ if ($outputFile) {
+ $installSplat.Add("OutputFile", $outputFile)
+ }
+ if ($match) {
+ $installSplat.Add("Match", $match)
+ }
+ if ($noLogVersion) {
+ $installSplat.SchemaVersionTable = $null
+ }
+
+ $output = Install-DboScript @installSplat
+ if ($output.DeploymentLog[-1] -ne "No new scripts need to be executed - completing.") {
+ $module.Result.changed = $true
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ }
+
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Failed migration script(s) execution: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.py
new file mode 100644
index 000000000..4dbf78f41
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/install_script.py
@@ -0,0 +1,104 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: install_script
+short_description: Runs migration scripts against a database
+description:
+ - Uses the module C(DBOps) to run C(Dbo-InstallScript) against a target SQL Server database.
+version_added: 0.11.0
+options:
+ database:
+ description:
+ - Name of the target database.
+ required: true
+ type: str
+ path:
+ description:
+ - Directory where targeted sql scripts are stored.
+ type: str
+ required: true
+ schema_version_table:
+ description:
+ - A table that will hold the history of script execution. This table is used to choose what scripts are going to be
+ run during the deployment, preventing the scripts from being execured twice.
+ type: str
+ required: false
+ deployment_method:
+ description:
+ - C(SingleTransaction) - wrap all the deployment scripts into a single transaction and rollback whole deployment on error.
+ - C(TransactionPerScript) - wrap each script into a separate transaction; rollback single script deployment in case of error.
+ - C(NoTransaction) - deploy as is.
+ type: str
+ required: false
+ default: 'NoTransaction'
+ choices: ['NoTransaction', 'SingleTransaction', 'TransactionPerScript']
+ no_log_version:
+ description:
+ - If set, the deployment will not be tracked in the database. That will also mean that all the scripts
+ and all the builds from the package are going to be deployed regardless of any previous deployment history.
+ type: bool
+ default: false
+ required: false
+ connection_timeout:
+ description:
+ - Database server connection timeout in seconds. Only affects connection attempts. Does not affect execution timeout.
+ type: int
+ default: 30
+ required: false
+ execution_timeout:
+ description:
+ - Script execution timeout. The script will be aborted if the execution takes more than specified number of seconds.
+ type: int
+ default: 0
+ required: false
+ output_file:
+ description:
+ - Log output into specified file.
+ type: str
+ required: false
+ create_database:
+ description:
+ - Will create an empty database if missing.
+ type: bool
+ default: false
+ required: false
+ no_recurse:
+ description:
+ - Only process the first level of the target path.
+ type: bool
+ required: false
+ default: false
+ match:
+ description:
+ - Runs a regex verification against provided file names using the provided string.
+ type: str
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+ - L(dbops,https://github.com/dataplat/dbops) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Migrate a database
+ lowlydba.sqlserver.install_script:
+ sql_instance: test-server.my.company.com
+ database: AdventureWorks
+ path: migrations
+'''
+
+RETURN = r'''
+data:
+ description: Modified output from the C(Install-DboScript) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.ps1
new file mode 100644
index 000000000..a99ea01de
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.ps1
@@ -0,0 +1,57 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{}
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$module.Result.changed = $false
+
+# Fetch instance information
+try {
+ $getSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ EnableException = $true
+ }
+ $output = Get-DbaConnection @getSplat | Select-Object -Property "ComputerName", "SqlInstance", "InstanceName" -First 1
+
+ if ($null -ne $output) {
+ # Add additional fields
+ $extraProperties = @(
+ "BuildNumber"
+ "Language"
+ "VersionMajor"
+ "VersionMinor"
+ "VersionString"
+ "Collation"
+ "ProductLevel"
+ "IsClustered"
+ "LoginMode"
+ )
+ foreach ($prop in $extraProperties) {
+ $value = (Get-DbaInstanceProperty @getSplat -InstanceProperty $prop).Value
+ $output | Add-Member -MemberType NoteProperty -Name $prop -Value $value
+ }
+
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error fetching instance information: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.py
new file mode 100644
index 000000000..2bfdbf152
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/instance_info.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: instance_info
+short_description: Returns basic information for a SQL Server instance
+description:
+ - Returns basic information for a SQL Server instance.
+version_added: 0.2.0
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode_read_only
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Get basic info for an instance
+ lowlydba.sqlserver.instance_info:
+ sql_instance: sql-01.myco.io
+'''
+
+RETURN = r'''
+data:
+ description: Instance level properties of the SQL Server instance.
+ returned: always
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/login.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/login.ps1
new file mode 100644
index 000000000..d509ba794
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/login.ps1
@@ -0,0 +1,144 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ login = @{type = 'str'; required = $true }
+ password = @{type = 'str'; required = $false; no_log = $true }
+ enabled = @{type = 'bool'; required = $false; default = $true }
+ default_database = @{type = 'str'; required = $false }
+ language = @{type = 'str'; required = $false }
+ password_must_change = @{type = 'bool'; required = $false }
+ password_policy_enforced = @{type = 'bool'; required = $false }
+ password_expiration_enabled = @{type = 'bool'; required = $false }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$login = $module.Params.login
+if ($null -ne $module.Params.password) {
+ $secPassword = ConvertTo-SecureString -String $module.Params.password -AsPlainText -Force
+}
+$enabled = $module.Params.enabled
+$defaultDatabase = $module.Params.default_database
+$language = $module.Params.language
+[nullable[bool]]$passwordMustChange = $module.Params.password_must_change
+[nullable[bool]]$passwordExpirationEnabled = $module.Params.password_expiration_enabled
+[nullable[bool]]$passwordPolicyEnforced = $module.Params.password_policy_enforced
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+
+$module.Result.changed = $false
+
+try {
+ $getLoginSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Login = $login
+ ExcludeSystemLogin = $true
+ EnableException = $true
+ }
+ $existingLogin = Get-DbaLogin @getLoginSplat
+
+ if ($state -eq "absent") {
+ if ($null -ne $existingLogin) {
+ $output = $existingLogin | Remove-DbaLogin -WhatIf:$checkMode -EnableException -Force -Confirm:$false
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "present") {
+ $setLoginSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Login = $login
+ WhatIf = $checkMode
+ EnableException = $true
+ Confirm = $false
+ }
+ if ($null -ne $defaultDatabase) {
+ $setLoginSplat.add("DefaultDatabase", $defaultDatabase)
+ }
+ if ($null -ne $passwordExpirationEnabled) {
+ if ($existingLogin.PasswordExpirationEnabled -ne $passwordExpirationEnabled) {
+ $changed = $true
+ }
+ if ($passwordExpirationEnabled -eq $true) {
+ $setLoginSplat.add("PasswordExpirationEnabled", $true)
+ }
+ }
+ if ($null -ne $passwordPolicyEnforced) {
+ if ($existingLogin.PasswordPolicyEnforced -ne $passwordPolicyEnforced) {
+ $changed = $true
+ }
+ if ($passwordPolicyEnforced -eq $true) {
+ $setLoginSplat.add("PasswordPolicyEnforced", $true)
+ }
+ }
+ if ($true -eq $passwordMustChange) {
+ if ($existingLogin.PasswordMustChange -ne $passwordMustChange) {
+ $changed = $true
+ }
+ if ($passwordMustChange -eq $true) {
+ $setLoginSplat.add("PasswordMustChange", $true)
+ }
+ }
+ if ($null -ne $secPassword) {
+ $setLoginSplat.add("SecurePassword", $secPassword)
+ }
+
+ # Login already exists
+ if ($null -ne $existingLogin) {
+ if ($enabled -eq $false) {
+ $disabled = $true
+ $setLoginSplat.add("Disable", $true)
+ }
+ else {
+ $disabled = $false
+ $setLoginSplat.add("Enable", $true)
+ }
+ # Login needs to be modified
+ if (($changed -eq $true) -or ($disabled -ne $existingLogin.IsDisabled) -or ($secPassword)) {
+ $output = Set-DbaLogin @setLoginSplat
+ $module.result.changed = $true
+ }
+ }
+ # New login
+ else {
+ if ($null -ne $language) {
+ $setLoginSplat.add("Language", $language)
+ }
+ if ($enabled -eq $false) {
+ $setLoginSplat.add("Disabled", $true)
+ }
+ $output = New-DbaLogin @setLoginSplat
+ $module.result.changed = $true
+ }
+ # If not in check mode, add extra fields we can change to default display set
+ if ($null -ne $output) {
+ $output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("DefaultDatabase")
+ $output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Language")
+ }
+
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring login failed: $($_.Exception.Message) ; $setLoginSplat", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/login.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/login.py
new file mode 100644
index 000000000..a570d8cfe
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/login.py
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: login
+short_description: Configures a login for the target SQL Server instance
+description:
+ - Creates, modifies, or removes a Windows or SQL Authentication login on a SQL Server instance.
+version_added: 0.1.0
+options:
+ login:
+ description:
+ - Name of the login to configure.
+ type: str
+ required: true
+ password:
+ description:
+ - Password for the login, if SQL Authentication login.
+ type: str
+ required: false
+ enabled:
+ description:
+ - Whether the login is enabled or disabled.
+ type: bool
+ required: false
+ default: true
+ version_added: '0.4.0'
+ default_database:
+ description:
+ - Default database for the login.
+ type: str
+ required: false
+ language:
+ description:
+ - Default language for the login. Only used when creating a new login, not when modifying an existing one.
+ type: str
+ required: false
+ password_must_change:
+ description:
+ - Enforces user must change password at next login.
+ - When specified will enforce I(password_expiration_enabled) and I(password_policy_enforced) as they are required.
+ type: bool
+ required: false
+ password_policy_enforced:
+ description:
+ - Enforces password complexity policy.
+ type: bool
+ required: false
+ password_expiration_enabled:
+ description:
+ - Enforces password expiration policy. Requires I(password_policy_enforced=true).
+ type: bool
+ required: false
+author: "John McCall (@lowlydba)"
+notes:
+ - Module will always return changed if a password is supplied.
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a login
+ lowlydba.sqlserver.login:
+ sql_instance: sql-01.myco.io
+ login: TheIntern
+ password: ReallyComplexStuff12345!
+
+- name: Disable a login
+ lowlydba.sqlserver.login:
+ sql_instance: sql-01.myco.io
+ login: TheIntern
+ enabled: false
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaLogin), C(Set-DbaLogin), or C(Remove-DbaLogin) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.ps1
new file mode 100644
index 000000000..48f9c90ab
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.ps1
@@ -0,0 +1,105 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ backup_location = @{type = 'str'; required = $false }
+ cleanup_time = @{type = 'int'; required = $false; default = 0 }
+ output_file_dir = @{type = 'str'; required = $false }
+ replace_existing = @{type = 'bool'; required = $false; }
+ log_to_table = @{type = 'bool'; required = $false; default = $false }
+ solution = @{type = 'str'; required = $false; choices = @('All', 'Backup', 'IntegrityCheck', 'IndexOptimize'); default = 'All' }
+ install_jobs = @{type = 'bool'; required = $false; default = $false }
+ local_file = @{type = 'str'; required = $false }
+ database = @{type = 'str'; required = $true }
+ force = @{type = 'bool'; required = $false; default = $false }
+ install_parallel = @{type = 'bool'; required = $false; default = $false }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$backupLocation = $module.Params.backup_location
+$outputFileDirectory = $module.Params.output_file_dir
+$cleanupTime = $module.Params.cleanup_time
+$replaceExisting = $module.Params.replace_existing
+$solution = $module.Params.solution
+$installJobs = $module.Params.install_jobs
+$installParallel = $module.Params.install_parallel
+$logToTable = $module.Params.log_to_table
+$localFile = $module.Params.local_file
+$force = $module.Params.force
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+try {
+ $maintenanceSolutionSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ LogToTable = $logToTable
+ Solution = $solution
+ InstallJobs = $installJobs
+ InstallParallel = $installParallel
+ WhatIf = $checkMode
+ Force = $force
+ Confirm = $false
+ EnableException = $true
+ }
+ if ($null -ne $localFile) {
+ $maintenanceSolutionSplat.LocalFile = $localFile
+ }
+ if ($null -ne $backupLocation) {
+ $maintenanceSolutionSplat.BackupLocation = $backupLocation
+ }
+ if ($null -ne $outputFileDirectory) {
+ $maintenanceSolutionSplat.OutputFileDirectory = $outputFileDirectory
+ }
+ if ($installJobs -eq $true -and $null -ne $cleanupTime) {
+ $maintenanceSolutionSplat.CleanupTime = $cleanupTime
+ }
+ # Only pass if true, otherwise removes warning that is used to track changed=$false
+ if ($replaceExisting -eq $true) {
+ $maintenanceSolutionSplat.ReplaceExisting = $replaceExisting
+ }
+
+ try {
+ $output = Install-DbaMaintenanceSolution @maintenanceSolutionSplat
+ $module.Result.changed = $true
+ }
+ catch {
+ $errMessage = $_.Exception.Message
+ if ($errMessage -like "*Maintenance Solution already exists*") {
+ $server = Connect-DbaInstance -SqlInstance $sqlInstance -SqlCredential $sqlCredential
+ $output = [PSCustomObject]@{
+ ComputerName = $server.ComputerName
+ InstanceName = $server.ServiceName
+ SqlInstance = $server.DomainInstanceName
+ Results = "Success"
+ }
+ }
+ else {
+ Write-Error -Message $errMessage
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Installing Maintenance Solution failed.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.py
new file mode 100644
index 000000000..1df314ff4
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/maintenance_solution.py
@@ -0,0 +1,101 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: maintenance_solution
+short_description: Install/update Maintenance Solution by Ola Hallengren
+description:
+ - A wrapper for C(Install-DbaMaintenanceSolution) to fetch the latest version of the Ola Hallengren's Maintenance Solution,
+ or install from a local cached version.
+version_added: 0.1.0
+options:
+ backup_location:
+ description:
+ - Location of the backup root directory. If this is not supplied, the default backup directory will be used.
+ type: str
+ required: false
+ cleanup_time:
+ description:
+ - Time in hours, after which backup files are deleted.
+ type: int
+ required: false
+ default: 0
+ output_file_dir:
+ description:
+ - Specify the output file directory where the Maintenance Solution will write to.
+ type: str
+ required: false
+ replace_existing:
+ description:
+ - If this switch is enabled, objects already present in the target database will be dropped and recreated.
+ type: bool
+ required: false
+ log_to_table:
+ description:
+ - If this switch is enabled, the Maintenance Solution will be configured to log commands to a table.
+ type: bool
+ required: false
+ default: false
+ solution:
+ description:
+ - Specifies which portion of the Maintenance Solution to install.
+ type: str
+ required: false
+ default: 'All'
+ choices: ['All', 'Backup', 'IntegrityCheck', 'IndexOptimize']
+ install_jobs:
+ description:
+ - If this switch is enabled, the corresponding SQL Agent Jobs will be created.
+ type: bool
+ required: false
+ default: false
+ install_parallel:
+ description:
+ - If this switch is enabled, the C(Queue) and C(QueueDatabase) tables are created, for use when C(@DatabasesInParallel = 'Y') are set in the jobs.
+ type: bool
+ required: false
+ default: false
+ local_file:
+ description:
+ - Specifies the path to a local file to install Ola's solution from. This should be the zip file as distributed by the maintainers.
+ - If this option is not specified, the latest version will be downloaded and installed
+ from the L(Maintenance Solution Github,https://github.com/olahallengren/sql-server-maintenance-solution).
+ type: str
+ required: false
+ database:
+ description:
+ - Name of the target database.
+ type: str
+ required: true
+ force:
+ description:
+ - If this switch is enabled, the Maintenance Solution will be downloaded from the internet even if previously cached.
+ type: bool
+ default: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Install/Update Maintenance Solution
+ lowlydba.sqlserver.multitool:
+ sql_instance: sql-01.myco.io
+ database: main
+ replace_existing: true
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Install-MaintenanceSolution) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/memory.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/memory.ps1
new file mode 100644
index 000000000..1b6d2bed9
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/memory.ps1
@@ -0,0 +1,50 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ max = @{type = "int"; required = $false; default = 0 }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$max = $module.Params.max
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+# Set max memory for SQL Instance
+try {
+ # Set max memory
+ $setMemorySplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Max = $max
+ }
+ $output = Set-DbaMaxMemory @setMemorySplat
+
+ if ($output.PreviousMaxValue -ne $output.MaxValue -or $checkMode) {
+ $module.Result.changed = $true
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error setting max memory.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/memory.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/memory.py
new file mode 100644
index 000000000..65b6b3273
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/memory.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: memory
+short_description: Sets the maximum memory for a SQL Server instance
+description:
+ - Sets the maximum memory for a SQL Server instance.
+version_added: 0.1.0
+options:
+ max:
+ description:
+ - The maximum memory in MB that the SQL Server instance can utilize. C(0) will automatically calculate the ideal value.
+ type: int
+ required: false
+ default: 0
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Automatically configure SQL max memory
+ lowlydba.sqlserver.memory:
+ sql_instance: sql-01.myco.io
+
+- name: Manually configure SQL max memory
+ lowlydba.sqlserver.memory:
+ sql_instance: sql-01.myco.io
+ max: 10240
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Set-DbaMaxMemory) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.ps1
new file mode 100644
index 000000000..fdc34d170
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.ps1
@@ -0,0 +1,51 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ database = @{type = 'str'; required = $true }
+ nonquery = @{type = 'str'; required = $true }
+ query_timeout = @{type = 'int'; required = $false; default = 60 }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$nonquery = $module.Params.nonquery
+$queryTimeout = $module.Params.query_timeout
+$checkMode = $module.CheckMode
+
+$module.Result.changed = $false
+
+try {
+ $invokeQuerySplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ Query = $nonquery
+ QueryTimeout = $queryTimeout
+ EnableException = $true
+ }
+ if ($checkMode) {
+ $invokeQuerySplat.Add("NoExec", $true)
+ }
+ $null = Invoke-DbaQuery @invokeQuerySplat
+
+ $module.Result.changed = $true
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Executing nonquery failed.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.py
new file mode 100644
index 000000000..9f56c7bc5
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/nonquery.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: nonquery
+short_description: Executes a generic nonquery
+description:
+ - Execute a nonquery against a database. Does not return a resultset. Ideal for ad-hoc configurations or DML queries.
+version_added: 0.1.0
+options:
+ database:
+ description:
+ - Name of the database to execute the nonquery in.
+ type: str
+ required: true
+ nonquery:
+ description:
+ - The nonquery to be executed.
+ type: str
+ required: true
+ query_timeout:
+ description:
+ - Number of seconds to wait before timing out the nonquery execution.
+ type: int
+ required: false
+ default: 60
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Update a table value
+ lowlydba.sqlserver.nonquery:
+ sql_instance: sql-01-myco.io
+ database: userdb
+ nonquery: "UPDATE dbo.User set IsActive = 1;"
+'''
+
+RETURN = r''' # '''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.ps1
new file mode 100644
index 000000000..aa0ade5ed
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.ps1
@@ -0,0 +1,69 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ enabled = @{type = 'bool'; required = $false; default = $true }
+ classifier_function = @{type = 'str'; required = $false }
+ }
+}
+
+# Get Csharp utility module
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$enabled = $module.Params.enabled
+$classifierFunction = $module.Params.classifier_function
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $rg = Get-DbaResourceGovernor -SqlInstance $sqlInstance -SqlCredential $sqlCredential
+ $rgClassifierFunction = $rg.ClassifierFunction
+
+ if ($rg.Enabled -ne $enabled) {
+ $change = $true
+ }
+ if ($classifierFunction -ne "NULL" -and $rgClassifierFunction -ne $classifierFunction) {
+ $change = $true
+ }
+ if ($classifierFunction -eq "NULL" -and $null -ne $rgClassifierFunction) {
+ $change = $true
+ }
+
+ if ($change) {
+ $rgSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ ClassifierFunction = $classifierFunction
+ }
+ if ($enabled) {
+ $rgSplat.Add("Enabled", $true)
+ }
+ else {
+ $rgSplat.Add("Disabled", $true)
+ }
+ $output = Set-DbaResourceGovernor @rgSplat
+ $module.Result.changed = $true
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Setting resource governor failed.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.py
new file mode 100644
index 000000000..66b789d22
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/resource_governor.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: resource_governor
+short_description: Configures the resource governor on a SQL Server instance
+description:
+ - Enables or disables and optionally sets the classifier function for the resource governor feature.
+version_added: 0.1.0
+options:
+ enabled:
+ description:
+ - Whether to enable or disable resource governor.
+ type: bool
+ required: false
+ default: true
+ classifier_function:
+ description:
+ - The name of the classifier function that resource governor will use. To clear the function, use the string C(NULL).
+ type: str
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Enable resource governor
+ lowlydba.sqlserver.resource_governor:
+ sql_instance: sql-01.myco.io
+ enabled: true
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Set-DbaResourceGovernor) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/restore.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/restore.ps1
new file mode 100644
index 000000000..73c9690fa
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/restore.ps1
@@ -0,0 +1,170 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ database = @{type = 'str'; required = $false }
+ path = @{type = 'str'; required = $true }
+ destination_data_directory = @{type = 'str'; required = $false }
+ destination_log_directory = @{type = 'str'; required = $false }
+ destination_filestream_directory = @{type = 'str'; required = $false }
+ restore_time = @{type = 'str'; required = $false }
+ with_replace = @{type = 'bool'; required = $false; default = $false }
+ keep_replication = @{type = 'bool'; required = $false; default = $false }
+ xp_dirtree = @{type = 'bool'; required = $false }
+ no_xp_dir_recurse = @{type = 'bool'; required = $false; default = $false }
+ verify_only = @{type = 'bool'; required = $false; default = $false }
+ maintenance_solution_backup = @{type = 'bool'; required = $false; default = $false }
+ ignore_log_backup = @{type = 'bool'; required = $false; default = $false }
+ ignore_diff_backup = @{type = 'bool'; required = $false; default = $false }
+ use_destination_default_directories = @{type = 'bool'; required = $false }
+ reuse_source_folder_structure = @{type = 'bool'; required = $false }
+ destination_file_prefix = @{type = 'str'; required = $false }
+ restored_database_name_prefix = @{type = 'str'; required = $false }
+ directory_recurse = @{type = 'bool'; required = $false; default = $false }
+ standby_directory = @{type = 'str'; required = $false }
+ replace_db_name_in_file = @{type = 'bool'; required = $false }
+ destination_file_suffix = @{type = 'str'; required = $false }
+ keep_cdc = @{type = 'bool'; required = $false }
+ stop_before = @{type = 'bool'; required = $false; default = $false }
+ stop_mark = @{type = 'str'; required = $false }
+ stop_after_date = @{type = 'str'; required = $false }
+ no_recovery = @{type = 'bool'; required = $false; default = $false }
+ max_transfer_size = @{type = 'int'; required = $false; default = 0 }
+ block_size = @{type = 'str'; required = $false; choices = @('0.5kb', '1kb', '2kb', '4kb', '8kb', '16kb', '32kb', '64kb') }
+ buffer_count = @{type = 'int'; required = $false; default = 0 }
+ azure_credential = @{type = 'str'; required = $false }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$path = $module.Params.path
+$destinationDataDirectory = $module.Params.destination_data_directory
+$destinationLogDirectory = $module.Params.destination_log_directory
+$destinationFilestreamDirectory = $module.Params.destination_filestream_directory
+$restoreTime = $module.Params.restore_time
+$withReplace = $module.Params.with_replace
+$keepReplication = $module.Params.keep_replication
+$xpDirTree = $module.Params.xp_dirtree
+$noXpDirRecurse = $module.Params.no_xp_dir_recurse
+$verifyOnly = $module.Params.verify_only
+$maintenanceSolutionBackup = $module.Params.maintenance_solution_backup
+$ignoreLogBackup = $module.Params.ignore_log_backup
+$ignoreDiffBackup = $module.Params.ignore_diff_backup
+$useDestinationDefaultDirectories = $module.Params.use_destination_default_directories
+$reuseSourceFolderStructure = $module.Params.reuse_source_folder_structure
+$destinationFilePrefix = $module.Params.destination_file_prefix
+$restoredDatabaseNamePrefix = $module.Params.restored_database_name_prefix
+$directoryRecurse = $module.Params.directory_recurse
+$standbyDirectory = $module.Params.standby_directory
+$replaceDbNameInFile = $module.Params.replace_db_name_in_file
+$destinationFileSuffix = $module.Params.destination_file_suffix
+$keepCDC = $module.Params.keep_cdc
+$stopBefore = $module.Params.stop_before
+$stopMark = $module.Params.stop_mark
+$stopAfterDate = $module.Params.stop_after_date
+$noRecovery = $module.Params.no_recovery
+$maxTransferSize = $module.Params.max_transfer_size
+$blockSize = $module.Params.block_size
+$bufferCount = $module.Params.buffer_count
+$azureCredential = $modules.Param.azure_credential
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $restoreSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Path = $path
+ WithReplace = $withReplace
+ KeepReplication = $keepReplication
+ NoXpDirRecurse = $noXpDirRecurse
+ VerifyOnly = $verifyOnly
+ MaintenanceSolutionBackup = $maintenanceSolutionBackup
+ IgnoreLogBackup = $ignoreLogBackup
+ IgnoreDiffBackup = $ignoreDiffBackup
+ DirectoryRecurse = $directoryRecurse
+ StopBefore = $stopBefore
+ NoRecovery = $noRecovery
+ MaxTransferSize = $maxTransferSize
+ BufferCount = $bufferCount
+ }
+ if ($null -ne $database) {
+ $restoreSplat.Add("DatabaseName", $database)
+ }
+ if ($null -ne $destinationDataDirectory) {
+ $restoreSplat.Add("DestinationDataDirectory", $destinationDataDirectory)
+ }
+ if ($null -ne $destinationLogDirectory) {
+ $restoreSplat.Add("DestinationLogDirectory", $destinationLogDirectory)
+ }
+ if ($null -ne $destinationFilestreamDirectory) {
+ $restoreSplat.Add("DestinationFilestreamDirectory", $destinationFilestreamDirectory)
+ }
+ if ($null -ne $restoreTime) {
+ $restoreSplat.Add("RestoreTime", $restoreTime)
+ }
+ if ($null -ne $destinationFilePrefix) {
+ $restoreSplat.Add("DestinationFilePrefix", $destinationFilePrefix)
+ }
+ if ($null -ne $restoredDatabaseNamePrefix) {
+ $restoreSplat.Add("RestoredDatabaseNamePrefix", $restoredDatabaseNamePrefix)
+ }
+ if ($null -ne $standbyDirectory) {
+ $restoreSplat.Add("StandbyDirectory", $standbyDirectory)
+ }
+ if ($null -ne $destinationFileSuffix) {
+ $restoreSplat.Add("DestinationFileSuffix", $destinationFileSuffix)
+ }
+ if ($null -ne $stopAfterDate) {
+ $restoreSplat.Add("StopAfterDate", $stopAfterDate)
+ }
+ if ($null -ne $stopMark) {
+ $restoreSplat.Add("StopMark", $stopMark)
+ }
+ if ($null -ne $blockSize) {
+ $restoreSplat.Add("BlockSize", ($blockSize / 1))
+ }
+ if ($null -ne $azureCredential) {
+ $restoreSplat.Add("AzureCredential", $azureCredential)
+ }
+ if ($null -ne $xpDirTree) {
+ $restoreSplat.Add("xpDirTree", $xpDirTree)
+ }
+ if ($null -ne $reuseSourceFolderStructure) {
+ $restoreSplat.Add("reuseSourceFolderStructure", $reuseSourceFolderStructure)
+ }
+ if ($null -ne $replaceDbNameInFile) {
+ $restoreSplat.Add("replaceDbNameInFile", $replaceDbNameInFile)
+ }
+ if ($null -ne $useDestinationDefaultDirectories) {
+ $restoreSplat.Add("useDestinationDefaultDirectories", $useDestinationDefaultDirectories)
+ }
+ if ($null -ne $keepCDC) {
+ $restoreSplat.Add("KeepCDC", $keepCDC)
+ }
+ $output = Restore-DbaDatabase @restoreSplat
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ $module.Result.changed = $true
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Error restoring database: $($_.Exception.Message).", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/restore.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/restore.py
new file mode 100644
index 000000000..5899ef18f
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/restore.py
@@ -0,0 +1,230 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: restore
+short_description: Performs a restore operation
+description:
+ - Performs a database restore operation.
+version_added: 0.9.0
+options:
+ database:
+ description:
+ - The database to process.
+ type: str
+ required: false
+ path:
+ description:
+ - Path to SQL Server backup files.
+ - Paths passed in as strings will be scanned using the desired method, default is a recursive folder scan.
+ - Accepts multiple paths separated by C(,).
+ type: str
+ required: true
+ destination_data_directory:
+ description:
+ - Path to restore the SQL Server backups to on the target instance.
+ - If only this option is specified, then all database files (data and log) will be restored to this location
+ type: str
+ required: false
+ destination_log_directory:
+ description:
+ - Path to restore the database log files to.
+ - This option can only be specified alongside I(destination_data_directory).
+ type: str
+ required: false
+ destination_filestream_directory:
+ description:
+ - Path to restore FileStream data to.
+ - This option can only be specified alongside I(destination_data_directory).
+ type: str
+ required: false
+ restore_time:
+ description:
+ - Specify a datetime string C(HH:MM:SS MM/DD/YYYY) to which you want the database restored to.
+ - Default is to the latest point available in the specified backups.
+ type: str
+ required: false
+ with_replace:
+ description:
+ - Indicates if the restore is allowed to replace an existing database.
+ type: bool
+ required: false
+ default: false
+ keep_replication:
+ description:
+ - Indicates whether replication configuration should be restored as part of the database restore operation.
+ type: bool
+ required: false
+ default: false
+ xp_dirtree:
+ description:
+ - Switch that indicated file scanning should be performed by the SQL Server instance using C(xp_dirtree).
+ - This will scan recursively from the passed in path.
+ - You must have sysadmin role membership on the instance for this to work.
+ type: bool
+ required: false
+ no_xp_dir_recurse:
+ description:
+ - If specified, prevents the C(XpDirTree) process from recursing (its default behaviour).
+ type: bool
+ required: false
+ default: false
+ verify_only:
+ description:
+ - Indicates the restore should be verified only.
+ type: bool
+ required: false
+ default: false
+ maintenance_solution_backup:
+ description:
+ - Switch to indicate the backup files are in a folder structure as created by Ola Hallengreen's maintenance scripts.
+ - This allows for faster file parsing.
+ type: bool
+ required: false
+ default: false
+ ignore_log_backup:
+ description:
+ - Indicates to skip restoring any log backups.
+ type: bool
+ required: false
+ default: false
+ ignore_diff_backup:
+ description:
+ - Indicates to skip restoring any differential backups.
+ type: bool
+ required: false
+ default: false
+ use_destination_default_directories:
+ description:
+ - Switch that tells the restore to use the default Data and Log locations on the target server.
+ - If they don't exist, the function will try to create them.
+ type: bool
+ required: false
+ reuse_source_folder_structure:
+ description:
+ - By default, databases will be migrated to the destination Sql Server's default data and log directories.
+ - You can override this by using C(reuse_source_folder_structure).
+ type: bool
+ required: false
+ destination_file_prefix:
+ description:
+ - This value will be prefixed to B(all) restored files (log and data).
+ type: str
+ required: false
+ restored_database_name_prefix:
+ description:
+ - A string which will be prefixed to the start of the restore Database's name.
+ type: str
+ required: false
+ directory_recurse:
+ description:
+ - If specified the specified directory will be recursed into (overriding the default behaviour).
+ type: bool
+ required: false
+ default: false
+ standby_directory:
+ description:
+ - If a directory is specified the database(s) will be restored into a standby state,
+ with the standby file placed into this directory (which must exist, and be writable by the target Sql Server instance).
+ type: str
+ required: false
+ replace_db_name_in_file:
+ description:
+ - If switch set any occurrence of the original database's name in a data or log file
+ will be replace with the name specified in the I(database_name) option.
+ type: bool
+ required: false
+ destination_file_suffix:
+ description:
+ - This value will be suffixed to B(all) restored files (log and data).
+ type: str
+ required: false
+ keep_cdc:
+ description:
+ - Indicates whether CDC information should be restored as part of the database.
+ type: bool
+ required: false
+ stop_before:
+ description:
+ - Switch to indicate the restore should stop before I(stop_mark) occurs, default is to stop when mark is created.
+ type: bool
+ required: false
+ default: false
+ stop_mark:
+ description:
+ - Marked point in the transaction log to stop the restore at.
+ type: str
+ required: false
+ stop_after_date:
+ description:
+ - By default the restore will stop at the first occurence of I(stop_mark) found in the chain,
+ passing a datetime string C(HH:MM:SS MM/DD/YYYY) will cause it to stop the first I(stop_mark) after that datetime.
+ type: str
+ required: false
+ no_recovery:
+ description:
+ - Indicates if the databases should be recovered after last restore.
+ type: bool
+ required: false
+ default: false
+ max_transfer_size:
+ description:
+ - Sets the size of the unit of transfer. Values must be a multiple of 64kb.
+ type: int
+ required: false
+ default: 0
+ block_size:
+ description:
+ - Specifies block size to use.
+ type: str
+ required: false
+ choices: ['0.5kb','1kb','2kb','4kb','8kb','16kb','32kb','64kb']
+ buffer_count:
+ description:
+ - Number of I/O buffers to use.
+ type: int
+ required: false
+ default: 0
+ azure_credential:
+ description:
+ - The name of the SQL Server credential to be used if restoring from an Azure hosted backup using Storage Access Keys.
+ type: str
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Restore a Database
+ lowlydba.sqlserver.restore:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB
+
+- name: Restore a Database and allow future T-Log restores
+ lowlydba.sqlserver.restore:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB1
+ no_recovery: true
+
+- name: Verify backup files, no restore
+ lowlydba.sqlserver.restore:
+ sql_instance: sql-01.myco.io
+ database: LowlyDB2
+ verify_only: true
+'''
+
+RETURN = r'''
+data:
+ description: Modified output from the C(Restore-DbaDatabase) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.ps1
new file mode 100644
index 000000000..a6b7ff9b0
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.ps1
@@ -0,0 +1,118 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ resource_pool = @{type = 'str'; required = $true }
+ type = @{type = 'str'; required = $false; default = 'Internal'; choices = @('Internal', 'External') }
+ max_cpu_perc = @{type = 'int'; required = $false; }
+ min_cpu_perc = @{type = 'int'; required = $false; }
+ cap_cpu_perc = @{type = 'int'; required = $false; }
+ max_mem_perc = @{type = 'int'; required = $false; }
+ min_mem_perc = @{type = 'int'; required = $false; }
+ min_iops_per_vol = @{type = 'int'; required = $false; }
+ max_iops_per_vol = @{type = 'int'; required = $false; }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$state = $module.Params.state
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$options = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ ResourcePool = $module.Params.resource_pool
+ Type = $module.Params.type
+ MaximumCpuPercentage = $module.Params.max_cpu_perc
+ MinimumCpuPercentage = $module.Params.min_cpu_perc
+ CapCpuPercentage = $module.Params.cap_cpu_perc
+ MaximumMemoryPercentage = $module.params.max_mem_perc
+ MinimumMemoryPercentage = $module.Params.min_mem_perc
+ MinimumIOPSPerVolume = $module.params.min_iops_per_vol
+ MaximumIOPSPerVolume = $module.params.max_iops_per_vol
+}
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+[System.Collections.ArrayList]$compareProperty = @(
+ 'MaximumCpuPercentage',
+ 'MinimumCpuPercentage',
+ 'CapCpuPercentage',
+ 'MinimumMemoryPercentage',
+ 'MaximumMemoryPercentage',
+ 'MinimumIOPSPerVolume',
+ 'MaximumIOPSPerVolume'
+)
+
+$optionsToRemove = @()
+foreach ($item in $options.GetEnumerator() ) {
+ if ($null -eq $item.Value) {
+ $optionsToRemove += $item.Name
+ }
+}
+foreach ($item in $optionsToRemove) {
+ $options.Remove($item)
+ $compareProperty.Remove($item)
+}
+
+try {
+ $getPoolParams = @{
+ SqlInstance = $options.SqlInstance
+ SqlCredential = $options.SqlCredential
+ Type = $options.Type
+ EnableException = $true
+ }
+ $existingResourcePool = Get-DbaRgResourcePool @getPoolParams | Where-Object Name -eq $options.ResourcePool
+
+ if ($state -eq "absent") {
+ if ($null -ne $existingResourcePool) {
+ $removePoolParams = @{
+ SqlInstance = $options.SqlInstance
+ SqlCredential = $options.SqlCredential
+ Type = $options.Type
+ ResourcePool = $options.ResourcePool
+ WhatIf = $checkMode
+ EnableException = $true
+ Confirm = $false
+ }
+ $output = Remove-DbaRgResourcePool @removePoolParams
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "present") {
+ $options.Add("WhatIf", $checkMode)
+ if ($null -ne $existingResourcePool) {
+ # Check for value parity
+ $diff = Compare-Object -ReferenceObject $options -DifferenceObject $existingResourcePool -Property $compareProperty
+ if ($null -ne $diff) {
+ # Set to new values
+ $output = Set-DbaRgResourcePool @options -EnableException
+ $module.Result.changed = $true
+ }
+ }
+ else {
+ # Create a resource pool
+ $output = New-DbaRgResourcePool @options -EnableException
+ $module.Result.changed = $true
+ }
+ }
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring resource pool failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.py
new file mode 100644
index 000000000..08b7aef28
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_resource_pool.py
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: rg_resource_pool
+short_description: Configures a resource pool for use by the Resource Governor
+description:
+ - Creates or modifies a resource pool to be used by the Resource Governor. Default values are handled by the Powershell functions themselves.
+version_added: 0.1.0
+options:
+ resource_pool:
+ description:
+ - Name of the target resource pool.
+ type: str
+ required: true
+ type:
+ description:
+ - Specify the type of resource pool.
+ type: str
+ required: false
+ default: 'Internal'
+ choices: ['Internal', 'External']
+ max_cpu_perc:
+ description:
+ - Maximum CPU Percentage able to be used by queries in this resource pool.
+ type: int
+ required: false
+ min_cpu_perc:
+ description:
+ - Minimum CPU Percentage able to be used by queries in this resource pool.
+ type: int
+ required: false
+ cap_cpu_perc:
+ description:
+ - Cap CPU Percentage able to be used by queries in this resource pool.
+ type: int
+ required: false
+ max_mem_perc:
+ description:
+ - Maximum Memory Percentage able to be used by queries in this resource pool.
+ type: int
+ required: false
+ min_mem_perc:
+ description:
+ - Minimum Memory Percentage able to be used by queries in this resource pool.
+ type: int
+ required: false
+ max_iops_per_vol:
+ description:
+ - Maximum IOPS/volume able to be used by queries in this resource pool.
+ type: int
+ required: false
+ min_iops_per_vol:
+ description:
+ - Minimum IOPS/volume able to be used by queries in this resource pool.
+ type: int
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Enable resource governor
+ lowlydba.sqlserver.resource_governor:
+ sql_instance: sql-01.myco.io
+ enabled: true
+
+- name: Create rg resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ sql_instance: sql-01.myco.io
+ resource_pool: "rpLittle"
+ max_cpu_perc: 5
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Set-DbaRgResourcePool), C(New-DbaRgResourcePool), or C(Remove-DbaRgResourcePool) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.ps1
new file mode 100644
index 000000000..0b225fd18
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.ps1
@@ -0,0 +1,112 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ workload_group = @{type = 'str'; required = $true; }
+ resource_pool = @{type = 'str'; required = $true; }
+ resource_pool_type = @{type = 'str'; required = $false; default = 'Internal'; choices = @('Internal', 'External') }
+ group_max_requests = @{type = 'int'; required = $false; }
+ importance = @{type = 'str'; required = $false; choices = @('Low', 'Medium', 'High') }
+ max_dop = @{type = 'int'; required = $false; }
+ request_max_cpu_time = @{type = 'int'; required = $false; }
+ request_max_mem_grant_perc = @{type = 'int'; required = $false; }
+ request_mem_grant_timeout_sec = @{type = 'int'; required = $false; }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+# Get Csharp utility module
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$options = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ WorkloadGroup = $module.Params.workload_group
+ ResourcePool = $module.Params.resource_pool
+ ResourcePoolType = $module.Params.resource_pool_type
+ GroupMaximumRequests = $module.Params.group_max_requests
+ Importance = $module.Params.importance
+ MaximumDegreeOfParallelism = $module.Params.max_dop
+ RequestMaximumCpuTimeInSeconds = $module.Params.request_max_cpu_time
+ RequestMaximumMemoryGrantPercentage = $module.Params.request_max_mem_grant_perc
+ RequestMemoryGrantTimeoutInSeconds = $module.Params.request_mem_grant_timeout_sec
+}
+$state = $module.Params.state
+$module.Result.changed = $false
+$checkMode = $module.CheckMode
+[System.Collections.ArrayList]$compareProperty = @(
+ 'GroupMaximumRequests',
+ 'Importance',
+ 'MaximumDegreeOfParallelism',
+ 'RequestMaximumCpuTimeInSeconds',
+ 'RequestMemoryGrantTimeoutInSeconds',
+ 'RequestMaximumMemoryGrantPercentage'
+)
+
+# Remove unsupplied params - the dbatools functions handle default value checks
+$optionsToRemove = @()
+foreach ($item in $options.GetEnumerator() ) {
+ if ($null -eq $item.Value) {
+ $optionsToRemove += $item.Name
+ }
+}
+foreach ($item in $optionsToRemove) {
+ $options.Remove($item)
+ $compareProperty.Remove($item)
+}
+
+try {
+ $getResourcePoolSplat = @{
+ SqlInstance = $options.SqlInstance
+ SqlCredential = $options.SqlCredential
+ Type = $options.ResourcePoolType
+ }
+ $existingResourcePool = Get-DbaRgResourcePool @getResourcePoolSplat | Where-Object Name -eq $options.ResourcePool
+ if ($null -eq $existingResourcePool) {
+ $module.FailJson("Failed to lookup parent resource pool '$($options.ResourcePool)'.", $_)
+ }
+ $existingWorkloadGroup = $existingResourcePool.WorkloadGroups | Where-Object Name -eq $options.WorkloadGroup
+
+ if ($state -eq "absent") {
+ if ($null -ne $existingResourcePool) {
+ $output = $existingWorkloadGroup | Remove-DbaRgWorkloadGroup -WhatIf:$checkMode -EnableException
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "present") {
+ if ($null -ne $existingWorkloadGroup) {
+ # Check for value parity
+ $diff = Compare-Object -ReferenceObject $existingWorkloadGroup -DifferenceObject $options -Property $compareProperty
+ # Set to new values
+ if ($null -ne $diff) {
+ $output = Set-DbaRgWorkloadGroup @options -WhatIf:$checkMode -EnableException
+ $module.Result.changed = $true
+ }
+ }
+ else {
+ # Create a new workload group
+ $output = New-DbaRgWorkloadGroup @options -WhatIf:$checkMode -EnableException
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Failed to configure workload group: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.py
new file mode 100644
index 000000000..21cf82617
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/rg_workload_group.py
@@ -0,0 +1,100 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: rg_workload_group
+short_description: Configures a workload group for use by the Resource Governor
+description:
+ - Creates or modifies a workload group to be used by the Resource Governor. Default values are handled by the Powershell functions themselves.
+version_added: 0.1.0
+options:
+ workload_group:
+ description:
+ - Name of the target workload group.
+ type: str
+ required: true
+ resource_pool:
+ description:
+ - Name of the resource pool for the workload group.
+ type: str
+ required: true
+ resource_pool_type:
+ description:
+ - Specify the type of resource pool.
+ type: str
+ required: false
+ default: 'Internal'
+ choices: ['Internal', 'External']
+ group_max_requests:
+ description:
+ - Specifies the maximum number of simultaneous requests that are allowed to execute in the workload group.
+ type: int
+ required: false
+ importance:
+ description:
+ - Specifies the relative importance of a request in the workload group.
+ type: str
+ required: false
+ choices: ['Low', 'Medium', 'High']
+ max_dop:
+ description:
+ - Specifies the maximum degree of parallelism (MAXDOP) for parallel query execution.
+ type: int
+ required: false
+ request_max_cpu_time:
+ description:
+ - Specifies the maximum amount of CPU time, in seconds, that a request can use.
+ type: int
+ required: false
+ request_max_mem_grant_perc:
+ description:
+ - Specifies the maximum amount of memory that a single request can take from the pool.
+ type: int
+ required: false
+ request_mem_grant_timeout_sec:
+ description:
+ - Specifies the maximum time, in seconds, that a query can wait for a memory grant (work buffer memory) to become available.
+ type: int
+ required: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Enable resource governor
+ lowlydba.sqlserver.resource_governor:
+ sql_instance: sql-01.myco.io
+ enabled: true
+
+- name: Create rg resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ sql_instance: sql-01.myco.io
+ resource_pool: "rpLittle"
+ max_cpu_perc: 5
+
+- name: Create rg workload group
+ lowlydba.sqlserver.rg_workload_group:
+ sql_instance: sql-01.myco.io
+ workload_group: rgMyGroup
+ resource_pool: rpLittle
+ resource_pool_type: Internal
+ max_dop: 2
+ state: present
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Set-DbaRgWorkloadGroup), C(New-DbaRgWorkloadGroup), or C(Remove-DbaRgWorkloadGroup) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/sa.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/sa.ps1
new file mode 100644
index 000000000..38042bc68
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/sa.ps1
@@ -0,0 +1,101 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ new_name = @{type = 'str'; required = $false; }
+ password = @{type = 'str'; required = $false; no_log = $true }
+ enabled = @{type = 'bool'; required = $false; default = $true }
+ password_must_change = @{type = 'bool'; required = $false }
+ password_policy_enforced = @{type = 'bool'; required = $false }
+ password_expiration_enabled = @{type = 'bool'; required = $false }
+ }
+}
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$newName = $module.Params.new_name
+if ($null -ne $module.Params.password) {
+ $secPassword = ConvertTo-SecureString -String $module.Params.password -AsPlainText -Force
+}
+$enabled = $module.Params.enabled
+[nullable[bool]]$passwordMustChange = $module.Params.password_must_change
+[nullable[bool]]$passwordExpirationEnabled = $module.Params.password_expiration_enabled
+[nullable[bool]]$passwordPolicyEnforced = $module.Params.password_policy_enforced
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+try {
+ $sa = Get-DbaLogin -SqlInstance $SqlInstance -SqlCredential $sqlCredential -EnableException | Where-Object ID -eq 1
+
+ $setLoginSplat = @{ }
+
+ if ($null -ne $newName) {
+ $setLoginSplat.Add("NewName", $newName)
+ if ($sa.Name -ne $newName) {
+ $changed = $true
+ }
+ }
+ if ($null -ne $passwordExpirationEnabled) {
+ if ($sa.PasswordExpirationEnabled -ne $passwordExpirationEnabled) {
+ $changed = $true
+ }
+ if ($passwordExpirationEnabled -eq $true) {
+ $setLoginSplat.add("PasswordExpirationEnabled", $true)
+ }
+ }
+ if ($null -ne $passwordPolicyEnforced) {
+ if ($sa.PasswordPolicyEnforced -ne $passwordPolicyEnforced) {
+ $changed = $true
+ }
+ if ($passwordPolicyEnforced -eq $true) {
+ $setLoginSplat.add("PasswordPolicyEnforced", $true)
+ }
+ }
+ if ($true -eq $passwordMustChange) {
+ if ($sa.PasswordMustChange -ne $passwordMustChange) {
+ $changed = $true
+ }
+ if ($passwordMustChange -eq $true) {
+ $setLoginSplat.add("PasswordMustChange", $true)
+ }
+ }
+ if ($null -ne $secPassword) {
+ $setLoginSplat.add("SecurePassword", $secPassword)
+ }
+ if ($enabled -eq $false) {
+ $disabled = $true
+ $setLoginSplat.add("Disable", $true)
+ }
+ else {
+ $disabled = $false
+ $setLoginSplat.add("Enable", $true)
+ }
+
+ # Check for changes
+ if (($changed -eq $true) -or ($disabled -ne $sa.IsDisabled) -or ($secPassword)) {
+ $output = $sa | Set-DbaLogin @setLoginSplat -WhatIf:$checkMode -EnableException
+ $module.Result.changed = $true
+ }
+ else {
+ $output = $sa
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.exitJson()
+}
+catch {
+ $module.FailJson("Configuring 'sa' login failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/sa.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/sa.py
new file mode 100644
index 000000000..6aa45fe36
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/sa.py
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: sa
+short_description: Configure the C(sa) login for security best practices
+description:
+ - Rename, disable, and reset the password for the C(sa) login on a SQL Server instance per best practices.
+options:
+ password:
+ description:
+ - Password for the login.
+ type: str
+ required: false
+ new_name:
+ description:
+ - The new name to rename the C(sa) login to.
+ type: str
+ required: false
+ enabled:
+ description:
+ - Whether the login is enabled or disabled.
+ type: bool
+ required: false
+ default: true
+ version_added: '0.4.0'
+ password_must_change:
+ description:
+ - Enforces user must change password at next login.
+ - When specified, will enforce I(password_expiration_enabled) and I(password_policy_enforced) as they are required.
+ type: bool
+ required: false
+ password_policy_enforced:
+ description:
+ - Enforces password complexity policy.
+ type: bool
+ required: false
+ password_expiration_enabled:
+ description:
+ - Enforces password expiration policy. Requires I(password_policy_enforced=true).
+ type: bool
+ required: false
+version_added: 0.3.0
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Disable sa login
+ lowlydba.sqlserver.sa:
+ sql_instance: sql-01.myco.io
+ disable: true
+
+- name: Rename sa login
+ lowlydba.sqlserver.sa:
+ sql_instance: sql-01.myco.io
+ new_name: 'notthesayourelookingfor'
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Set-DbaLogin) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.ps1
new file mode 100644
index 000000000..f4ac80fdc
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.ps1
@@ -0,0 +1,59 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# (c) 2021, Sudhir Koduri (@kodurisudhir)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ name = @{type = 'str'; required = $true }
+ value = @{type = 'int'; required = $true }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$name = $module.Params.name
+$value = $module.Params.value
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+try {
+ $existingConfig = Get-DbaSpConfigure -SqlInstance $sqlInstance -SqlCredential $sqlCredential -Name $name -EnableException
+
+ if ($existingConfig.ConfiguredValue -ne $value) {
+ $setSpConfigureSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Name = $name
+ Value = $value
+ WhatIf = $checkMode
+ EnableException = $true
+ }
+ $output = Set-DbaSpConfigure @setSpConfigureSplat
+
+ if ($existingConfig.IsDynamic -eq $false) {
+ $output | Add-Member -MemberType NoteProperty -Name "RestartRequired" -Value $true
+ }
+ $module.Result.changed = $true
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+
+catch {
+ $module.FailJson("sp_configure change failed.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.py
new file mode 100644
index 000000000..91e060e86
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_configure.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# (c) 2021, Sudhir Koduri (@kodurisudhir)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: sp_configure
+short_description: Make instance level system configuration changes via C(sp_configure)
+description:
+ - Read instance level system configuration for a given configuration and update to a new value as provided.
+version_added: 0.1.0
+options:
+ name:
+ description:
+ - Name of the configuration that will be changed.
+ type: str
+ required: true
+ value:
+ description:
+ - New value the configuration will be set to.
+ type: int
+ required: true
+author: "Sudhir Koduri (@kodurisudhir)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Enable remote DAC connection
+ lowlydba.sqlserver.sp_configure:
+ sql_instance: sql-01.myco.io
+ name: RemoteDacConnectionsEnabled
+ value: 1
+'''
+
+RETURN = r'''
+data:
+ description:
+ - Output from the C(Set-DbaSpConfigure) function.
+ - RestartRequired returned if the setting requires a service restart to take effect.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.ps1
new file mode 100644
index 000000000..45fc5ebdd
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.ps1
@@ -0,0 +1,57 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ database = @{type = 'str'; required = $true }
+ local_file = @{type = 'str'; required = $false }
+ force = @{type = 'bool'; required = $false; default = $false }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$database = $module.Params.database
+$localFile = $module.Params.local_file
+$force = $module.Params.force
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+$whoIsActiveSplat = @{
+ SqlInstance = $SqlInstance
+ SqlCredential = $SqlCredential
+ Database = $Database
+ WhatIf = $checkMode
+ Force = $force
+ Confirm = $false
+ EnableException = $true
+}
+if ($null -ne $LocalFile) {
+ $whoIsActiveSplat.LocalFile = $LocalFile
+}
+
+try {
+ $output = Install-DbaWhoIsActive @whoIsActiveSplat
+ $module.Result.changed = $true
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+
+catch {
+ $module.FailJson("Installing sp_WhoIsActive failed.", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.py
new file mode 100644
index 000000000..8aed1036a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/sp_whoisactive.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: sp_whoisactive
+short_description: Install/update C(sp_whoisactive) by Adam Mechanic
+description:
+ - A wrapper for C(Install-DbaWhoIsActive) to fetch the latest version of the script, or install from a local cached version.
+version_added: 0.1.0
+options:
+ local_file:
+ description:
+ - Specifies the path to a local file to install sp_WhoisActive from.
+ - This can be either the zip file as distributed by the website or the expanded SQL script.
+ - If this option is not specified, the latest version will be downloaded and installed from https://github.com/amachanic/sp_whoisactive/releases
+ type: str
+ required: false
+ database:
+ description:
+ - Name of the target database.
+ type: str
+ required: true
+ force:
+ description:
+ - If this switch is enabled, then C(sp_WhoisActive) will be downloaded from the internet even if previously cached.
+ type: bool
+ default: false
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Install/Update sp_whoisactive
+ lowlydba.sqlserver.sp_whoisactive:
+ sql_instance: sql-01.myco.io
+ database: lowlydb
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Install-DbaWhoIsActive) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/spn.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/spn.ps1
new file mode 100644
index 000000000..12c953bcc
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/spn.ps1
@@ -0,0 +1,69 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# (c) 2021, Sudhir Koduri (@kodurisudhir)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ computer_username = @{ type = 'str'; required = $false }
+ computer_password = @{ type = 'str'; required = $false; no_log = $true; }
+ computer = @{ type = 'str'; required = $true }
+ service_account = @{ type = 'str'; required = $true; }
+ state = @{ type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+ required_together = @(
+ , @('computer_username', 'computer_password')
+ )
+}
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
+if ($null -ne $module.Params.computer_username) {
+ [securestring]$secPassword = ConvertTo-SecureString $Module.Params.computer_password -AsPlainText -Force
+ [pscredential]$computerCredential = New-Object System.Management.Automation.PSCredential ($Module.Params.computer_username, $secPassword)
+}
+$computer = $module.Params.computer
+$serviceAccount = $module.Params.service_account
+$serviceClass = "MSSQLSvc"
+$spn = "$serviceClass\$computer"
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $existingSPN = Get-DbaSpn -ComputerName $computer -Credential $computerCredential -AccountName $serviceAccount | Where-Object spn -eq $spn
+
+ if ($state -eq "present") {
+ if ($null -ne $existingSPN) {
+ # SPNs can only be added and removed, not modified
+ $module.ExitJson()
+ }
+ elseif ($null -eq $existingSPN) {
+ $output = Set-DbaSpn -SPN $spn -ServiceAccount $serviceAccount -Credential $computerCredential
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($state -eq "absent") {
+ if ($null -ne $existingSPN) {
+ $output = Remove-DbaSpn -SPN $spn -ServiceAccount $serviceAccount -Credential $computerCredential
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring SPN failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/spn.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/spn.py
new file mode 100644
index 000000000..0fabb9346
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/spn.py
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: spn
+short_description: Configures SPNs for SQL Server
+description:
+ - Configures SPNs for SQL Server.
+version_added: 0.6.0
+options:
+ computer_username:
+ description:
+ - Username of a credential to connect to Active Directory with.
+ type: str
+ required: false
+ computer_password:
+ description:
+ - Password of a credential to connect to Active Directory with.
+ type: str
+ required: false
+ computer:
+ description:
+ - The host or alias to configure the SPN for. Can include the port in the format C(host:port).
+ type: str
+ required: true
+ service_account:
+ description:
+ - The account you want the SPN added to. Will be looked up if not provided.
+ type: str
+ required: true
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.state
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_win
+'''
+
+EXAMPLES = r'''
+- name: Add server SPN
+ lowlydba.sqlserver.spn:
+ computer: sql-01.myco.io
+ service_account: myco\sql-svc
+
+- name: Create an AG Listener
+ lowlydba.sqlserver.ag_listener:
+ sql_instance_primary: sql-01.myco.io
+ ag_name: AG_MyDatabase
+ listener_name: aglMyDatabase
+ ip_address: 10.0.20.20,10.1.77.77
+ subnet_ip: 255.255.252.0
+ subnet_mask: 255.255.255.0
+
+- name: Add SPN for new AG listener on port 1433
+ lowlydba.sqlserver.spn:
+ computer: aglMyDatabase.myco.io:1433
+ service_account: myco\sql-svc
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Set-DbaSpn) or C(Remove-DbaSpn) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.ps1
new file mode 100644
index 000000000..bff87bd9a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.ps1
@@ -0,0 +1,69 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# (c) 2021, Sudhir Koduri (@kodurisudhir)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ username = @{type = 'str'; required = $false }
+ password = @{type = 'str'; required = $false; no_log = $true }
+ port = @{type = 'int'; required = $true }
+ ip_address = @{type = 'str'; required = $false }
+ force = @{type = 'bool'; required = $false; default = $false }
+ }
+ required_together = @(
+ , @('username', 'password')
+ )
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+if ($null -ne $module.Params.username) {
+ [securestring]$secPassword = ConvertTo-SecureString $Module.Params.password -AsPlainText -Force
+ [pscredential]$credential = New-Object System.Management.Automation.PSCredential ($Module.Params.username, $secPassword)
+}
+$port = $module.Params.port
+$ipAddress = $module.Params.ip_address
+$checkMode = $module.CheckMode
+$force = $module.Params.force
+$module.Result.changed = $false
+$PSDefaultParameterValues = @{ "*:EnableException" = $true; "*:Confirm" = $false; "*:WhatIf" = $checkMode }
+
+try {
+ $tcpPortSplat = @{
+ SqlInstance = $SqlInstance
+ Credential = $credential
+ Port = $port
+ Force = $force
+ }
+ if ($ipAddress) {
+ $tcpPortSplat.Add("IPAddress", $ipAddress)
+ }
+ $output = Set-DbaTcpPort @tcpPortSplat
+
+ if ($output.Changes.Count -gt 0 -or $checkMode) {
+ $module.Result.changed = $true
+ if ($force -ne $true) {
+ $output | Add-Member -MemberType NoteProperty -Name "RestartRequired" -Value $true
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring TCP port failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.py
new file mode 100644
index 000000000..f97013f8a
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/tcp_port.py
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: tcp_port
+short_description: Sets the TCP port for the instance
+description:
+ - Sets the TCP port for a SQL Server instance.
+version_added: 0.10.0
+options:
+ username:
+ description:
+ - Username for alternative credential to authenticate with Windows.
+ type: str
+ required: false
+ password:
+ description:
+ - Password for alternative credential to authenticate with Windows.
+ type: str
+ required: false
+ port:
+ description:
+ - Port for SQL Server to listen on.
+ type: int
+ required: true
+ ip_address:
+ description:
+ - IPv4 address.
+ type: str
+ required: false
+ force:
+ description:
+ - Restart SQL Server and SQL Agent services automatically.
+ type: bool
+ required: false
+ default: false
+ version_added: 1.2.0
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_win
+'''
+
+EXAMPLES = r'''
+- name: Set the default port
+ lowlydba.sqlserver.tcp_port:
+ sql_instance: sql-01.myco.io
+ port: 1433
+
+- name: Set a non-standard default port
+ lowlydba.sqlserver.tcp_port:
+ sql_instance: sql-01.myco.io
+ port: 1933
+'''
+
+RETURN = r'''
+data:
+ description:
+ - Output from the C(Set-DbaTcpPort) function.
+ - RestartRequired returned if the change requires a service restart to take effect.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.ps1
new file mode 100644
index 000000000..9e0a1434c
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.ps1
@@ -0,0 +1,67 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# (c) 2021, Sudhir Koduri (@kodurisudhir)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+# Get Csharp utility module
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ trace_flag = @{type = 'int'; required = $true }
+ enabled = @{type = 'bool'; required = $true }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$traceFlag = $module.Params.trace_flag
+$enabled = $module.Params.enabled
+$checkMode = $module.CheckMode
+$module.Result.changed = $false
+
+try {
+ $traceFlagSplat = @{
+ SqlInstance = $SqlInstance
+ SqlCredential = $sqlCredential
+ TraceFlag = $traceFlag
+ EnableException = $true
+ }
+ $existingFlag = Get-DbaTraceFlag @traceFlagSplat
+
+ if ($enabled -eq $true) {
+ if (-not $checkMode) {
+ $enabled = Enable-DbaTraceFlag @traceFlagSplat
+ $output = $enabled | Select-Object -Property InstanceName, SqlInstance, TraceFlag
+ }
+ if ($existingFlag.TraceFlag -notcontains $traceFlag) {
+ $module.Result.changed = $true
+ }
+ }
+ elseif ($enabled -eq $false) {
+
+ if (-not $checkMode) {
+ $disabled = Disable-DbaTraceFlag @traceFlagSplat
+ $output = $disabled | Select-Object -Property InstanceName, SqlInstance, TraceFlag
+ }
+ if ($existingFlag.TraceFlag -contains $traceFlag) {
+ $module.Result.changed = $true
+ }
+ }
+
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Configuring trace flag failed: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.py
new file mode 100644
index 000000000..c8139e510
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/traceflag.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# (c) 2021, Sudhir Koduri (@kodurisudhir)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: traceflag
+short_description: Enable or disable global trace flags on a SQL Server instance
+description:
+ - Enable\Disable global trace flag on a SQL Instance. This trace flag takes affect immediately and does not require SQL Instance restart.
+ - This setting does not persist after restart.
+version_added: 0.1.0
+options:
+ trace_flag:
+ description:
+ - Trace Flag number.
+ type: int
+ required: true
+ enabled:
+ description:
+ - Flag to enable or disable the trace flag.
+ type: bool
+ required: true
+author: "Sudhir Koduri (@kodurisudhir)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+'''
+
+EXAMPLES = r'''
+- name: Eliminate successful backup information from SQL Error Log
+ lowlydba.sqlserver.traceflag:
+ sql_instance: sql-01.myco.io
+ trace_flag: 3226
+ enabled: true
+
+- name: Disable trace flag
+ lowlydba.sqlserver.traceflag:
+ sql_instance: sql-01.myco.io
+ trace_flag: 3226
+ enabled: false
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(Enable-DbaTraceFlag) or C(Disable-DbaTraceFlag) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/user.ps1 b/ansible_collections/lowlydba/sqlserver/plugins/modules/user.ps1
new file mode 100644
index 000000000..29bbd69b4
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/user.ps1
@@ -0,0 +1,142 @@
+#!powershell
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+#AnsibleRequires -CSharpUtil Ansible.Basic
+#AnsibleRequires -PowerShell ansible_collections.lowlydba.sqlserver.plugins.module_utils._SqlServerUtils
+#Requires -Modules @{ ModuleName="dbatools"; ModuleVersion="1.1.112" }
+
+$ErrorActionPreference = "Stop"
+
+$spec = @{
+ supports_check_mode = $true
+ options = @{
+ login = @{type = 'str'; required = $true }
+ database = @{type = 'str'; required = $true }
+ username = @{type = 'str'; required = $true }
+ default_schema = @{type = 'str'; required = $false ; default = 'dbo' }
+ external_provider = @{type = 'bool'; required = $false }
+ state = @{type = 'str'; required = $false; default = 'present'; choices = @('present', 'absent') }
+ }
+}
+
+$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec, @(Get-LowlyDbaSqlServerAuthSpec))
+$sqlInstance, $sqlCredential = Get-SqlCredential -Module $module
+$login = $module.Params.login
+$username = $module.Params.username
+$database = $module.Params.database
+$defaultSchema = $module.Params.default_schema
+[nullable[bool]]$externalProvider = $module.Params.external_provider
+$state = $module.Params.state
+$checkMode = $module.CheckMode
+
+$module.Result.changed = $false
+
+$getUserSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ User = $username
+ Login = $login
+ Database = $database
+ EnableException = $true
+}
+$existingUser = Get-DbaDbUser @getUserSplat
+
+if ($state -eq "absent") {
+ if ($null -ne $existingUser) {
+ try {
+ $removeUserSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ User = $username
+ Database = $database
+ EnableException = $true
+ WhatIf = $checkMode
+ Force = $true
+ Confirm = $false
+ }
+ $output = Remove-DbaDbUser @removeUserSplat
+ $module.Result.changed = $true
+ }
+ catch {
+ $module.FailJson("Removing user failed: $($_.Exception.Message)", $_)
+ }
+ }
+}
+elseif ($state -eq "present") {
+ # User exists
+ if ($null -ne $existingUser) {
+ if ($defaultSchema -ne $existingUser.DefaultSchema) {
+ try {
+ # No Set-DbaDbUser command exists, use SMO
+ $getSchemaSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Database = $database
+ Schema = $defaultSchema
+ IncludeSystemDatabases = $true
+ IncludeSystemSchemas = $true
+ EnableException = $true
+ }
+ $existingSchema = Get-DbaDbSchema @getSchemaSplat
+
+ if ($null -ne $existingSchema) {
+ # do schema change
+ if (-not($checkMode)) {
+ $existingUser.DefaultSchema = $defaultSchema
+ $existingUser.Alter()
+ $output = $existingUser
+ }
+ $module.result.changed = $true
+ }
+ else {
+ $module.FailJson("Schema '$defaultSchema' not found in [$database].")
+ }
+ }
+ catch {
+ $module.FailJson("Configuring user failed: $($_.Exception.Message)", $_)
+ }
+ }
+ }
+ # New User
+ else {
+ try {
+ $newUserSplat = @{
+ SqlInstance = $sqlInstance
+ SqlCredential = $sqlCredential
+ Username = $username
+ Login = $login
+ Database = $database
+ DefaultSchema = $defaultSchema
+ EnableException = $true
+ WhatIf = $checkMode
+ Force = $true
+ Confirm = $false
+ }
+ if ($externalProvider -eq $true) {
+ $newUserSplat.add("ExternalProvider", $true)
+ }
+ $output = New-DbaDbUser @newUserSplat
+ $module.result.changed = $true
+ }
+ catch {
+ $module.FailJson("Creating user failed: $($_.Exception.Message)", $_)
+ }
+ }
+ # If not in check mode, add extra fields we can change to default display set
+ if ($null -ne $output) {
+ $output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("DefaultSchema")
+ }
+}
+try {
+ if ($null -ne $output) {
+ $resultData = ConvertTo-SerializableObject -InputObject $output
+ $module.Result.data = $resultData
+ }
+ $module.ExitJson()
+}
+catch {
+ $module.FailJson("Failure: $($_.Exception.Message)", $_)
+}
diff --git a/ansible_collections/lowlydba/sqlserver/plugins/modules/user.py b/ansible_collections/lowlydba/sqlserver/plugins/modules/user.py
new file mode 100644
index 000000000..b9c36d069
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/plugins/modules/user.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2022, John McCall (@lowlydba)
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+DOCUMENTATION = r'''
+---
+module: user
+short_description: Configures a user within a database
+description:
+ - Creates, modifies, or removes a user in a database.
+version_added: 1.1.0
+options:
+ login:
+ description:
+ - Name of the login that the user is mapped to.
+ type: str
+ required: true
+ database:
+ description:
+ - Database for the user.
+ type: str
+ required: true
+ username:
+ description:
+ - Name of the user.
+ type: str
+ required: true
+ external_provider:
+ description:
+ - Specifies that the user is for Azure AD Authentication. Only used when creating a new user, this cannot be modified for an existing user.
+ type: bool
+ required: false
+ default_schema:
+ description:
+ - The default database schema for the user.
+ type: str
+ required: false
+ default: "dbo"
+author: "John McCall (@lowlydba)"
+requirements:
+ - L(dbatools,https://www.powershellgallery.com/packages/dbatools/) PowerShell module
+extends_documentation_fragment:
+ - lowlydba.sqlserver.sql_credentials
+ - lowlydba.sqlserver.attributes.check_mode
+ - lowlydba.sqlserver.attributes.platform_all
+ - lowlydba.sqlserver.state
+'''
+
+EXAMPLES = r'''
+- name: Create a user
+ lowlydba.sqlserver.user:
+ sql_instance: sql-01.myco.io
+ login: TheIntern
+ username: TheIntern
+ database: InternProject1
+
+- name: Change user's schema
+ lowlydba.sqlserver.login:
+ sql_instance: sql-01.myco.io
+ login: TheIntern
+ username: TheIntern
+ database: InternProject1
+ default_schema: dev
+
+- name: Remove a user
+ lowlydba.sqlserver.login:
+ sql_instance: sql-01.myco.io
+ login: TheIntern
+ username: TheIntern
+ database: InternProject1
+ state: absent
+'''
+
+RETURN = r'''
+data:
+ description: Output from the C(New-DbaDbUser), C(Get-DbaDbUser), or C(Remove-DbaDbUser) function.
+ returned: success, but not in check_mode.
+ type: dict
+'''
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/.ansible-lint b/ansible_collections/lowlydba/sqlserver/tests/integration/.ansible-lint
new file mode 100644
index 000000000..274a44617
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/.ansible-lint
@@ -0,0 +1,10 @@
+# .ansible-lint file for integration tests
+---
+skip_list:
+ - unnamed-task
+ - truthy
+ - var-naming
+ - meta-no-info
+ - ignore-errors
+ - risky-file-permissions
+ - command-instead-of-shell
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/integration_config.sample.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/integration_config.sample.yml
new file mode 100644
index 000000000..dece838f3
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/integration_config.sample.yml
@@ -0,0 +1,4 @@
+---
+sqlserver_instance: sqlserver
+sqlserver_username: sa
+sqlserver_password: L0wlydb4
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/inventory b/ansible_collections/lowlydba/sqlserver/tests/integration/inventory
new file mode 100644
index 000000000..7c937f87e
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/inventory
@@ -0,0 +1,2 @@
+[testgroup]
+testhost ansible_connection="local" ansible_pipelining="yes" ansible_python_interpreter="/usr/bin/python3"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/inventory.winrm.ci b/ansible_collections/lowlydba/sqlserver/tests/integration/inventory.winrm.ci
new file mode 100644
index 000000000..ac1437375
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/inventory.winrm.ci
@@ -0,0 +1,8 @@
+[windows]
+runner ansible_host=127.0.0.1 ansible_user=admin ansible_password=pass123@
+
+[windows:vars]
+ansible_connection=psrp
+ansible_port=5986
+ansible_psrp_auth=basic
+ansible_psrp_cert_validation=ignore
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/tasks/main.yml
new file mode 100644
index 000000000..46684e965
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job/tasks/main.yml
@@ -0,0 +1,146 @@
+---
+- name: Var block
+ vars:
+ category_name: "Integration Tests"
+ job_name: "Integration Job"
+ description: "This test is not a test."
+ enabled: true
+ module_defaults:
+ lowlydba.sqlserver.agent_job:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ category: "{{ category_name }}"
+ job: "{{ job_name }}"
+ description: "{{ description }}"
+ force: true
+ enabled: "{{ enabled }}"
+ tags: ["agent_job"]
+ block:
+ # SQL Agent / SMO has delays on returning new data sometimes, and is worse on CI runners -
+ # so explicitly pre-create the category to make sure we get timely & accurate results later
+ - name: Prep agent job category
+ lowlydba.sqlserver.agent_job_category:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ category: "{{ category_name }}"
+
+ - name: Create agent job
+ lowlydba.sqlserver.agent_job:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Category == "{{ category_name }}"
+ - result.data.Enabled is true
+ - result.data.Name == "{{ job_name }}"
+ - result.data.OwnerLoginName == "{{ sqlserver_username }}"
+ - result.data.HasSchedule is false
+
+ - name: Create agent job step one
+ lowlydba.sqlserver.agent_job_step:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ job: "{{ job_name }}"
+ step_name: "Step 1"
+ step_id: 1
+
+ - name: Create agent job step two
+ lowlydba.sqlserver.agent_job_step:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ job: "{{ job_name }}"
+ step_name: "Step 2"
+ step_id: 2
+
+ - name: Set start job step id
+ lowlydba.sqlserver.agent_job:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ job: "{{ job_name }}"
+ start_step_id: 2
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result is changed
+
+ - name: No change
+ lowlydba.sqlserver.agent_job:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ job: "{{ job_name }}"
+ start_step_id: 2
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Remove agent job
+ lowlydba.sqlserver.agent_job:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Status == "Dropped"
+
+ - name: Create new agent job
+ lowlydba.sqlserver.agent_job:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Category == "{{ category_name }}"
+ - result.data.Enabled is true
+ - result.data.OwnerLoginName == "{{ sqlserver_username }}"
+ - result.data.HasSchedule is false
+ - result is changed
+
+ - name: Change agent job
+ lowlydba.sqlserver.agent_job:
+ owner_login: "sa"
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Category == "{{ category_name }}"
+ - result.data.Enabled is false
+ - result.data.Name == "{{ job_name }}"
+ - result.data.OwnerLoginName == "sa"
+ - result.data.HasSchedule is false
+ - result is changed
+
+ - name: Change agent job
+ lowlydba.sqlserver.agent_job:
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Category == "{{ category_name }}"
+ - result.data.Enabled is true
+ - result.data.Name == "{{ job_name }}"
+ - result is changed
+
+ always:
+ - name: Cleanup agent job
+ lowlydba.sqlserver.agent_job:
+ state: "absent"
+
+ - name: Cleanup agent job category
+ lowlydba.sqlserver.agent_job_category:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ category: "{{ category_name }}"
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/tasks/main.yml
new file mode 100644
index 000000000..739112a41
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_category/tasks/main.yml
@@ -0,0 +1,69 @@
+---
+- name: Var block
+ vars:
+ category_name: "Integration Tests"
+ module_defaults:
+ lowlydba.sqlserver.agent_job_category:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ category: "{{ category_name }}"
+ tags: ["agent_job_category"]
+ block:
+ - name: Create job category
+ lowlydba.sqlserver.agent_job_category:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Name == "{{ category_name }}"
+ - result.data.ID != None
+ - result.data.CategoryType == "LocalJob"
+ - result.data.JobCount == 0
+
+ - name: Create existing job category
+ lowlydba.sqlserver.agent_job_category:
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Remove job category in check mode
+ lowlydba.sqlserver.agent_job_category:
+ state: absent
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Remove job category
+ lowlydba.sqlserver.agent_job_category:
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Create new job category
+ lowlydba.sqlserver.agent_job_category:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Name == "{{ category_name }}"
+ - result.data.ID != None
+ - result.data.CategoryType == "LocalJob"
+ - result.data.JobCount == 0
+ - result is changed
+
+ always:
+ - name: Remove job category
+ lowlydba.sqlserver.agent_job_category:
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/tasks/main.yml
new file mode 100644
index 000000000..5bd266548
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_schedule/tasks/main.yml
@@ -0,0 +1,169 @@
+---
+- name: Var block
+ vars:
+ forced_schedule_name: "Forced"
+ job_name: "Agent Job Schedule Integration Test"
+ start_date: "30200525"
+ start_time: "000000"
+ frequency_type: "Daily"
+ frequency_interval: "Everyday"
+ frequency_subday_type: "Hours"
+ frequency_subday_interval: 5
+ frequency_relative_interval: "First"
+ end_date: "30200525"
+ end_time: "000929"
+ start_date_result: "3020-05-25T00:00:00"
+ end_date_result: "3020-05-25T00:00:00"
+ module_defaults:
+ lowlydba.sqlserver.agent_job:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ job: "{{ job_name }}"
+ lowlydba.sqlserver.agent_job_schedule:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ start_date: "{{ start_date }}"
+ start_time: "{{ start_time }}"
+ end_date: "{{ end_date }}"
+ end_time: "{{ end_time }}"
+ frequency_type: "{{ frequency_type }}"
+ frequency_interval: "{{ frequency_interval }}"
+ frequency_subday_type: "{{ frequency_subday_type }}"
+ frequency_subday_interval: "{{ frequency_subday_interval }}"
+ frequency_relative_interval: "{{ frequency_relative_interval }}"
+ job: "{{ job_name }}"
+ tags: ["agent_job_schedule"]
+ block:
+ - name: Pre-create agent job
+ lowlydba.sqlserver.agent_job:
+ force: true
+ state: present
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Create job schedule with force
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ force: true
+ state: present
+ register: result
+ - assert:
+ that:
+ - result.data.ScheduleUid != None
+ - result.data.ActiveStartDate == "3020-05-25T00:00:00.0000000"
+ - result.data.ActiveEndDate == "3020-05-25T00:00:00.0000000"
+ - result.data.JobCount == 1
+ - result.data.IsEnabled is true
+ - result.data.ScheduleName == "{{ forced_schedule_name }}"
+ - result is changed
+
+ - name: Change job schedule & disable
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ start_date: "30210525"
+ end_date: "30210525"
+ enabled: false
+ state: present
+ register: result
+ - assert:
+ that:
+ - result.data.ScheduleUid != None
+ - result.data.ActiveStartDate == "3021-05-25T00:00:00.0000000"
+ - result.data.ActiveEndDate == "3021-05-25T00:00:00.0000000"
+ - result.data.JobCount == 1
+ - result.data.IsEnabled is false
+ - result.data.ScheduleName == "{{ forced_schedule_name }}"
+ - result is changed
+
+ - name: Enable job schedule
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ enabled: true
+ state: present
+ register: result
+ - assert:
+ that:
+ - result.data.ScheduleUid != None
+ - result.data.JobCount == 1
+ - result.data.IsEnabled is true
+ - result.data.ScheduleName == "{{ forced_schedule_name }}"
+ - result is changed
+
+ - name: No change
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ enabled: true
+ state: present
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Remove job schedule
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ force: true
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Remove non-existent job schedule
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ force: true
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Create job schedule in checkmode
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ start_date: "30210526"
+ end_date: "30210526"
+ enabled: false
+ state: present
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify unchanged in checkmode
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ start_date: "30210526"
+ end_date: "30210526"
+ enabled: false
+ state: present
+ register: result
+ - assert:
+ that:
+ - result.data.ScheduleUid != None
+ - result.data.ActiveStartDate == "3021-05-26T00:00:00.0000000"
+ - result.data.ActiveEndDate == "3021-05-26T00:00:00.0000000"
+ - result.data.JobCount == 1
+ - result.data.IsEnabled is false
+ - result.data.ScheduleName == "{{ forced_schedule_name }}"
+ - result is changed
+
+ # Cleanup
+ always:
+ # Also cleans up associated schedules
+ - name: Remove test agent job
+ lowlydba.sqlserver.agent_job:
+ force: true
+ state: absent
+
+ - name: Remove job schedule
+ lowlydba.sqlserver.agent_job_schedule:
+ schedule: "{{ forced_schedule_name }}"
+ force: true
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/tasks/main.yml
new file mode 100644
index 000000000..1cfbec421
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/agent_job_step/tasks/main.yml
@@ -0,0 +1,167 @@
+---
+- name: Var block
+ vars:
+ category_name: "Integration Tests"
+ job_name: "Ansible Integration Job Step Test"
+ job_step1: "One, you're like a dream come true"
+ job_step2: "Two, just wanna be with you"
+ job_step3: "Three, girl, it's plain to see"
+ module_defaults:
+ lowlydba.sqlserver.agent_job:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ lowlydba.sqlserver.agent_job_step:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ job: "{{ job_name }}"
+ tags: ["agent_job_step"]
+ block:
+ - name: Create agent job
+ lowlydba.sqlserver.agent_job:
+ job: "{{ job_name }}"
+ force: true
+ register: result
+ - assert:
+ that:
+ - result.data.Name == "{{ job_name }}"
+
+ - name: Create agent job step one
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step1 }}"
+ step_id: 1
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Name == "{{ job_step1 }}"
+ - result.data.ID == 1
+ - result.data.DatabaseName == "master"
+ - result.data.State == "Existing"
+ - result is changed
+
+ - name: Create agent job step two in checkmode
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step2 }}"
+ step_id: 2
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify create agent job step two in checkmode works
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step2 }}"
+ step_id: 2
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Name == "{{ job_step2 }}"
+ - result.data.ID == 2
+ - result.data.DatabaseName == "master"
+ - result.data.State == "Existing"
+ - result is changed
+
+ - name: Create agent job step three
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step3 }}"
+ step_id: 3
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Name == "{{ job_step3 }}"
+ - result.data.ID == 3
+ - result.data.DatabaseName == "master"
+ - result.data.State == "Existing"
+
+ - name: Create duplicate agent job step
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step3 }}"
+ step_id: 4
+ register: result
+ failed_when: result is not failed
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Change agent job step in checkmode
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step3 }}"
+ step_id: 3
+ database: "model"
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify change agent job step in checkmode works
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step3 }}"
+ step_id: 3
+ database: "model"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Name == "{{ job_step3 }}"
+ - result.data.ID == 3
+ - result.data.DatabaseName == "model"
+ - result.data.State == "Existing"
+ - result is changed
+
+ - name: Verify no change works
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step3 }}"
+ step_id: 3
+ database: "model"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.Name == "{{ job_step3 }}"
+ - result.data.ID == 3
+ - result.data.DatabaseName == "model"
+ - result.data.State == "Existing"
+ - result is not changed
+
+ - name: Remove agent job step
+ lowlydba.sqlserver.agent_job_step:
+ step_name: "{{ job_step1 }}"
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Remove agent job step in checkmode
+ lowlydba.sqlserver.agent_job_step:
+ step_id: 2
+ state: "absent"
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify remove agent job step in checkmode works
+ lowlydba.sqlserver.agent_job_step:
+ step_id: 2
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ always:
+ - name: Cleanup agent job
+ lowlydba.sqlserver.agent_job:
+ job: "{{ job_name }}"
+ state: "absent"
+ register: result
+ - assert:
+ that: result.data.Status == "Dropped"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/tasks/main.yml
new file mode 100644
index 000000000..7678c29fc
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/backup/tasks/main.yml
@@ -0,0 +1,25 @@
+---
+- name: Var block
+ vars:
+ database_name: "master"
+ tags: ["backup"]
+ block:
+ - name: Backup a database
+ lowlydba.sqlserver.backup:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ database_name }}"
+ block_size: "16kb"
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.Database == "{{ database_name }}"
+ - result.data.Type == "Full"
+ - result.data.TotalSize != None
+ - result.data.DeviceType == "Disk"
+ - result.data.Start != None
+ - result.data.End != None
+ - result.data.Duration != None
+ - result is changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/tasks/main.yml
new file mode 100644
index 000000000..0a68c4bc8
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/credential/tasks/main.yml
@@ -0,0 +1,85 @@
+---
+- name: Var block
+ vars:
+ identity: "TestIdentity"
+ name: "MrSmith"
+ password: "Password123!"
+ mapped_class_type: "None"
+ provider_name: ""
+ module_defaults:
+ lowlydba.sqlserver.credential:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ identity: "{{ identity }}"
+ tags: ["credential"]
+ block:
+ - name: Create a new credential
+ lowlydba.sqlserver.credential:
+ name: "{{ name }}"
+ password: "{{ password }}"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Identity == "{{ identity }}"
+ - result.data.Name == "{{ name }}"
+ - result is changed
+
+ - name: Try to add the same credential
+ lowlydba.sqlserver.credential:
+ name: "{{ name }}"
+ password: "{{ password }}"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Identity == "{{ identity }}"
+ - result.data.Name == "{{ name }}"
+ - result is not changed
+
+ - name: Replace an existing credential
+ lowlydba.sqlserver.credential:
+ force: true
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Identity == "{{ identity }}"
+ - result.data.Name == "{{ identity }}"
+ - result is changed
+
+ - name: Drop credential
+ lowlydba.sqlserver.credential:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result is changed
+
+ - name: Create credential in check mode
+ lowlydba.sqlserver.credential:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ identity: "{{ identity }}"
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ always:
+ - name: Drop credential
+ lowlydba.sqlserver.credential:
+ state: "absent"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/tasks/main.yml
new file mode 100644
index 000000000..93c9368c7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/database/tasks/main.yml
@@ -0,0 +1,92 @@
+---
+- name: Var block
+ vars:
+ database_name: "sqlserver_integration_db"
+ maxdop: 1
+ secondary_maxdop: 4
+ owner_name: sa
+ recovery_model: Simple
+ compatibility_low: Version140
+ compatibility_high: Version150
+ module_defaults:
+ lowlydba.sqlserver.database:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ database_name }}"
+ tags: ["database"]
+ block:
+ - name: Ensure a database exists
+ lowlydba.sqlserver.database:
+ maxdop: "{{ maxdop }}"
+ secondary_maxdop: "{{ secondary_maxdop }}"
+ rcsi: true
+ recovery_model: "{{ recovery_model }}"
+ compatibility: "{{ compatibility_low }}"
+ owner: "{{ sqlserver_username }}"
+ register: result
+ - assert:
+ that:
+ - result.data.Name == "{{ database_name }}"
+ - result.data.RCSI is true
+ - result.data.Owner == "{{ sqlserver_username }}"
+ - result.data.RecoveryModel == "{{ recovery_model }}"
+ - result.data.MaxDop == {{ maxdop }}
+ - result.data.Compatibility == "{{ compatibility_low }}"
+
+ - name: Change a database
+ lowlydba.sqlserver.database:
+ compatibility: "{{ compatibility_high }}"
+ owner: "{{ owner_name }}"
+ secondary_maxdop: "{{ secondary_maxdop }}"
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.data.Compatibility =="{{ compatibility_high }}"
+ - result.data.Owner == "{{ owner_name }}"
+ - result.data.SecondaryMaxDop == {{ secondary_maxdop }}
+
+ - name: Change a database in checkmode
+ lowlydba.sqlserver.database:
+ database: "{{ database_name }}"
+ rcsi: false
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify database unchanged from checkmode
+ lowlydba.sqlserver.database:
+ database: "{{ database_name }}"
+ rcsi: false
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.data.RCSI is false
+
+ - name: Drop a database
+ lowlydba.sqlserver.database:
+ database: "{{ database_name }}"
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Create a database
+ lowlydba.sqlserver.database:
+ database: "{{ database_name }}"
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.data.Name == "{{ database_name }}"
+
+ always:
+ - name: Drop a database
+ lowlydba.sqlserver.database:
+ database: "{{ database_name }}"
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/tasks/main.yml
new file mode 100644
index 000000000..b548ee7a0
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/dba_multitool/tasks/main.yml
@@ -0,0 +1,37 @@
+---
+- name: Var block
+ vars:
+ target_database: "master"
+ branch: "development"
+ module_defaults:
+ lowlydba.sqlserver.dba_multitool:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ target_database }}"
+ branch: "{{ branch }}"
+ tags: ["dba_multitool"]
+ block:
+ - name: Install dba_multitool
+ lowlydba.sqlserver.dba_multitool:
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.Database == target_database
+ - result.data.Status in ('Installed', 'Updated')
+ - result is changed
+
+ - name: Update dba_multitool
+ lowlydba.sqlserver.dba_multitool:
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.Database == target_database
+ - result.data.Status == 'Updated'
+ - result is changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/tasks/main.yml
new file mode 100644
index 000000000..e5dd01a86
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/first_responder_kit/tasks/main.yml
@@ -0,0 +1,39 @@
+---
+- name: Var block
+ vars:
+ target_database: "master"
+ branch: "main"
+ module_defaults:
+ lowlydba.sqlserver.first_responder_kit:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ target_database }}"
+ branch: "{{ branch }}"
+ only_script: "Install-All-Scripts.sql"
+ tags: ["first_responder_kit"]
+ block:
+ - name: Install first_responder_kit
+ lowlydba.sqlserver.first_responder_kit:
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.Database == target_database
+ - result.data.Status in ('Installed', 'Updated')
+ - result is changed
+
+ - name: Uninstall first_responder_kit
+ lowlydba.sqlserver.first_responder_kit:
+ only_script: "Uninstall.sql"
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.Database == target_database
+ - result.data.Status in ('Installed', 'Updated')
+ - result is changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/files/1-select-choice.sql b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/files/1-select-choice.sql
new file mode 100644
index 000000000..54a481acb
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/files/1-select-choice.sql
@@ -0,0 +1 @@
+SELECT 'choice';
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/tasks/main.yml
new file mode 100644
index 000000000..f363c031d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/install_script/tasks/main.yml
@@ -0,0 +1,61 @@
+---
+- name: Var block
+ vars:
+ path: "{{ role_path }}/files/"
+ database_name: "lowlydba-migration-test"
+ module_defaults:
+ lowlydba.sqlserver.install_script:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ create_database: true
+ no_recurse: true
+ database: "{{ database_name }}"
+ path: "{{ path }}"
+ schema_version_table: "SchemaVersion"
+ output_file: "output.txt"
+ tags: ["sqlserver.install_script"]
+
+ block:
+ - name: Install a script in no log mode
+ lowlydba.sqlserver.install_script:
+ no_log_version: true
+ register: result
+ - assert:
+ that:
+ - result.data.Database == "{{ database_name }}"
+ - result.data.Successful == true
+ - result is changed
+
+ - name: Install a script in checkmode
+ lowlydba.sqlserver.install_script:
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Install a script
+ lowlydba.sqlserver.install_script:
+ register: result
+ - assert:
+ that:
+ - result.data.Database == "{{ database_name }}"
+ - result.data.Successful == true
+ - result is changed
+
+ - name: Install same script
+ lowlydba.sqlserver.install_script:
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ always:
+ - name: Cleanup database
+ lowlydba.sqlserver.database:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ database_name }}"
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/tasks/main.yml
new file mode 100644
index 000000000..f7ac97a6e
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/instance_info/tasks/main.yml
@@ -0,0 +1,26 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.instance_info:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["instance_info"]
+ block:
+ - name: Get instance info
+ lowlydba.sqlserver.instance_info:
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.BuildNumber != None
+ - result.data.Language != None
+ - result.data.VersionMajor != None
+ - result.data.VersionMinor != None
+ - result.data.VersionString != None
+ - result.data.Collation != None
+ - result.data.ProductLevel != None
+ - result.data.IsClustered != None
+ - result.data.LoginMode != None
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/tasks/main.yml
new file mode 100644
index 000000000..da938fc53
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/login/tasks/main.yml
@@ -0,0 +1,97 @@
+---
+- name: Var block
+ vars:
+ login_name: "PhillipJFry"
+ plain_password: "P0pS3cret!23$%"
+ password_expiration_enabled: false
+ password_policy_enforced: false
+ password_must_change: false
+ enabled: false
+ default_database: "master"
+ language: "us_english"
+ module_defaults:
+ lowlydba.sqlserver.login:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ default_database: "{{ default_database }}"
+ login: "{{ login_name }}"
+ password: "{{ plain_password }}"
+ password_expiration_enabled: "{{ password_expiration_enabled }}"
+ password_must_change: "{{ password_must_change }}"
+ enabled: "{{ enabled }}"
+ language: "{{ language }}"
+ state: present
+ tags: ["sqlserver.login"]
+ block:
+ - name: Create login
+ lowlydba.sqlserver.login:
+ password_policy_enforced: "{{ password_policy_enforced }}"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+
+ - name: Modify login
+ lowlydba.sqlserver.login:
+ default_database: "model"
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.IsDisabled is false
+ - result.data.Name == "{{ login_name }}"
+ - result.data.DefaultDatabase == "model"
+
+ - name: Drop login
+ lowlydba.sqlserver.login:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Login == "{{ login_name }}"
+ - result.data.Status == "Dropped"
+ - result is changed
+
+ - name: Create login in checkmode
+ lowlydba.sqlserver.login:
+ password_policy_enforced: true
+ password_expiration_enabled: true
+ password_must_change: true
+ enabled: false
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify checkmode works
+ lowlydba.sqlserver.login:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.MustChangePassword is false
+ - result.data.IsDisabled is true
+ - result.data.IsLocked is false
+ - result.data.Name == "{{ login_name }}"
+ - result.data.DefaultDatabase == "{{ default_database }}"
+ - result.data.Language == "{{ language }}"
+ - result is changed
+
+ always:
+ - name: Drop login
+ lowlydba.sqlserver.login:
+ state: "absent"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/tasks/main.yml
new file mode 100644
index 000000000..9dd7b6687
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/maintenance_solution/tasks/main.yml
@@ -0,0 +1,29 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.maintenance_solution:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ backup_location: "C:\\backup"
+ cleanup_time: 24
+ output_file_dir: "C:\\logs"
+ tags: ["maintenance_solution"]
+ block:
+ - name: Install Maintenance Solution
+ lowlydba.sqlserver.maintenance_solution:
+ database: master
+ replace_existing: true
+ register: result
+ - assert:
+ that:
+ - result.data.Results == "Success"
+ - result is changed
+
+ - name: Install Maintenance Solution if not already present
+ lowlydba.sqlserver.maintenance_solution:
+ database: master
+ register: result
+ - assert:
+ that:
+ - result is not changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/tasks/main.yml
new file mode 100644
index 000000000..eb2f54fa1
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/memory/tasks/main.yml
@@ -0,0 +1,71 @@
+---
+- name: Var block
+ vars:
+ max_memory_over_9000: 99999
+ module_defaults:
+ lowlydba.sqlserver.memory:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["memory"]
+ block:
+ - name: Set max memory
+ lowlydba.sqlserver.memory:
+ max: "{{ max_memory_over_9000 }}"
+ register: result
+ - assert:
+ that:
+ - result.data.Total != None
+ - result.data.PreviousMaxValue is defined
+ - result.data.PreviousMaxValue != None
+ - result.data.MaxValue == {{ max_memory_over_9000 }}
+
+ - name: Don't change max memory
+ lowlydba.sqlserver.memory:
+ max: "{{ max_memory_over_9000 }}"
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Dynamically set max memory
+ lowlydba.sqlserver.memory:
+ max: 0
+ register: result
+ - assert:
+ that:
+ - result.data.PreviousMaxValue == {{ max_memory_over_9000 }}
+ - result.data.MaxValue != {{ max_memory_over_9000 }}
+ - result.data.Total > result.data.MaxValue
+
+ - name: No change with dynamic memory
+ lowlydba.sqlserver.memory:
+ max: 0
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Set max memory in checkmode
+ lowlydba.sqlserver.memory:
+ max: "{{ max_memory_over_9000 }}"
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify unchanged checkmode max memory
+ lowlydba.sqlserver.memory:
+ max: "{{ max_memory_over_9000 }}"
+ register: result
+ - assert:
+ that:
+ - result.data.PreviousMaxValue != {{ max_memory_over_9000 }}
+ - result.data.MaxValue == {{ max_memory_over_9000 }}
+ - result is changed
+
+ always:
+ - name: Dynamically set max memory
+ lowlydba.sqlserver.memory:
+ max: 0
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/tasks/main.yml
new file mode 100644
index 000000000..9b6d22354
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/nonquery/tasks/main.yml
@@ -0,0 +1,27 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.nonquery:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["query"]
+ block:
+ - name: Execute a nonquery
+ lowlydba.sqlserver.nonquery:
+ nonquery: "SELECT 1"
+ database: "master"
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Execute a nonquery in checkmode
+ lowlydba.sqlserver.nonquery:
+ nonquery: "SELECT 1"
+ database: "master"
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/tasks/main.yml
new file mode 100644
index 000000000..328f9cd0b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/resource_governor/tasks/main.yml
@@ -0,0 +1,36 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.resource_governor:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["resource_governor"]
+ block:
+ - name: Enable resource_governor
+ lowlydba.sqlserver.resource_governor:
+ enabled: true
+ register: result
+
+ - name: Disable resource_governor
+ lowlydba.sqlserver.resource_governor:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data.Enabled is false
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - "'default' in result.data.ResourcePools"
+ - result is changed
+
+ - name: Enable resource_governor
+ lowlydba.sqlserver.resource_governor:
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data.Enabled is true
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - "'default' in result.data.ResourcePools"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/tasks/main.yml
new file mode 100644
index 000000000..d6ab8d93c
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_resource_pool/tasks/main.yml
@@ -0,0 +1,76 @@
+---
+- name: Var block
+ vars:
+ resource_pool: "rpTheWaterIsFine"
+ type: "Internal"
+ max_cpu_perc: 99
+ min_cpu_perc: 90
+ max_iops_per_vol: 10000
+ min_iops_per_vol: 1
+ max_mem_perc: 99
+ min_mem_perc: 42
+ module_defaults:
+ lowlydba.sqlserver.rg_resource_pool:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ resource_pool: "{{ resource_pool }}"
+ type: "{{ type }}"
+ max_cpu_perc: "{{ max_cpu_perc }}"
+ min_cpu_perc: "{{ min_cpu_perc }}"
+ max_iops_per_vol: "{{ max_iops_per_vol }}"
+ min_iops_per_vol: "{{ min_iops_per_vol }}"
+ max_mem_perc: "{{ max_mem_perc }}"
+ min_mem_perc: "{{ min_mem_perc }}"
+ tags: ["rg_resource_pool"]
+ block:
+ - name: Create resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ state: "present"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - result.data.MaximumCpuPercentage == {{ max_cpu_perc }}
+ - result.data.MinimumCpuPercentage == {{ min_cpu_perc }}
+ - result.data.MaximumIopsPerVolume == {{ max_iops_per_vol }}
+ - result.data.MinimumIopsPerVolume == {{ min_iops_per_vol }}
+ - result.data.MaximumMemoryPercentage == {{ max_mem_perc }}
+ - result.data.MinimumMemoryPercentage == {{ min_mem_perc }}
+ - result.data.Name == "{{ resource_pool }}"
+
+ - name: Modify resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ min_cpu_perc: 1
+ state: "present"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - result.data.MinimumCpuPercentage == 1
+
+ - name: Drop resource pool in checkmode
+ lowlydba.sqlserver.rg_resource_pool:
+ state: "absent"
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Drop resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ always:
+ - name: Drop resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ state: "absent"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/tasks/main.yml
new file mode 100644
index 000000000..449663e17
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/rg_workload_group/tasks/main.yml
@@ -0,0 +1,102 @@
+---
+- name: Var block
+ vars:
+ workload_group: "rgReports"
+ resource_pool: "rpReports"
+ resource_pool_type: "Internal"
+ max_dop: 2
+ request_max_cpu_time: 10
+ request_max_mem_grant_perc: 50
+ request_mem_grant_timeout_sec: 420
+ importance: "Medium"
+ module_defaults:
+ lowlydba.sqlserver.rg_workload_group:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ workload_group: "{{ workload_group }}"
+ resource_pool: "{{ resource_pool }}"
+ resource_pool_type: "{{ resource_pool_type }}"
+ request_max_cpu_time: "{{ request_max_cpu_time }}"
+ request_max_mem_grant_perc: "{{ request_max_mem_grant_perc }}"
+ request_mem_grant_timeout_sec: "{{ request_mem_grant_timeout_sec }}"
+ importance: "{{ importance }}"
+ max_dop: "{{ max_dop }}"
+ lowlydba.sqlserver.rg_resource_pool:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ resource_pool: "{{ resource_pool }}"
+ type: "{{ resource_pool_type }}"
+ tags: ["rg_workload_group"]
+ block:
+ - name: Create resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ state: "present"
+
+ - name: Create workload group
+ lowlydba.sqlserver.rg_workload_group:
+ state: "present"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - result.data.Importance == "{{ importance }}"
+ - result.data.Name == "{{ workload_group }}"
+ - result.data.MaximumDegreeOfParallelism == {{ max_dop }}
+ - result.data.RequestMaximumCpuTimeInSeconds == {{ request_max_cpu_time }}
+ - result.data.RequestMemoryGrantTimeoutInSeconds == {{ request_mem_grant_timeout_sec }}
+ - result.data.GroupMaximumRequests == 0
+ - result.data.RequestMaximumMemoryGrantPercentage == {{ request_max_mem_grant_perc }}
+
+ - name: Modify workload group
+ lowlydba.sqlserver.rg_workload_group:
+ group_max_requests: 4
+ state: "present"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - result.data.MaximumDegreeOfParallelism == {{ max_dop }}
+ - result.data.Importance == "{{ importance }}"
+ - result.data.Name == "{{ workload_group }}"
+ - result.data.RequestMaximumCpuTimeInSeconds == {{ request_max_cpu_time }}
+ - result.data.RequestMemoryGrantTimeoutInSeconds == {{ request_mem_grant_timeout_sec }}
+ - result.data.GroupMaximumRequests == 4
+ - result.data.RequestMaximumMemoryGrantPercentage == {{ request_max_mem_grant_perc }}
+
+ - name: Drop workload group in checkmode
+ lowlydba.sqlserver.rg_workload_group:
+ state: "absent"
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Drop workload group
+ lowlydba.sqlserver.rg_workload_group:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.SqlInstance != None
+ - result.data.Name == "{{ workload_group }}"
+ - result.data.Status == "Dropped"
+ - result is changed
+
+ always:
+ - name: Drop workload group
+ lowlydba.sqlserver.rg_workload_group:
+ state: "absent"
+
+ - name: Drop resource pool
+ lowlydba.sqlserver.rg_resource_pool:
+ resource_pool: "{{ resource_pool }}"
+ state: "absent"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/tasks/main.yml
new file mode 100644
index 000000000..89a3c135f
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sa/tasks/main.yml
@@ -0,0 +1,66 @@
+---
+- name: Var block
+ vars:
+ password_expiration_enabled: false
+ password_policy_enforced: false
+ password_must_change: false
+ enabled: true
+ module_defaults:
+ lowlydba.sqlserver.sa:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["sqlserver.login"]
+ block:
+ - name: Configure sa
+ lowlydba.sqlserver.sa:
+ password_expiration_enabled: "{{ password_expiration_enabled }}"
+ password_policy_enforced: "{{ password_policy_enforced }}"
+ password_must_change: "{{ password_must_change }}"
+ enabled: "{{ enabled }}"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.IsDisabled is false
+ - result.data.IsLocked is false
+ - result.data.Name == "sa"
+ - result.data.MustChangePassword is false
+
+ - name: Disable in checkmode
+ lowlydba.sqlserver.sa:
+ new_name: UpDawg
+ password: "WhatsUpDawg?"
+ enabled: false
+ password_expiration_enabled: true
+ password_must_change: true
+ password_policy_enforced: true
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify checkmode works
+ lowlydba.sqlserver.sa:
+ enabled: "{{ enabled }}"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.MustChangePassword is false
+ - result.data.IsDisabled is false
+ - result.data.IsLocked is false
+ - result.data.Name == "sa"
+ - result is not changed
+ # Cleanup
+ always:
+ - name: Enable sa
+ lowlydba.sqlserver.sa:
+ enabled: true
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/defaults/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/defaults/main.yml
new file mode 100644
index 000000000..5e3e5017d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+sqlserver_windows: false
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/tasks/main.yml
new file mode 100644
index 000000000..28c3c1cd7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+- name: Install Powershell modules
+ when: not sqlserver_windows
+ ansible.builtin.command: >
+ pwsh -Command "{{ item }}"
+ no_log: "{{ ansible_verbosity | int < 3 }}"
+ loop:
+ - "{{ dbatools_install_cmd }}"
+ - "{{ dbops_install_cmd }}"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/vars/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/vars/main.yml
new file mode 100644
index 000000000..3f8503300
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver/vars/main.yml
@@ -0,0 +1,12 @@
+---
+dbatools_min_version: 1.1.112
+dbatools_install_cmd: >
+ if (-not(Get-Module -FullyQualifiedName @{ModuleName='dbatools';ModuleVersion='{{ dbatools_min_version }}'} -ListAvailable)) {
+ Install-Module dbatools -MinimumVersion {{ dbatools_min_version }} -Force
+ }
+
+dbops_min_version: 0.8.0
+dbops_install_cmd: >
+ if (-not(Get-Module -FullyQualifiedName @{ModuleName='dbops';ModuleVersion='{{ dbops_min_version }}'} -ListAvailable)) {
+ Install-Module dbops -MinimumVersion {{ dbops_min_version }} -Force
+ }
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/README.md b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/README.md
new file mode 100644
index 000000000..b55cd1cd9
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/README.md
@@ -0,0 +1,9 @@
+# What is this?
+
+This collection contains a connection plugin and a shell plugin, with the goal of running Ansible PowerShell modules (traditionally only able to be run on remote Windows hosts), directly on the Ansible controller via `pwsh`, without modifications to the modules.
+
+## Supportability
+
+This is extremely experimental, and relies at least in part, on some hackery. Use with caution.
+
+The goal of not modifying modules to run this way _should_ support the notion that if this hackery fails, the module could instead be run against a remote Windows host as a sort of proxy, as long as the module already does its work against a remote system (like modules intended to manage SQL servers).
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py
new file mode 100644
index 000000000..18ec57fd3
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/connection_plugins/local_pwsh.py
@@ -0,0 +1,197 @@
+# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
+# (c) 2015, 2017 Toshio Kuratomi <tkuratomi@ansible.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = '''
+ name: local_pwsh
+ short_description: execute on controller via pwsh
+ description:
+ - This connection plugin allows ansible to execute tasks on the Ansible 'controller' instead of on a remote host.
+ author: ansible (@core)
+ version_added: historical
+ extends_documentation_fragment:
+ - connection_pipelining
+ notes:
+ - The remote user is ignored, the user with which the ansible CLI was executed is used instead.
+'''
+
+import os
+import sys
+import pty
+import shutil
+import subprocess
+import fcntl
+import getpass
+
+import ansible.constants as C
+from ansible.errors import AnsibleError, AnsibleFileNotFound
+from ansible.module_utils.compat import selectors
+from ansible.module_utils.six import text_type, binary_type
+from ansible.module_utils._text import to_bytes, to_native, to_text
+from ansible.plugins.connection import ConnectionBase
+from ansible.utils.display import Display
+from ansible.utils.path import unfrackpath
+
+display = Display()
+
+
+class Connection(ConnectionBase):
+ ''' Local based connections '''
+
+ transport = 'local'
+ has_pipelining = True
+ module_implementation_preferences = ('.ps1', '')
+
+ def __init__(self, *args, **kwargs):
+
+ super(Connection, self).__init__(*args, **kwargs)
+ self.cwd = None
+ self.default_user = getpass.getuser()
+
+ def _connect(self):
+ ''' connect to the local host; nothing to do here '''
+
+ # Because we haven't made any remote connection we're running as
+ # the local user, rather than as whatever is configured in remote_user.
+ self._play_context.remote_user = self.default_user
+
+ if not self._connected:
+ display.vvv(u"ESTABLISH LOCAL CONNECTION FOR USER: {0}".format(self._play_context.remote_user), host=self._play_context.remote_addr)
+ self._connected = True
+ return self
+
+ def exec_command(self, cmd, in_data=None, sudoable=True):
+ ''' run a command on the local host '''
+
+ super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
+
+ display.debug("in local_pwsh.exec_command()")
+
+ # mac (darwin) has different pwsh install location than linux
+ if sys.platform.startswith('darwin'):
+ executable = '/usr/local/bin/pwsh'
+ else:
+ executable = '/usr/bin/pwsh'
+ # executable = C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else None
+
+ if not os.path.exists(to_bytes(executable, errors='surrogate_or_strict')):
+ raise AnsibleError("failed to find the executable specified %s."
+ " Please verify if the executable exists and re-try." % executable)
+
+ display.vvv(u"EXEC {0}".format(to_text(cmd)), host=self._play_context.remote_addr)
+ display.debug("opening command with Popen()")
+
+ if isinstance(cmd, (text_type, binary_type)):
+ cmd = to_bytes(cmd)
+ else:
+ cmd = map(to_bytes, cmd)
+
+ master = None
+ stdin = subprocess.PIPE
+ if sudoable and self.become and self.become.expect_prompt() and not self.get_option('pipelining'):
+ # Create a pty if sudoable for privlege escalation that needs it.
+ # Falls back to using a standard pipe if this fails, which may
+ # cause the command to fail in certain situations where we are escalating
+ # privileges or the command otherwise needs a pty.
+ try:
+ master, stdin = pty.openpty()
+ except (IOError, OSError) as e:
+ display.debug("Unable to open pty: %s" % to_native(e))
+
+ p = subprocess.Popen(
+ cmd,
+ shell=isinstance(cmd, (text_type, binary_type)),
+ executable=executable,
+ cwd=self.cwd,
+ stdin=stdin,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+
+ # if we created a master, we can close the other half of the pty now, otherwise master is stdin
+ if master is not None:
+ os.close(stdin)
+
+ display.debug("done running command with Popen()")
+
+ if self.become and self.become.expect_prompt() and sudoable:
+ fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK)
+ fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) | os.O_NONBLOCK)
+ selector = selectors.DefaultSelector()
+ selector.register(p.stdout, selectors.EVENT_READ)
+ selector.register(p.stderr, selectors.EVENT_READ)
+
+ become_output = b''
+ try:
+ while not self.become.check_success(become_output) and not self.become.check_password_prompt(become_output):
+ events = selector.select(self._play_context.timeout)
+ if not events:
+ stdout, stderr = p.communicate()
+ raise AnsibleError('timeout waiting for privilege escalation password prompt:\n' + to_native(become_output))
+
+ for key, event in events:
+ if key.fileobj == p.stdout:
+ chunk = p.stdout.read()
+ elif key.fileobj == p.stderr:
+ chunk = p.stderr.read()
+
+ if not chunk:
+ stdout, stderr = p.communicate()
+ raise AnsibleError('privilege output closed while waiting for password prompt:\n' + to_native(become_output))
+ become_output += chunk
+ finally:
+ selector.close()
+
+ if not self.become.check_success(become_output):
+ become_pass = self.become.get_option('become_pass', playcontext=self._play_context)
+ if master is None:
+ p.stdin.write(to_bytes(become_pass, errors='surrogate_or_strict') + b'\n')
+ else:
+ os.write(master, to_bytes(become_pass, errors='surrogate_or_strict') + b'\n')
+
+ fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) & ~os.O_NONBLOCK)
+ fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) & ~os.O_NONBLOCK)
+
+ display.debug("getting output with communicate()")
+ stdout, stderr = p.communicate(in_data)
+ display.debug("done communicating")
+
+ # finally, close the other half of the pty, if it was created
+ if master:
+ os.close(master)
+
+ display.debug("done with local.exec_command()")
+ return (p.returncode, stdout, stderr)
+
+ def put_file(self, in_path, out_path):
+ ''' transfer a file from local to local '''
+
+ super(Connection, self).put_file(in_path, out_path)
+
+ in_path = unfrackpath(in_path, basedir=self.cwd)
+ out_path = unfrackpath(out_path, basedir=self.cwd)
+
+ display.vvv(u"PUT {0} TO {1}".format(in_path, out_path), host=self._play_context.remote_addr)
+ if not os.path.exists(to_bytes(in_path, errors='surrogate_or_strict')):
+ raise AnsibleFileNotFound("file or module does not exist: {0}".format(to_native(in_path)))
+ try:
+ shutil.copyfile(to_bytes(in_path, errors='surrogate_or_strict'), to_bytes(out_path, errors='surrogate_or_strict'))
+ except shutil.Error:
+ raise AnsibleError("failed to copy: {0} and {1} are the same".format(to_native(in_path), to_native(out_path)))
+ except IOError as e:
+ raise AnsibleError("failed to transfer file to {0}: {1}".format(to_native(out_path), to_native(e)))
+
+ def fetch_file(self, in_path, out_path):
+ ''' fetch a file from local to local -- for compatibility '''
+
+ super(Connection, self).fetch_file(in_path, out_path)
+
+ display.vvv(u"FETCH {0} TO {1}".format(in_path, out_path), host=self._play_context.remote_addr)
+ self.put_file(in_path, out_path)
+
+ def close(self):
+ ''' terminate the connection; nothing to do here '''
+ self._connected = False
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.Basic.cs b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.Basic.cs
new file mode 100644
index 000000000..484f75751
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.Basic.cs
@@ -0,0 +1,1481 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Management.Automation;
+using System.Management.Automation.Runspaces;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Security.AccessControl;
+using System.Security.Principal;
+#if CORECLR
+using Newtonsoft.Json;
+#else
+using System.Web.Script.Serialization;
+#endif
+
+// System.Diagnostics.EventLog.dll reference different versioned dlls that are
+// loaded in PSCore, ignore CS1702 so the code will ignore this warning
+//NoWarn -Name CS1702 -CLR Core
+
+//AssemblyReference -Type Newtonsoft.Json.JsonConvert -CLR Core
+//AssemblyReference -Type System.Diagnostics.EventLog -CLR Core
+//AssemblyReference -Type System.Security.AccessControl.NativeObjectSecurity -CLR Core
+//AssemblyReference -Type System.Security.AccessControl.DirectorySecurity -CLR Core
+//AssemblyReference -Type System.Security.Principal.IdentityReference -CLR Core
+
+//AssemblyReference -Name System.Web.Extensions.dll -CLR Framework
+
+namespace Ansible.Basic
+{
+ public class AnsibleModule
+ {
+ public delegate void ExitHandler(int rc);
+ public static ExitHandler Exit = new ExitHandler(ExitModule);
+
+ public delegate void WriteLineHandler(string line);
+ public static WriteLineHandler WriteLine = new WriteLineHandler(WriteLineModule);
+
+ public static bool _DebugArgSpec = false;
+
+ private static List<string> BOOLEANS_TRUE = new List<string>() { "y", "yes", "on", "1", "true", "t", "1.0" };
+ private static List<string> BOOLEANS_FALSE = new List<string>() { "n", "no", "off", "0", "false", "f", "0.0" };
+
+ private string remoteTmp = Path.GetTempPath();
+ private string tmpdir = null;
+ private HashSet<string> noLogValues = new HashSet<string>();
+ private List<string> optionsContext = new List<string>();
+ private List<string> warnings = new List<string>();
+ private List<Dictionary<string, string>> deprecations = new List<Dictionary<string, string>>();
+ private List<string> cleanupFiles = new List<string>();
+
+ private Dictionary<string, string> passVars = new Dictionary<string, string>()
+ {
+ // null values means no mapping, not used in Ansible.Basic.AnsibleModule
+ { "check_mode", "CheckMode" },
+ { "debug", "DebugMode" },
+ { "diff", "DiffMode" },
+ { "keep_remote_files", "KeepRemoteFiles" },
+ { "module_name", "ModuleName" },
+ { "no_log", "NoLog" },
+ { "remote_tmp", "remoteTmp" },
+ { "selinux_special_fs", null },
+ { "shell_executable", null },
+ { "socket", null },
+ { "string_conversion_action", null },
+ { "syslog_facility", null },
+ { "tmpdir", "tmpdir" },
+ { "verbosity", "Verbosity" },
+ { "version", "AnsibleVersion" },
+ };
+ private List<string> passBools = new List<string>() { "check_mode", "debug", "diff", "keep_remote_files", "no_log" };
+ private List<string> passInts = new List<string>() { "verbosity" };
+ private Dictionary<string, List<object>> specDefaults = new Dictionary<string, List<object>>()
+ {
+ // key - (default, type) - null is freeform
+ { "apply_defaults", new List<object>() { false, typeof(bool) } },
+ { "aliases", new List<object>() { typeof(List<string>), typeof(List<string>) } },
+ { "choices", new List<object>() { typeof(List<object>), typeof(List<object>) } },
+ { "default", new List<object>() { null, null } },
+ { "deprecated_aliases", new List<object>() { typeof(List<Hashtable>), typeof(List<Hashtable>) } },
+ { "elements", new List<object>() { null, null } },
+ { "mutually_exclusive", new List<object>() { typeof(List<List<string>>), typeof(List<object>) } },
+ { "no_log", new List<object>() { false, typeof(bool) } },
+ { "options", new List<object>() { typeof(Hashtable), typeof(Hashtable) } },
+ { "removed_in_version", new List<object>() { null, typeof(string) } },
+ { "removed_at_date", new List<object>() { null, typeof(DateTime) } },
+ { "removed_from_collection", new List<object>() { null, typeof(string) } },
+ { "required", new List<object>() { false, typeof(bool) } },
+ { "required_by", new List<object>() { typeof(Hashtable), typeof(Hashtable) } },
+ { "required_if", new List<object>() { typeof(List<List<object>>), typeof(List<object>) } },
+ { "required_one_of", new List<object>() { typeof(List<List<string>>), typeof(List<object>) } },
+ { "required_together", new List<object>() { typeof(List<List<string>>), typeof(List<object>) } },
+ { "supports_check_mode", new List<object>() { false, typeof(bool) } },
+ { "type", new List<object>() { "str", null } },
+ };
+ private Dictionary<string, Delegate> optionTypes = new Dictionary<string, Delegate>()
+ {
+ { "bool", new Func<object, bool>(ParseBool) },
+ { "dict", new Func<object, Dictionary<string, object>>(ParseDict) },
+ { "float", new Func<object, float>(ParseFloat) },
+ { "int", new Func<object, int>(ParseInt) },
+ { "json", new Func<object, string>(ParseJson) },
+ { "list", new Func<object, List<object>>(ParseList) },
+ { "path", new Func<object, string>(ParsePath) },
+ { "raw", new Func<object, object>(ParseRaw) },
+ { "sid", new Func<object, SecurityIdentifier>(ParseSid) },
+ { "str", new Func<object, string>(ParseStr) },
+ };
+
+ public Dictionary<string, object> Diff = new Dictionary<string, object>();
+ public IDictionary Params = null;
+ public Dictionary<string, object> Result = new Dictionary<string, object>() { { "changed", false } };
+
+ public bool CheckMode { get; private set; }
+ public bool DebugMode { get; private set; }
+ public bool DiffMode { get; private set; }
+ public bool KeepRemoteFiles { get; private set; }
+ public string ModuleName { get; private set; }
+ public bool NoLog { get; private set; }
+ public int Verbosity { get; private set; }
+ public string AnsibleVersion { get; private set; }
+
+ public string Tmpdir
+ {
+ get
+ {
+ if (tmpdir == null)
+ {
+ SecurityIdentifier user = WindowsIdentity.GetCurrent().User;
+ DirectorySecurity dirSecurity = new DirectorySecurity();
+ dirSecurity.SetOwner(user);
+ dirSecurity.SetAccessRuleProtection(true, false); // disable inheritance rules
+ FileSystemAccessRule ace = new FileSystemAccessRule(user, FileSystemRights.FullControl,
+ InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
+ PropagationFlags.None, AccessControlType.Allow);
+ dirSecurity.AddAccessRule(ace);
+
+ string baseDir = Path.GetFullPath(Environment.ExpandEnvironmentVariables(remoteTmp));
+ if (!Directory.Exists(baseDir))
+ {
+ string failedMsg = null;
+ try
+ {
+#if CORECLR
+ DirectoryInfo createdDir = Directory.CreateDirectory(baseDir);
+ FileSystemAclExtensions.SetAccessControl(createdDir, dirSecurity);
+#else
+ Directory.CreateDirectory(baseDir, dirSecurity);
+#endif
+ }
+ catch (Exception e)
+ {
+ failedMsg = String.Format("Failed to create base tmpdir '{0}': {1}", baseDir, e.Message);
+ }
+
+ if (failedMsg != null)
+ {
+ string envTmp = Path.GetTempPath();
+ Warn(String.Format("Unable to use '{0}' as temporary directory, falling back to system tmp '{1}': {2}", baseDir, envTmp, failedMsg));
+ baseDir = envTmp;
+ }
+ else
+ {
+ NTAccount currentUser = (NTAccount)user.Translate(typeof(NTAccount));
+ string warnMsg = String.Format("Module remote_tmp {0} did not exist and was created with FullControl to {1}, ", baseDir, currentUser.ToString());
+ warnMsg += "this may cause issues when running as another user. To avoid this, create the remote_tmp dir with the correct permissions manually";
+ Warn(warnMsg);
+ }
+ }
+
+ string dateTime = DateTime.Now.ToFileTime().ToString();
+ string dirName = String.Format("ansible-moduletmp-{0}-{1}", dateTime, new Random().Next(0, int.MaxValue));
+ string newTmpdir = Path.Combine(baseDir, dirName);
+#if CORECLR
+ DirectoryInfo tmpdirInfo = Directory.CreateDirectory(newTmpdir);
+ FileSystemAclExtensions.SetAccessControl(tmpdirInfo, dirSecurity);
+#else
+ Directory.CreateDirectory(newTmpdir, dirSecurity);
+#endif
+ tmpdir = newTmpdir;
+
+ if (!KeepRemoteFiles)
+ cleanupFiles.Add(tmpdir);
+ }
+ return tmpdir;
+ }
+ }
+
+ public AnsibleModule(string[] args, IDictionary argumentSpec, IDictionary[] fragments = null)
+ {
+ // NoLog is not set yet, we cannot rely on FailJson to sanitize the output
+ // Do the minimum amount to get this running before we actually parse the params
+ Dictionary<string, string> aliases = new Dictionary<string, string>();
+ try
+ {
+ ValidateArgumentSpec(argumentSpec);
+
+ // Merge the fragments if present into the main arg spec.
+ if (fragments != null)
+ {
+ foreach (IDictionary fragment in fragments)
+ {
+ ValidateArgumentSpec(fragment);
+ MergeFragmentSpec(argumentSpec, fragment);
+ }
+ }
+
+ // Used by ansible-test to retrieve the module argument spec, not designed for public use.
+ if (_DebugArgSpec)
+ {
+ // Cannot call exit here because it will be caught with the catch (Exception e) below. Instead
+ // just throw a new exception with a specific message and the exception block will handle it.
+ ScriptBlock.Create("Set-Variable -Name ansibleTestArgSpec -Value $args[0] -Scope Global"
+ ).Invoke(argumentSpec);
+ throw new Exception("ansible-test validate-modules check");
+ }
+
+ // Now make sure all the metadata keys are set to their defaults, this must be done after we've
+ // potentially output the arg spec for ansible-test.
+ SetArgumentSpecDefaults(argumentSpec);
+
+ Params = GetParams(args);
+ aliases = GetAliases(argumentSpec, Params);
+ SetNoLogValues(argumentSpec, Params);
+ }
+ catch (Exception e)
+ {
+ if (e.Message == "ansible-test validate-modules check")
+ Exit(0);
+
+ Dictionary<string, object> result = new Dictionary<string, object>
+ {
+ { "failed", true },
+ { "msg", String.Format("internal error: {0}", e.Message) },
+ { "exception", e.ToString() }
+ };
+ WriteLine(ToJson(result));
+ Exit(1);
+ }
+
+ // Initialise public properties to the defaults before we parse the actual inputs
+ CheckMode = false;
+ DebugMode = false;
+ DiffMode = false;
+ KeepRemoteFiles = false;
+ ModuleName = "undefined win module";
+ NoLog = (bool)argumentSpec["no_log"];
+ Verbosity = 0;
+ AppDomain.CurrentDomain.ProcessExit += CleanupFiles;
+
+ List<string> legalInputs = passVars.Keys.Select(v => "_ansible_" + v).ToList();
+ legalInputs.AddRange(((IDictionary)argumentSpec["options"]).Keys.Cast<string>().ToList());
+ legalInputs.AddRange(aliases.Keys.Cast<string>().ToList());
+ CheckArguments(argumentSpec, Params, legalInputs);
+
+ // Set a Ansible friendly invocation value in the result object
+ Dictionary<string, object> invocation = new Dictionary<string, object>() { { "module_args", Params } };
+ Result["invocation"] = RemoveNoLogValues(invocation, noLogValues);
+
+ if (!NoLog)
+ LogEvent(String.Format("Invoked with:\r\n {0}", FormatLogData(Params, 2)), sanitise: false);
+ }
+
+ public static AnsibleModule Create(string[] args, IDictionary argumentSpec, IDictionary[] fragments = null)
+ {
+ return new AnsibleModule(args, argumentSpec, fragments);
+ }
+
+ public void Debug(string message)
+ {
+ if (DebugMode)
+ LogEvent(String.Format("[DEBUG] {0}", message));
+ }
+
+ public void Deprecate(string message, string version)
+ {
+ Deprecate(message, version, null);
+ }
+
+ public void Deprecate(string message, string version, string collectionName)
+ {
+ deprecations.Add(new Dictionary<string, string>() {
+ { "msg", message }, { "version", version }, { "collection_name", collectionName } });
+ LogEvent(String.Format("[DEPRECATION WARNING] {0} {1}", message, version));
+ }
+
+ public void Deprecate(string message, DateTime date)
+ {
+ Deprecate(message, date, null);
+ }
+
+ public void Deprecate(string message, DateTime date, string collectionName)
+ {
+ string isoDate = date.ToString("yyyy-MM-dd");
+ deprecations.Add(new Dictionary<string, string>() {
+ { "msg", message }, { "date", isoDate }, { "collection_name", collectionName } });
+ LogEvent(String.Format("[DEPRECATION WARNING] {0} {1}", message, isoDate));
+ }
+
+ public void ExitJson()
+ {
+ WriteLine(GetFormattedResults(Result));
+ CleanupFiles(null, null);
+ Exit(0);
+ }
+
+ public void FailJson(string message) { FailJson(message, null, null); }
+ public void FailJson(string message, ErrorRecord psErrorRecord) { FailJson(message, psErrorRecord, null); }
+ public void FailJson(string message, Exception exception) { FailJson(message, null, exception); }
+ private void FailJson(string message, ErrorRecord psErrorRecord, Exception exception)
+ {
+ Result["failed"] = true;
+ Result["msg"] = RemoveNoLogValues(message, noLogValues);
+
+
+ if (!Result.ContainsKey("exception") && (Verbosity > 2 || DebugMode))
+ {
+ if (psErrorRecord != null)
+ {
+ string traceback = String.Format("{0}\r\n{1}", psErrorRecord.ToString(), psErrorRecord.InvocationInfo.PositionMessage);
+ traceback += String.Format("\r\n + CategoryInfo : {0}", psErrorRecord.CategoryInfo.ToString());
+ traceback += String.Format("\r\n + FullyQualifiedErrorId : {0}", psErrorRecord.FullyQualifiedErrorId.ToString());
+ traceback += String.Format("\r\n\r\nScriptStackTrace:\r\n{0}", psErrorRecord.ScriptStackTrace);
+ Result["exception"] = traceback;
+ }
+ else if (exception != null)
+ Result["exception"] = exception.ToString();
+ }
+
+ WriteLine(GetFormattedResults(Result));
+ CleanupFiles(null, null);
+ Exit(1);
+ }
+
+ public void LogEvent(string message, EventLogEntryType logEntryType = EventLogEntryType.Information, bool sanitise = true)
+ {
+ // non-Windows hack; event log is not supported, not implementing a x-plat compat logger at this time
+ // original content left as comment, because it may make it easier to update this
+ return;
+ /*
+ if (NoLog)
+ return;
+
+ string logSource = "Ansible";
+ bool logSourceExists = false;
+ try
+ {
+ logSourceExists = EventLog.SourceExists(logSource);
+ }
+ catch (System.Security.SecurityException) { } // non admin users may not have permission
+
+ if (!logSourceExists)
+ {
+ try
+ {
+ EventLog.CreateEventSource(logSource, "Application");
+ }
+ catch (System.Security.SecurityException)
+ {
+ // Cannot call Warn as that calls LogEvent and we get stuck in a loop
+ warnings.Add(String.Format("Access error when creating EventLog source {0}, logging to the Application source instead", logSource));
+ logSource = "Application";
+ }
+ }
+ if (sanitise)
+ message = (string)RemoveNoLogValues(message, noLogValues);
+ message = String.Format("{0} - {1}", ModuleName, message);
+
+ using (EventLog eventLog = new EventLog("Application"))
+ {
+ eventLog.Source = logSource;
+ try
+ {
+ eventLog.WriteEntry(message, logEntryType, 0);
+ }
+ catch (System.InvalidOperationException) { } // Ignore permission errors on the Application event log
+ catch (System.Exception e)
+ {
+ // Cannot call Warn as that calls LogEvent and we get stuck in a loop
+ warnings.Add(String.Format("Unknown error when creating event log entry: {0}", e.Message));
+ }
+ }
+ */
+ }
+
+ public void Warn(string message)
+ {
+ warnings.Add(message);
+ LogEvent(String.Format("[WARNING] {0}", message), EventLogEntryType.Warning);
+ }
+
+ public static object FromJson(string json) { return FromJson<object>(json); }
+ public static T FromJson<T>(string json)
+ {
+#if CORECLR
+ return JsonConvert.DeserializeObject<T>(json);
+#else
+ JavaScriptSerializer jss = new JavaScriptSerializer();
+ jss.MaxJsonLength = int.MaxValue;
+ jss.RecursionLimit = int.MaxValue;
+ return jss.Deserialize<T>(json);
+#endif
+ }
+
+ public static string ToJson(object obj)
+ {
+ // Using PowerShell to serialize the JSON is preferable over the native .NET libraries as it handles
+ // PS Objects a lot better than the alternatives. In case we are debugging in Visual Studio we have a
+ // fallback to the other libraries as we won't be dealing with PowerShell objects there.
+ if (Runspace.DefaultRunspace != null)
+ {
+ PSObject rawOut = ScriptBlock.Create("ConvertTo-Json -InputObject $args[0] -Depth 99 -Compress").Invoke(obj)[0];
+ return rawOut.BaseObject as string;
+ }
+ else
+ {
+#if CORECLR
+ return JsonConvert.SerializeObject(obj);
+#else
+ JavaScriptSerializer jss = new JavaScriptSerializer();
+ jss.MaxJsonLength = int.MaxValue;
+ jss.RecursionLimit = int.MaxValue;
+ return jss.Serialize(obj);
+#endif
+ }
+ }
+
+ public static IDictionary GetParams(string[] args)
+ {
+ if (args.Length > 0)
+ {
+ string inputJson = File.ReadAllText(args[0]);
+ Dictionary<string, object> rawParams = FromJson<Dictionary<string, object>>(inputJson);
+ if (!rawParams.ContainsKey("ANSIBLE_MODULE_ARGS"))
+ throw new ArgumentException("Module was unable to get ANSIBLE_MODULE_ARGS value from the argument path json");
+ return (IDictionary)rawParams["ANSIBLE_MODULE_ARGS"];
+ }
+ else
+ {
+ // $complex_args is already a Hashtable, no need to waste time converting to a dictionary
+ PSObject rawArgs = ScriptBlock.Create("$complex_args").Invoke()[0];
+ return rawArgs.BaseObject as Hashtable;
+ }
+ }
+
+ public static bool ParseBool(object value)
+ {
+ if (value.GetType() == typeof(bool))
+ return (bool)value;
+
+ List<string> booleans = new List<string>();
+ booleans.AddRange(BOOLEANS_TRUE);
+ booleans.AddRange(BOOLEANS_FALSE);
+
+ string stringValue = ParseStr(value).ToLowerInvariant().Trim();
+ if (BOOLEANS_TRUE.Contains(stringValue))
+ return true;
+ else if (BOOLEANS_FALSE.Contains(stringValue))
+ return false;
+
+ string msg = String.Format("The value '{0}' is not a valid boolean. Valid booleans include: {1}",
+ stringValue, String.Join(", ", booleans));
+ throw new ArgumentException(msg);
+ }
+
+ public static Dictionary<string, object> ParseDict(object value)
+ {
+ Type valueType = value.GetType();
+ if (valueType == typeof(Dictionary<string, object>))
+ return (Dictionary<string, object>)value;
+ else if (value is IDictionary)
+ return ((IDictionary)value).Cast<DictionaryEntry>().ToDictionary(kvp => (string)kvp.Key, kvp => kvp.Value);
+ else if (valueType == typeof(string))
+ {
+ string stringValue = (string)value;
+ if (stringValue.StartsWith("{") && stringValue.EndsWith("}"))
+ return FromJson<Dictionary<string, object>>((string)value);
+ else if (stringValue.IndexOfAny(new char[1] { '=' }) != -1)
+ {
+ List<string> fields = new List<string>();
+ List<char> fieldBuffer = new List<char>();
+ char? inQuote = null;
+ bool inEscape = false;
+ string field;
+
+ foreach (char c in stringValue.ToCharArray())
+ {
+ if (inEscape)
+ {
+ fieldBuffer.Add(c);
+ inEscape = false;
+ }
+ else if (c == '\\')
+ inEscape = true;
+ else if (inQuote == null && (c == '\'' || c == '"'))
+ inQuote = c;
+ else if (inQuote != null && c == inQuote)
+ inQuote = null;
+ else if (inQuote == null && (c == ',' || c == ' '))
+ {
+ field = String.Join("", fieldBuffer);
+ if (field != "")
+ fields.Add(field);
+ fieldBuffer = new List<char>();
+ }
+ else
+ fieldBuffer.Add(c);
+ }
+
+ field = String.Join("", fieldBuffer);
+ if (field != "")
+ fields.Add(field);
+
+ return fields.Distinct().Select(i => i.Split(new[] { '=' }, 2)).ToDictionary(i => i[0], i => i.Length > 1 ? (object)i[1] : null);
+ }
+ else
+ throw new ArgumentException("string cannot be converted to a dict, must either be a JSON string or in the key=value form");
+ }
+
+ throw new ArgumentException(String.Format("{0} cannot be converted to a dict", valueType.FullName));
+ }
+
+ public static float ParseFloat(object value)
+ {
+ if (value.GetType() == typeof(float))
+ return (float)value;
+
+ string valueStr = ParseStr(value);
+ return float.Parse(valueStr);
+ }
+
+ public static int ParseInt(object value)
+ {
+ Type valueType = value.GetType();
+ if (valueType == typeof(int))
+ return (int)value;
+ else
+ return Int32.Parse(ParseStr(value));
+ }
+
+ public static string ParseJson(object value)
+ {
+ // mostly used to ensure a dict is a json string as it may
+ // have been converted on the controller side
+ Type valueType = value.GetType();
+ if (value is IDictionary)
+ return ToJson(value);
+ else if (valueType == typeof(string))
+ return (string)value;
+ else
+ throw new ArgumentException(String.Format("{0} cannot be converted to json", valueType.FullName));
+ }
+
+ public static List<object> ParseList(object value)
+ {
+ if (value == null)
+ return null;
+
+ Type valueType = value.GetType();
+ if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(List<>))
+ return (List<object>)value;
+ else if (valueType == typeof(ArrayList))
+ return ((ArrayList)value).Cast<object>().ToList();
+ else if (valueType.IsArray)
+ return ((object[])value).ToList();
+ else if (valueType == typeof(string))
+ return ((string)value).Split(',').Select(s => s.Trim()).ToList<object>();
+ else if (valueType == typeof(int))
+ return new List<object>() { value };
+ else
+ throw new ArgumentException(String.Format("{0} cannot be converted to a list", valueType.FullName));
+ }
+
+ public static string ParsePath(object value)
+ {
+ string stringValue = ParseStr(value);
+
+ // do not validate, expand the env vars if it starts with \\?\ as
+ // it is a special path designed for the NT kernel to interpret
+ if (stringValue.StartsWith(@"\\?\"))
+ return stringValue;
+
+ stringValue = Environment.ExpandEnvironmentVariables(stringValue);
+ if (stringValue.IndexOfAny(Path.GetInvalidPathChars()) != -1)
+ throw new ArgumentException("string value contains invalid path characters, cannot convert to path");
+
+ // will fire an exception if it contains any invalid chars
+ Path.GetFullPath(stringValue);
+ return stringValue;
+ }
+
+ public static object ParseRaw(object value) { return value; }
+
+ public static SecurityIdentifier ParseSid(object value)
+ {
+ string stringValue = ParseStr(value);
+
+ try
+ {
+ return new SecurityIdentifier(stringValue);
+ }
+ catch (ArgumentException) { } // ignore failures string may not have been a SID
+
+ NTAccount account = new NTAccount(stringValue);
+ return (SecurityIdentifier)account.Translate(typeof(SecurityIdentifier));
+ }
+
+ public static string ParseStr(object value) { return value.ToString(); }
+
+ private void ValidateArgumentSpec(IDictionary argumentSpec)
+ {
+ Dictionary<string, object> changedValues = new Dictionary<string, object>();
+ foreach (DictionaryEntry entry in argumentSpec)
+ {
+ string key = (string)entry.Key;
+
+ // validate the key is a valid argument spec key
+ if (!specDefaults.ContainsKey(key))
+ {
+ string msg = String.Format("argument spec entry contains an invalid key '{0}', valid keys: {1}",
+ key, String.Join(", ", specDefaults.Keys));
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+
+ // ensure the value is casted to the type we expect
+ Type optionType = null;
+ if (entry.Value != null)
+ optionType = (Type)specDefaults[key][1];
+ if (optionType != null)
+ {
+ Type actualType = entry.Value.GetType();
+ bool invalid = false;
+ if (optionType.IsGenericType && optionType.GetGenericTypeDefinition() == typeof(List<>))
+ {
+ // verify the actual type is not just a single value of the list type
+ Type entryType = optionType.GetGenericArguments()[0];
+ object[] arrayElementTypes = new object[]
+ {
+ null, // ArrayList does not have an ElementType
+ entryType,
+ typeof(object), // Hope the object is actually entryType or it can at least be casted.
+ };
+
+ bool isArray = entry.Value is IList && arrayElementTypes.Contains(actualType.GetElementType());
+ if (actualType == entryType || isArray)
+ {
+ object rawArray;
+ if (isArray)
+ rawArray = entry.Value;
+ else
+ rawArray = new object[1] { entry.Value };
+
+ MethodInfo castMethod = typeof(Enumerable).GetMethod("Cast").MakeGenericMethod(entryType);
+ MethodInfo toListMethod = typeof(Enumerable).GetMethod("ToList").MakeGenericMethod(entryType);
+
+ var enumerable = castMethod.Invoke(null, new object[1] { rawArray });
+ var newList = toListMethod.Invoke(null, new object[1] { enumerable });
+ changedValues.Add(key, newList);
+ }
+ else if (actualType != optionType && !(actualType == typeof(List<object>)))
+ invalid = true;
+ }
+ else
+ invalid = actualType != optionType;
+
+ if (invalid)
+ {
+ string msg = String.Format("argument spec for '{0}' did not match expected type {1}: actual type {2}",
+ key, optionType.FullName, actualType.FullName);
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+ }
+
+ // recursively validate the spec
+ if (key == "options" && entry.Value != null)
+ {
+ IDictionary optionsSpec = (IDictionary)entry.Value;
+ foreach (DictionaryEntry optionEntry in optionsSpec)
+ {
+ optionsContext.Add((string)optionEntry.Key);
+ IDictionary optionMeta = (IDictionary)optionEntry.Value;
+ ValidateArgumentSpec(optionMeta);
+ optionsContext.RemoveAt(optionsContext.Count - 1);
+ }
+ }
+
+ // validate the type and elements key type values are known types
+ if (key == "type" || key == "elements" && entry.Value != null)
+ {
+ Type valueType = entry.Value.GetType();
+ if (valueType == typeof(string))
+ {
+ string typeValue = (string)entry.Value;
+ if (!optionTypes.ContainsKey(typeValue))
+ {
+ string msg = String.Format("{0} '{1}' is unsupported", key, typeValue);
+ msg = String.Format("{0}. Valid types are: {1}", FormatOptionsContext(msg, " - "), String.Join(", ", optionTypes.Keys));
+ throw new ArgumentException(msg);
+ }
+ }
+ else if (!(entry.Value is Delegate))
+ {
+ string msg = String.Format("{0} must either be a string or delegate, was: {1}", key, valueType.FullName);
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+ }
+ }
+
+ // Outside of the spec iterator, change the values that were casted above
+ foreach (KeyValuePair<string, object> changedValue in changedValues)
+ argumentSpec[changedValue.Key] = changedValue.Value;
+ }
+
+ private void MergeFragmentSpec(IDictionary argumentSpec, IDictionary fragment)
+ {
+ foreach (DictionaryEntry fragmentEntry in fragment)
+ {
+ string fragmentKey = fragmentEntry.Key.ToString();
+
+ if (argumentSpec.Contains(fragmentKey))
+ {
+ // We only want to add new list entries and merge dictionary new keys and values. Leave the other
+ // values as is in the argument spec as that takes priority over the fragment.
+ if (fragmentEntry.Value is IDictionary)
+ {
+ MergeFragmentSpec((IDictionary)argumentSpec[fragmentKey], (IDictionary)fragmentEntry.Value);
+ }
+ else if (fragmentEntry.Value is IList)
+ {
+ IList specValue = (IList)argumentSpec[fragmentKey];
+ foreach (object fragmentValue in (IList)fragmentEntry.Value)
+ specValue.Add(fragmentValue);
+ }
+ }
+ else
+ argumentSpec[fragmentKey] = fragmentEntry.Value;
+ }
+ }
+
+ private void SetArgumentSpecDefaults(IDictionary argumentSpec)
+ {
+ foreach (KeyValuePair<string, List<object>> metadataEntry in specDefaults)
+ {
+ List<object> defaults = metadataEntry.Value;
+ object defaultValue = defaults[0];
+ if (defaultValue != null && defaultValue.GetType() == typeof(Type).GetType())
+ defaultValue = Activator.CreateInstance((Type)defaultValue);
+
+ if (!argumentSpec.Contains(metadataEntry.Key))
+ argumentSpec[metadataEntry.Key] = defaultValue;
+ }
+
+ // Recursively set the defaults for any inner options.
+ foreach (DictionaryEntry entry in argumentSpec)
+ {
+ if (entry.Value == null || entry.Key.ToString() != "options")
+ continue;
+
+ IDictionary optionsSpec = (IDictionary)entry.Value;
+ foreach (DictionaryEntry optionEntry in optionsSpec)
+ {
+ optionsContext.Add((string)optionEntry.Key);
+ IDictionary optionMeta = (IDictionary)optionEntry.Value;
+ SetArgumentSpecDefaults(optionMeta);
+ optionsContext.RemoveAt(optionsContext.Count - 1);
+ }
+ }
+ }
+
+ private Dictionary<string, string> GetAliases(IDictionary argumentSpec, IDictionary parameters)
+ {
+ Dictionary<string, string> aliasResults = new Dictionary<string, string>();
+
+ foreach (DictionaryEntry entry in (IDictionary)argumentSpec["options"])
+ {
+ string k = (string)entry.Key;
+ Hashtable v = (Hashtable)entry.Value;
+
+ List<string> aliases = (List<string>)v["aliases"];
+ object defaultValue = v["default"];
+ bool required = (bool)v["required"];
+
+ if (defaultValue != null && required)
+ throw new ArgumentException(String.Format("required and default are mutually exclusive for {0}", k));
+
+ foreach (string alias in aliases)
+ {
+ aliasResults.Add(alias, k);
+ if (parameters.Contains(alias))
+ parameters[k] = parameters[alias];
+ }
+
+ List<Hashtable> deprecatedAliases = (List<Hashtable>)v["deprecated_aliases"];
+ foreach (Hashtable depInfo in deprecatedAliases)
+ {
+ foreach (string keyName in new List<string> { "name" })
+ {
+ if (!depInfo.ContainsKey(keyName))
+ {
+ string msg = String.Format("{0} is required in a deprecated_aliases entry", keyName);
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+ }
+ if (!depInfo.ContainsKey("version") && !depInfo.ContainsKey("date"))
+ {
+ string msg = "One of version or date is required in a deprecated_aliases entry";
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+ if (depInfo.ContainsKey("version") && depInfo.ContainsKey("date"))
+ {
+ string msg = "Only one of version or date is allowed in a deprecated_aliases entry";
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+ if (depInfo.ContainsKey("date") && depInfo["date"].GetType() != typeof(DateTime))
+ {
+ string msg = "A deprecated_aliases date must be a DateTime object";
+ throw new ArgumentException(FormatOptionsContext(msg, " - "));
+ }
+ string collectionName = null;
+ if (depInfo.ContainsKey("collection_name"))
+ {
+ collectionName = (string)depInfo["collection_name"];
+ }
+ string aliasName = (string)depInfo["name"];
+
+ if (parameters.Contains(aliasName))
+ {
+ string msg = String.Format("Alias '{0}' is deprecated. See the module docs for more information", aliasName);
+ if (depInfo.ContainsKey("version"))
+ {
+ string depVersion = (string)depInfo["version"];
+ Deprecate(FormatOptionsContext(msg, " - "), depVersion, collectionName);
+ }
+ if (depInfo.ContainsKey("date"))
+ {
+ DateTime depDate = (DateTime)depInfo["date"];
+ Deprecate(FormatOptionsContext(msg, " - "), depDate, collectionName);
+ }
+ }
+ }
+ }
+
+ return aliasResults;
+ }
+
+ private void SetNoLogValues(IDictionary argumentSpec, IDictionary parameters)
+ {
+ foreach (DictionaryEntry entry in (IDictionary)argumentSpec["options"])
+ {
+ string k = (string)entry.Key;
+ Hashtable v = (Hashtable)entry.Value;
+
+ if ((bool)v["no_log"])
+ {
+ object noLogObject = parameters.Contains(k) ? parameters[k] : null;
+ string noLogString = noLogObject == null ? "" : noLogObject.ToString();
+ if (!String.IsNullOrEmpty(noLogString))
+ noLogValues.Add(noLogString);
+ }
+ string collectionName = null;
+ if (v.ContainsKey("removed_from_collection"))
+ {
+ collectionName = (string)v["removed_from_collection"];
+ }
+
+ object removedInVersion = v["removed_in_version"];
+ if (removedInVersion != null && parameters.Contains(k))
+ Deprecate(String.Format("Param '{0}' is deprecated. See the module docs for more information", k),
+ removedInVersion.ToString(), collectionName);
+
+ object removedAtDate = v["removed_at_date"];
+ if (removedAtDate != null && parameters.Contains(k))
+ Deprecate(String.Format("Param '{0}' is deprecated. See the module docs for more information", k),
+ (DateTime)removedAtDate, collectionName);
+ }
+ }
+
+ private void CheckArguments(IDictionary spec, IDictionary param, List<string> legalInputs)
+ {
+ // initially parse the params and check for unsupported ones and set internal vars
+ CheckUnsupportedArguments(param, legalInputs);
+
+ // Only run this check if we are at the root argument (optionsContext.Count == 0)
+ if (CheckMode && !(bool)spec["supports_check_mode"] && optionsContext.Count == 0)
+ {
+ Result["skipped"] = true;
+ Result["msg"] = String.Format("remote module ({0}) does not support check mode", ModuleName);
+ ExitJson();
+ }
+ IDictionary optionSpec = (IDictionary)spec["options"];
+
+ CheckMutuallyExclusive(param, (IList)spec["mutually_exclusive"]);
+ CheckRequiredArguments(optionSpec, param);
+
+ // set the parameter types based on the type spec value
+ foreach (DictionaryEntry entry in optionSpec)
+ {
+ string k = (string)entry.Key;
+ Hashtable v = (Hashtable)entry.Value;
+
+ object value = param.Contains(k) ? param[k] : null;
+ if (value != null)
+ {
+ // convert the current value to the wanted type
+ Delegate typeConverter;
+ string type;
+ if (v["type"].GetType() == typeof(string))
+ {
+ type = (string)v["type"];
+ typeConverter = optionTypes[type];
+ }
+ else
+ {
+ type = "delegate";
+ typeConverter = (Delegate)v["type"];
+ }
+
+ try
+ {
+ value = typeConverter.DynamicInvoke(value);
+ param[k] = value;
+ }
+ catch (Exception e)
+ {
+ string msg = String.Format("argument for {0} is of type {1} and we were unable to convert to {2}: {3}",
+ k, value.GetType(), type, e.InnerException.Message);
+ FailJson(FormatOptionsContext(msg));
+ }
+
+ // ensure it matches the choices if there are choices set
+ List<string> choices = ((List<object>)v["choices"]).Select(x => x.ToString()).Cast<string>().ToList();
+ if (choices.Count > 0)
+ {
+ List<string> values;
+ string choiceMsg;
+ if (type == "list")
+ {
+ values = ((List<object>)value).Select(x => x.ToString()).Cast<string>().ToList();
+ choiceMsg = "one or more of";
+ }
+ else
+ {
+ values = new List<string>() { value.ToString() };
+ choiceMsg = "one of";
+ }
+
+ List<string> diffList = values.Except(choices, StringComparer.OrdinalIgnoreCase).ToList();
+ List<string> caseDiffList = values.Except(choices).ToList();
+ if (diffList.Count > 0)
+ {
+ string msg = String.Format("value of {0} must be {1}: {2}. Got no match for: {3}",
+ k, choiceMsg, String.Join(", ", choices), String.Join(", ", diffList));
+ FailJson(FormatOptionsContext(msg));
+ }
+ /*
+ For now we will just silently accept case insensitive choices, uncomment this if we want to add it back in
+ else if (caseDiffList.Count > 0)
+ {
+ // For backwards compatibility with Legacy.psm1 we need to be matching choices that are not case sensitive.
+ // We will warn the user it was case insensitive and tell them this will become case sensitive in the future.
+ string msg = String.Format(
+ "value of {0} was a case insensitive match of {1}: {2}. Checking of choices will be case sensitive in a future Ansible release. Case insensitive matches were: {3}",
+ k, choiceMsg, String.Join(", ", choices), String.Join(", ", caseDiffList.Select(x => RemoveNoLogValues(x, noLogValues)))
+ );
+ Warn(FormatOptionsContext(msg));
+ }*/
+ }
+ }
+ }
+
+ CheckRequiredTogether(param, (IList)spec["required_together"]);
+ CheckRequiredOneOf(param, (IList)spec["required_one_of"]);
+ CheckRequiredIf(param, (IList)spec["required_if"]);
+ CheckRequiredBy(param, (IDictionary)spec["required_by"]);
+
+ // finally ensure all missing parameters are set to null and handle sub options
+ foreach (DictionaryEntry entry in optionSpec)
+ {
+ string k = (string)entry.Key;
+ IDictionary v = (IDictionary)entry.Value;
+
+ if (!param.Contains(k))
+ param[k] = null;
+
+ CheckSubOption(param, k, v);
+ }
+ }
+
+ private void CheckUnsupportedArguments(IDictionary param, List<string> legalInputs)
+ {
+ HashSet<string> unsupportedParameters = new HashSet<string>();
+ HashSet<string> caseUnsupportedParameters = new HashSet<string>();
+ List<string> removedParameters = new List<string>();
+
+ foreach (DictionaryEntry entry in param)
+ {
+ string paramKey = (string)entry.Key;
+ if (!legalInputs.Contains(paramKey, StringComparer.OrdinalIgnoreCase))
+ unsupportedParameters.Add(paramKey);
+ else if (!legalInputs.Contains(paramKey))
+ // For backwards compatibility we do not care about the case but we need to warn the users as this will
+ // change in a future Ansible release.
+ caseUnsupportedParameters.Add(paramKey);
+ else if (paramKey.StartsWith("_ansible_"))
+ {
+ removedParameters.Add(paramKey);
+ string key = paramKey.Replace("_ansible_", "");
+ // skip setting NoLog if NoLog is already set to true (set by the module)
+ // or there's no mapping for this key
+ if ((key == "no_log" && NoLog == true) || (passVars[key] == null))
+ continue;
+
+ object value = entry.Value;
+ if (passBools.Contains(key))
+ value = ParseBool(value);
+ else if (passInts.Contains(key))
+ value = ParseInt(value);
+
+ string propertyName = passVars[key];
+ PropertyInfo property = typeof(AnsibleModule).GetProperty(propertyName);
+ FieldInfo field = typeof(AnsibleModule).GetField(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
+ if (property != null)
+ property.SetValue(this, value, null);
+ else if (field != null)
+ field.SetValue(this, value);
+ else
+ FailJson(String.Format("implementation error: unknown AnsibleModule property {0}", propertyName));
+ }
+ }
+ foreach (string parameter in removedParameters)
+ param.Remove(parameter);
+
+ if (unsupportedParameters.Count > 0)
+ {
+ legalInputs.RemoveAll(x => passVars.Keys.Contains(x.Replace("_ansible_", "")));
+ string msg = String.Format("Unsupported parameters for ({0}) module: {1}", ModuleName, String.Join(", ", unsupportedParameters));
+ msg = String.Format("{0}. Supported parameters include: {1}", FormatOptionsContext(msg), String.Join(", ", legalInputs));
+ FailJson(msg);
+ }
+
+ /*
+ // Uncomment when we want to start warning users around options that are not a case sensitive match to the spec
+ if (caseUnsupportedParameters.Count > 0)
+ {
+ legalInputs.RemoveAll(x => passVars.Keys.Contains(x.Replace("_ansible_", "")));
+ string msg = String.Format("Parameters for ({0}) was a case insensitive match: {1}", ModuleName, String.Join(", ", caseUnsupportedParameters));
+ msg = String.Format("{0}. Module options will become case sensitive in a future Ansible release. Supported parameters include: {1}",
+ FormatOptionsContext(msg), String.Join(", ", legalInputs));
+ Warn(msg);
+ }*/
+
+ // Make sure we convert all the incorrect case params to the ones set by the module spec
+ foreach (string key in caseUnsupportedParameters)
+ {
+ string correctKey = legalInputs[legalInputs.FindIndex(s => s.Equals(key, StringComparison.OrdinalIgnoreCase))];
+ object value = param[key];
+ param.Remove(key);
+ param.Add(correctKey, value);
+ }
+ }
+
+ private void CheckMutuallyExclusive(IDictionary param, IList mutuallyExclusive)
+ {
+ if (mutuallyExclusive == null)
+ return;
+
+ foreach (object check in mutuallyExclusive)
+ {
+ List<string> mutualCheck = ((IList)check).Cast<string>().ToList();
+ int count = 0;
+ foreach (string entry in mutualCheck)
+ if (param.Contains(entry))
+ count++;
+
+ if (count > 1)
+ {
+ string msg = String.Format("parameters are mutually exclusive: {0}", String.Join(", ", mutualCheck));
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+ }
+
+ private void CheckRequiredArguments(IDictionary spec, IDictionary param)
+ {
+ List<string> missing = new List<string>();
+ foreach (DictionaryEntry entry in spec)
+ {
+ string k = (string)entry.Key;
+ Hashtable v = (Hashtable)entry.Value;
+
+ // set defaults for values not already set
+ object defaultValue = v["default"];
+ if (defaultValue != null && !param.Contains(k))
+ param[k] = defaultValue;
+
+ // check required arguments
+ bool required = (bool)v["required"];
+ if (required && !param.Contains(k))
+ missing.Add(k);
+ }
+ if (missing.Count > 0)
+ {
+ string msg = String.Format("missing required arguments: {0}", String.Join(", ", missing));
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+
+ private void CheckRequiredTogether(IDictionary param, IList requiredTogether)
+ {
+ if (requiredTogether == null)
+ return;
+
+ foreach (object check in requiredTogether)
+ {
+ List<string> requiredCheck = ((IList)check).Cast<string>().ToList();
+ List<bool> found = new List<bool>();
+ foreach (string field in requiredCheck)
+ if (param.Contains(field))
+ found.Add(true);
+ else
+ found.Add(false);
+
+ if (found.Contains(true) && found.Contains(false))
+ {
+ string msg = String.Format("parameters are required together: {0}", String.Join(", ", requiredCheck));
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+ }
+
+ private void CheckRequiredOneOf(IDictionary param, IList requiredOneOf)
+ {
+ if (requiredOneOf == null)
+ return;
+
+ foreach (object check in requiredOneOf)
+ {
+ List<string> requiredCheck = ((IList)check).Cast<string>().ToList();
+ int count = 0;
+ foreach (string field in requiredCheck)
+ if (param.Contains(field))
+ count++;
+
+ if (count == 0)
+ {
+ string msg = String.Format("one of the following is required: {0}", String.Join(", ", requiredCheck));
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+ }
+
+ private void CheckRequiredIf(IDictionary param, IList requiredIf)
+ {
+ if (requiredIf == null)
+ return;
+
+ foreach (object check in requiredIf)
+ {
+ IList requiredCheck = (IList)check;
+ List<string> missing = new List<string>();
+ List<string> missingFields = new List<string>();
+ int maxMissingCount = 1;
+ bool oneRequired = false;
+
+ if (requiredCheck.Count < 3 && requiredCheck.Count < 4)
+ FailJson(String.Format("internal error: invalid required_if value count of {0}, expecting 3 or 4 entries", requiredCheck.Count));
+ else if (requiredCheck.Count == 4)
+ oneRequired = (bool)requiredCheck[3];
+
+ string key = (string)requiredCheck[0];
+ object val = requiredCheck[1];
+ IList requirements = (IList)requiredCheck[2];
+
+ if (ParseStr(param[key]) != ParseStr(val))
+ continue;
+
+ string term = "all";
+ if (oneRequired)
+ {
+ maxMissingCount = requirements.Count;
+ term = "any";
+ }
+
+ foreach (string required in requirements.Cast<string>())
+ if (!param.Contains(required))
+ missing.Add(required);
+
+ if (missing.Count >= maxMissingCount)
+ {
+ string msg = String.Format("{0} is {1} but {2} of the following are missing: {3}",
+ key, val.ToString(), term, String.Join(", ", missing));
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+ }
+
+ private void CheckRequiredBy(IDictionary param, IDictionary requiredBy)
+ {
+ foreach (DictionaryEntry entry in requiredBy)
+ {
+ string key = (string)entry.Key;
+ if (!param.Contains(key))
+ continue;
+
+ List<string> missing = new List<string>();
+ List<string> requires = ParseList(entry.Value).Cast<string>().ToList();
+ foreach (string required in requires)
+ if (!param.Contains(required))
+ missing.Add(required);
+
+ if (missing.Count > 0)
+ {
+ string msg = String.Format("missing parameter(s) required by '{0}': {1}", key, String.Join(", ", missing));
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+ }
+
+ private void CheckSubOption(IDictionary param, string key, IDictionary spec)
+ {
+ object value = param[key];
+
+ string type;
+ if (spec["type"].GetType() == typeof(string))
+ type = (string)spec["type"];
+ else
+ type = "delegate";
+
+ string elements = null;
+ Delegate typeConverter = null;
+ if (spec["elements"] != null && spec["elements"].GetType() == typeof(string))
+ {
+ elements = (string)spec["elements"];
+ typeConverter = optionTypes[elements];
+ }
+ else if (spec["elements"] != null)
+ {
+ elements = "delegate";
+ typeConverter = (Delegate)spec["elements"];
+ }
+
+ if (!(type == "dict" || (type == "list" && elements != null)))
+ // either not a dict, or list with the elements set, so continue
+ return;
+ else if (type == "list")
+ {
+ // cast each list element to the type specified
+ if (value == null)
+ return;
+
+ List<object> newValue = new List<object>();
+ foreach (object element in (List<object>)value)
+ {
+ if (elements == "dict")
+ newValue.Add(ParseSubSpec(spec, element, key));
+ else
+ {
+ try
+ {
+ object newElement = typeConverter.DynamicInvoke(element);
+ newValue.Add(newElement);
+ }
+ catch (Exception e)
+ {
+ string msg = String.Format("argument for list entry {0} is of type {1} and we were unable to convert to {2}: {3}",
+ key, element.GetType(), elements, e.Message);
+ FailJson(FormatOptionsContext(msg));
+ }
+ }
+ }
+
+ param[key] = newValue;
+ }
+ else
+ param[key] = ParseSubSpec(spec, value, key);
+ }
+
+ private object ParseSubSpec(IDictionary spec, object value, string context)
+ {
+ bool applyDefaults = (bool)spec["apply_defaults"];
+
+ // set entry to an empty dict if apply_defaults is set
+ IDictionary optionsSpec = (IDictionary)spec["options"];
+ if (applyDefaults && optionsSpec.Keys.Count > 0 && value == null)
+ value = new Dictionary<string, object>();
+ else if (optionsSpec.Keys.Count == 0 || value == null)
+ return value;
+
+ optionsContext.Add(context);
+ Dictionary<string, object> newValue = (Dictionary<string, object>)ParseDict(value);
+ Dictionary<string, string> aliases = GetAliases(spec, newValue);
+ SetNoLogValues(spec, newValue);
+
+ List<string> subLegalInputs = optionsSpec.Keys.Cast<string>().ToList();
+ subLegalInputs.AddRange(aliases.Keys.Cast<string>().ToList());
+
+ CheckArguments(spec, newValue, subLegalInputs);
+ optionsContext.RemoveAt(optionsContext.Count - 1);
+ return newValue;
+ }
+
+ private string GetFormattedResults(Dictionary<string, object> result)
+ {
+ if (!result.ContainsKey("invocation"))
+ result["invocation"] = new Dictionary<string, object>() { { "module_args", RemoveNoLogValues(Params, noLogValues) } };
+
+ if (warnings.Count > 0)
+ result["warnings"] = warnings;
+
+ if (deprecations.Count > 0)
+ result["deprecations"] = deprecations;
+
+ if (Diff.Count > 0 && DiffMode)
+ result["diff"] = Diff;
+
+ return ToJson(result);
+ }
+
+ private string FormatLogData(object data, int indentLevel)
+ {
+ if (data == null)
+ return "$null";
+
+ string msg = "";
+ if (data is IList)
+ {
+ string newMsg = "";
+ foreach (object value in (IList)data)
+ {
+ string entryValue = FormatLogData(value, indentLevel + 2);
+ newMsg += String.Format("\r\n{0}- {1}", new String(' ', indentLevel), entryValue);
+ }
+ msg += newMsg;
+ }
+ else if (data is IDictionary)
+ {
+ bool start = true;
+ foreach (DictionaryEntry entry in (IDictionary)data)
+ {
+ string newMsg = FormatLogData(entry.Value, indentLevel + 2);
+ if (!start)
+ msg += String.Format("\r\n{0}", new String(' ', indentLevel));
+ msg += String.Format("{0}: {1}", (string)entry.Key, newMsg);
+ start = false;
+ }
+ }
+ else
+ msg = (string)RemoveNoLogValues(ParseStr(data), noLogValues);
+
+ return msg;
+ }
+
+ private object RemoveNoLogValues(object value, HashSet<string> noLogStrings)
+ {
+ Queue<Tuple<object, object>> deferredRemovals = new Queue<Tuple<object, object>>();
+ object newValue = RemoveValueConditions(value, noLogStrings, deferredRemovals);
+
+ while (deferredRemovals.Count > 0)
+ {
+ Tuple<object, object> data = deferredRemovals.Dequeue();
+ object oldData = data.Item1;
+ object newData = data.Item2;
+
+ if (oldData is IDictionary)
+ {
+ foreach (DictionaryEntry entry in (IDictionary)oldData)
+ {
+ object newElement = RemoveValueConditions(entry.Value, noLogStrings, deferredRemovals);
+ ((IDictionary)newData).Add((string)entry.Key, newElement);
+ }
+ }
+ else
+ {
+ foreach (object element in (IList)oldData)
+ {
+ object newElement = RemoveValueConditions(element, noLogStrings, deferredRemovals);
+ ((IList)newData).Add(newElement);
+ }
+ }
+ }
+
+ return newValue;
+ }
+
+ private object RemoveValueConditions(object value, HashSet<string> noLogStrings, Queue<Tuple<object, object>> deferredRemovals)
+ {
+ if (value == null)
+ return value;
+
+ Type valueType = value.GetType();
+ HashSet<Type> numericTypes = new HashSet<Type>
+ {
+ typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint),
+ typeof(long), typeof(ulong), typeof(decimal), typeof(double), typeof(float)
+ };
+
+ if (numericTypes.Contains(valueType) || valueType == typeof(bool))
+ {
+ string valueString = ParseStr(value);
+ if (noLogStrings.Contains(valueString))
+ return "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER";
+ foreach (string omitMe in noLogStrings)
+ if (valueString.Contains(omitMe))
+ return "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER";
+ }
+ else if (valueType == typeof(DateTime))
+ value = ((DateTime)value).ToString("o");
+ else if (value is IList)
+ {
+ List<object> newValue = new List<object>();
+ deferredRemovals.Enqueue(new Tuple<object, object>((IList)value, newValue));
+ value = newValue;
+ }
+ else if (value is IDictionary)
+ {
+ Hashtable newValue = new Hashtable();
+ deferredRemovals.Enqueue(new Tuple<object, object>((IDictionary)value, newValue));
+ value = newValue;
+ }
+ else
+ {
+ string stringValue = value.ToString();
+ if (noLogStrings.Contains(stringValue))
+ return "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER";
+ foreach (string omitMe in noLogStrings)
+ if (stringValue.Contains(omitMe))
+ return (stringValue).Replace(omitMe, "********");
+ value = stringValue;
+ }
+ return value;
+ }
+
+ private void CleanupFiles(object s, EventArgs ev)
+ {
+ foreach (string path in cleanupFiles)
+ {
+ if (File.Exists(path))
+ File.Delete(path);
+ else if (Directory.Exists(path))
+ Directory.Delete(path, true);
+ }
+ cleanupFiles = new List<string>();
+ }
+
+ private string FormatOptionsContext(string msg, string prefix = " ")
+ {
+ if (optionsContext.Count > 0)
+ msg += String.Format("{0}found in {1}", prefix, String.Join(" -> ", optionsContext));
+ return msg;
+ }
+
+ [DllImport("kernel32.dll")]
+ private static extern IntPtr GetConsoleWindow();
+
+ private static void ExitModule(int rc)
+ {
+ // When running in a Runspace Environment.Exit will kill the entire
+ // process which is not what we want, detect if we are in a
+ // Runspace and call a ScriptBlock with exit instead.
+ if (Runspace.DefaultRunspace != null)
+ ScriptBlock.Create("Set-Variable -Name LASTEXITCODE -Value $args[0] -Scope Global; exit $args[0]").Invoke(rc);
+ else
+ {
+ // Used for local debugging in Visual Studio
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ Console.WriteLine("Press enter to continue...");
+ Console.ReadLine();
+ }
+ Environment.Exit(rc);
+ }
+ }
+
+ private static void WriteLineModule(string line)
+ {
+ Console.WriteLine(line);
+ }
+ }
+}
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.ModuleUtils.AddType.psm1 b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.ModuleUtils.AddType.psm1
new file mode 100644
index 000000000..673070263
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/module_utils/Ansible.ModuleUtils.AddType.psm1
@@ -0,0 +1,397 @@
+# Copyright (c) 2018 Ansible Project
+# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
+
+Function Add-CSharpType {
+ <#
+ .SYNOPSIS
+ Compiles one or more C# scripts similar to Add-Type. This exposes
+ more configuration options that are useable within Ansible and it
+ also allows multiple C# sources to be compiled together.
+
+ .PARAMETER References
+ [String[]] A collection of C# scripts to compile together.
+
+ .PARAMETER IgnoreWarnings
+ [Switch] Whether to compile code that contains compiler warnings, by
+ default warnings will cause a compiler error.
+
+ .PARAMETER PassThru
+ [Switch] Whether to return the loaded Assembly
+
+ .PARAMETER AnsibleModule
+ [Ansible.Basic.AnsibleModule] used to derive the TempPath and Debug values.
+ TempPath is set to the Tmpdir property of the class
+ IncludeDebugInfo is set when the Ansible verbosity is >= 3
+
+ .PARAMETER TempPath
+ [String] The temporary directory in which the dynamic assembly is
+ compiled to. This file is deleted once compilation is complete.
+ Cannot be used when AnsibleModule is set. This is a no-op when
+ running on PSCore.
+
+ .PARAMETER IncludeDebugInfo
+ [Switch] Whether to include debug information in the compiled
+ assembly. Cannot be used when AnsibleModule is set. This is a no-op
+ when running on PSCore.
+
+ .PARAMETER CompileSymbols
+ [String[]] A list of symbols to be defined during compile time. These are
+ added to the existing symbols, 'CORECLR', 'WINDOWS', 'UNIX' that are set
+ conditionalls in this cmdlet.
+
+ .NOTES
+ The following features were added to control the compiling options from the
+ code itself.
+
+ * Predefined compiler SYMBOLS
+
+ * CORECLR - Added when running on PowerShell Core.
+ * WINDOWS - Added when running on Windows.
+ * UNIX - Added when running on non-Windows.
+ * X86 - Added when running on a 32-bit process (Ansible 2.10+)
+ * AMD64 - Added when running on a 64-bit process (Ansible 2.10+)
+
+ * Ignore compiler warnings inline with the following comment inline
+
+ //NoWarn -Name <rule code> [-CLR Core|Framework]
+
+ * Specify custom assembly references inline
+
+ //AssemblyReference -Name Dll.Location.dll [-CLR Core|Framework]
+
+ # Added in Ansible 2.10
+ //AssemblyReference -Type System.Type.Name [-CLR Core|Framework]
+
+ * Create automatic type accelerators to simplify long namespace names (Ansible 2.9+)
+
+ //TypeAccelerator -Name <AcceleratorName> -TypeName <Name of compiled type>
+ #>
+ param(
+ [Parameter(Mandatory = $true)][AllowEmptyCollection()][String[]]$References,
+ [Switch]$IgnoreWarnings,
+ [Switch]$PassThru,
+ [Parameter(Mandatory = $true, ParameterSetName = "Module")][Object]$AnsibleModule,
+ [Parameter(ParameterSetName = "Manual")][String]$TempPath = $env:TMP,
+ [Parameter(ParameterSetName = "Manual")][Switch]$IncludeDebugInfo,
+ [String[]]$CompileSymbols = @()
+ )
+ if ($null -eq $References -or $References.Length -eq 0) {
+ return
+ }
+
+ # define special symbols CORECLR, WINDOWS, UNIX if required
+ # the Is* variables are defined on PSCore, if absent we assume an
+ # older version of PowerShell under .NET Framework and Windows
+ $defined_symbols = [System.Collections.ArrayList]$CompileSymbols
+
+ if ([System.IntPtr]::Size -eq 4) {
+ $defined_symbols.Add('X86') > $null
+ }
+ else {
+ $defined_symbols.Add('AMD64') > $null
+ }
+
+ $is_coreclr = Get-Variable -Name IsCoreCLR -ErrorAction SilentlyContinue
+ if ($null -ne $is_coreclr) {
+ if ($is_coreclr.Value) {
+ $defined_symbols.Add("CORECLR") > $null
+ }
+ }
+ $is_windows = Get-Variable -Name IsWindows -ErrorAction SilentlyContinue
+ if ($null -ne $is_windows) {
+ if ($is_windows.Value) {
+ $defined_symbols.Add("WINDOWS") > $null
+ }
+ else {
+ $defined_symbols.Add("UNIX") > $null
+ }
+ }
+ else {
+ $defined_symbols.Add("WINDOWS") > $null
+ }
+
+ # Store any TypeAccelerators shortcuts the util wants us to set
+ $type_accelerators = [System.Collections.Generic.List`1[Hashtable]]@()
+
+ # pattern used to find referenced assemblies in the code
+ $assembly_pattern = [Regex]"//\s*AssemblyReference\s+-(?<Parameter>(Name)|(Type))\s+(?<Name>[\w.]*)(\s+-CLR\s+(?<CLR>Core|Framework))?"
+ $no_warn_pattern = [Regex]"//\s*NoWarn\s+-Name\s+(?<Name>[\w\d]*)(\s+-CLR\s+(?<CLR>Core|Framework))?"
+ $type_pattern = [Regex]"//\s*TypeAccelerator\s+-Name\s+(?<Name>[\w.]*)\s+-TypeName\s+(?<TypeName>[\w.]*)"
+
+ # PSCore vs PSDesktop use different methods to compile the code,
+ # PSCore uses Roslyn and can compile the code purely in memory
+ # without touching the disk while PSDesktop uses CodeDom and csc.exe
+ # to compile the code. We branch out here and run each
+ # distribution's method to add our C# code.
+ if ($is_coreclr) {
+ # compile the code using Roslyn on PSCore
+
+ # Include the default assemblies using the logic in Add-Type
+ # https://github.com/PowerShell/PowerShell/blob/master/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs
+ $assemblies = [System.Collections.Generic.HashSet`1[Microsoft.CodeAnalysis.MetadataReference]]@(
+ [Microsoft.CodeAnalysis.CompilationReference]::CreateFromFile(([System.Reflection.Assembly]::GetAssembly([PSObject])).Location)
+ )
+ $netcore_app_ref_folder = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName([PSObject].Assembly.Location), "ref")
+ $lib_assembly_location = [System.IO.Path]::GetDirectoryName([object].Assembly.Location)
+ foreach ($file in [System.IO.Directory]::EnumerateFiles($netcore_app_ref_folder, "*.dll", [System.IO.SearchOption]::TopDirectoryOnly)) {
+ $assemblies.Add([Microsoft.CodeAnalysis.MetadataReference]::CreateFromFile($file)) > $null
+ }
+
+ # loop through the references, parse as a SyntaxTree and get
+ # referenced assemblies
+ $ignore_warnings = New-Object -TypeName 'System.Collections.Generic.Dictionary`2[[String], [Microsoft.CodeAnalysis.ReportDiagnostic]]'
+ $parse_options = ([Microsoft.CodeAnalysis.CSharp.CSharpParseOptions]::Default).WithPreprocessorSymbols($defined_symbols)
+ $syntax_trees = [System.Collections.Generic.List`1[Microsoft.CodeAnalysis.SyntaxTree]]@()
+ foreach ($reference in $References) {
+ # scan through code and add any assemblies that match
+ # //AssemblyReference -Name ... [-CLR Core]
+ # //NoWarn -Name ... [-CLR Core]
+ # //TypeAccelerator -Name ... -TypeName ...
+ $assembly_matches = $assembly_pattern.Matches($reference)
+ foreach ($match in $assembly_matches) {
+ $clr = $match.Groups["CLR"].Value
+ if ($clr -and $clr -ne "Core") {
+ continue
+ }
+
+ $parameter_type = $match.Groups["Parameter"].Value
+ $assembly_path = $match.Groups["Name"].Value
+ if ($parameter_type -eq "Type") {
+ $assembly_path = ([Type]$assembly_path).Assembly.Location
+ }
+ else {
+ if (-not ([System.IO.Path]::IsPathRooted($assembly_path))) {
+ $assembly_path = Join-Path -Path $lib_assembly_location -ChildPath $assembly_path
+ }
+ }
+ $assemblies.Add([Microsoft.CodeAnalysis.MetadataReference]::CreateFromFile($assembly_path)) > $null
+ }
+ $warn_matches = $no_warn_pattern.Matches($reference)
+ foreach ($match in $warn_matches) {
+ $clr = $match.Groups["CLR"].Value
+ if ($clr -and $clr -ne "Core") {
+ continue
+ }
+ $ignore_warnings.Add($match.Groups["Name"], [Microsoft.CodeAnalysis.ReportDiagnostic]::Suppress)
+ }
+ $syntax_trees.Add([Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree]::ParseText($reference, $parse_options)) > $null
+
+ $type_matches = $type_pattern.Matches($reference)
+ foreach ($match in $type_matches) {
+ $type_accelerators.Add(@{Name = $match.Groups["Name"].Value; TypeName = $match.Groups["TypeName"].Value })
+ }
+ }
+
+ # Release seems to contain the correct line numbers compared to
+ # debug,may need to keep a closer eye on this in the future
+ $compiler_options = (New-Object -TypeName Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions -ArgumentList @(
+ [Microsoft.CodeAnalysis.OutputKind]::DynamicallyLinkedLibrary
+ )).WithOptimizationLevel([Microsoft.CodeAnalysis.OptimizationLevel]::Release)
+
+ # set warnings to error out if IgnoreWarnings is not set
+ if (-not $IgnoreWarnings.IsPresent) {
+ $compiler_options = $compiler_options.WithGeneralDiagnosticOption([Microsoft.CodeAnalysis.ReportDiagnostic]::Error)
+ $compiler_options = $compiler_options.WithSpecificDiagnosticOptions($ignore_warnings)
+ }
+
+ # create compilation object
+ $compilation = [Microsoft.CodeAnalysis.CSharp.CSharpCompilation]::Create(
+ [System.Guid]::NewGuid().ToString(),
+ $syntax_trees,
+ $assemblies,
+ $compiler_options
+ )
+
+ # Load the compiled code and pdb info, we do this so we can
+ # include line number in a stracktrace
+ $code_ms = New-Object -TypeName System.IO.MemoryStream
+ $pdb_ms = New-Object -TypeName System.IO.MemoryStream
+ try {
+ $emit_result = $compilation.Emit($code_ms, $pdb_ms)
+ if (-not $emit_result.Success) {
+ $errors = [System.Collections.ArrayList]@()
+
+ foreach ($e in $emit_result.Diagnostics) {
+ # builds the error msg, based on logic in Add-Type
+ # https://github.com/PowerShell/PowerShell/blob/master/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs#L1239
+ if ($null -eq $e.Location.SourceTree) {
+ $errors.Add($e.ToString()) > $null
+ continue
+ }
+
+ $cancel_token = New-Object -TypeName System.Threading.CancellationToken -ArgumentList $false
+ $text_lines = $e.Location.SourceTree.GetText($cancel_token).Lines
+ $line_span = $e.Location.GetLineSpan()
+
+ $diagnostic_message = $e.ToString()
+ $error_line_string = $text_lines[$line_span.StartLinePosition.Line].ToString()
+ $error_position = $line_span.StartLinePosition.Character
+
+ $sb = New-Object -TypeName System.Text.StringBuilder -ArgumentList ($diagnostic_message.Length + $error_line_string.Length * 2 + 4)
+ $sb.AppendLine($diagnostic_message)
+ $sb.AppendLine($error_line_string)
+
+ for ($i = 0; $i -lt $error_line_string.Length; $i++) {
+ if ([System.Char]::IsWhiteSpace($error_line_string[$i])) {
+ continue
+ }
+ $sb.Append($error_line_string, 0, $i)
+ $sb.Append(' ', [Math]::Max(0, $error_position - $i))
+ $sb.Append("^")
+ break
+ }
+
+ $errors.Add($sb.ToString()) > $null
+ }
+
+ throw [InvalidOperationException]"Failed to compile C# code:`r`n$($errors -join "`r`n")"
+ }
+
+ $code_ms.Seek(0, [System.IO.SeekOrigin]::Begin) > $null
+ $pdb_ms.Seek(0, [System.IO.SeekOrigin]::Begin) > $null
+ $compiled_assembly = [System.Runtime.Loader.AssemblyLoadContext]::Default.LoadFromStream($code_ms, $pdb_ms)
+ }
+ finally {
+ $code_ms.Close()
+ $pdb_ms.Close()
+ }
+ }
+ else {
+ # compile the code using CodeDom on PSDesktop
+
+ # configure compile options based on input
+ if ($PSCmdlet.ParameterSetName -eq "Module") {
+ $temp_path = $AnsibleModule.Tmpdir
+ $include_debug = $AnsibleModule.Verbosity -ge 3
+ }
+ else {
+ $temp_path = $TempPath
+ $include_debug = $IncludeDebugInfo.IsPresent
+ }
+ $compiler_options = [System.Collections.ArrayList]@("/optimize")
+ if ($defined_symbols.Count -gt 0) {
+ $compiler_options.Add("/define:" + ([String]::Join(";", $defined_symbols.ToArray()))) > $null
+ }
+
+ $compile_parameters = New-Object -TypeName System.CodeDom.Compiler.CompilerParameters
+ $compile_parameters.GenerateExecutable = $false
+ $compile_parameters.GenerateInMemory = $true
+ $compile_parameters.TreatWarningsAsErrors = (-not $IgnoreWarnings.IsPresent)
+ $compile_parameters.IncludeDebugInformation = $include_debug
+ $compile_parameters.TempFiles = (New-Object -TypeName System.CodeDom.Compiler.TempFileCollection -ArgumentList $temp_path, $false)
+
+ # Add-Type automatically references System.dll, System.Core.dll,
+ # and System.Management.Automation.dll which we replicate here
+ $assemblies = [System.Collections.Generic.HashSet`1[String]]@(
+ "System.dll",
+ "System.Core.dll",
+ ([System.Reflection.Assembly]::GetAssembly([PSObject])).Location
+ )
+
+ # create a code snippet for each reference and check if we need
+ # to reference any extra assemblies
+ $ignore_warnings = [System.Collections.ArrayList]@()
+ $compile_units = [System.Collections.Generic.List`1[System.CodeDom.CodeSnippetCompileUnit]]@()
+ foreach ($reference in $References) {
+ # scan through code and add any assemblies that match
+ # //AssemblyReference -Name ... [-CLR Framework]
+ # //NoWarn -Name ... [-CLR Framework]
+ # //TypeAccelerator -Name ... -TypeName ...
+ $assembly_matches = $assembly_pattern.Matches($reference)
+ foreach ($match in $assembly_matches) {
+ $clr = $match.Groups["CLR"].Value
+ if ($clr -and $clr -ne "Framework") {
+ continue
+ }
+
+ $parameter_type = $match.Groups["Parameter"].Value
+ $assembly_path = $match.Groups["Name"].Value
+ if ($parameter_type -eq "Type") {
+ $assembly_path = ([Type]$assembly_path).Assembly.Location
+ }
+ $assemblies.Add($assembly_path) > $null
+ }
+ $warn_matches = $no_warn_pattern.Matches($reference)
+ foreach ($match in $warn_matches) {
+ $clr = $match.Groups["CLR"].Value
+ if ($clr -and $clr -ne "Framework") {
+ continue
+ }
+ $warning_id = $match.Groups["Name"].Value
+ # /nowarn should only contain the numeric part
+ if ($warning_id.StartsWith("CS")) {
+ $warning_id = $warning_id.Substring(2)
+ }
+ $ignore_warnings.Add($warning_id) > $null
+ }
+ $compile_units.Add((New-Object -TypeName System.CodeDom.CodeSnippetCompileUnit -ArgumentList $reference)) > $null
+
+ $type_matches = $type_pattern.Matches($reference)
+ foreach ($match in $type_matches) {
+ $type_accelerators.Add(@{Name = $match.Groups["Name"].Value; TypeName = $match.Groups["TypeName"].Value })
+ }
+ }
+ if ($ignore_warnings.Count -gt 0) {
+ $compiler_options.Add("/nowarn:" + ([String]::Join(",", $ignore_warnings.ToArray()))) > $null
+ }
+ $compile_parameters.ReferencedAssemblies.AddRange($assemblies)
+ $compile_parameters.CompilerOptions = [String]::Join(" ", $compiler_options.ToArray())
+
+ # compile the code together and check for errors
+ $provider = New-Object -TypeName Microsoft.CSharp.CSharpCodeProvider
+
+ # This calls csc.exe which can take compiler options from environment variables. Currently these env vars
+ # are known to have problems so they are unset:
+ # LIB - additional library paths will fail the compilation if they are invalid
+ $originalEnv = @{}
+ try {
+ 'LIB' | ForEach-Object -Process {
+ $value = Get-Item -LiteralPath "Env:\$_" -ErrorAction SilentlyContinue
+ if ($value) {
+ $originalEnv[$_] = $value
+ Remove-Item -LiteralPath "Env:\$_"
+ }
+ }
+
+ $compile = $provider.CompileAssemblyFromDom($compile_parameters, $compile_units)
+ }
+ finally {
+ foreach ($kvp in $originalEnv.GetEnumerator()) {
+ [System.Environment]::SetEnvironmentVariable($kvp.Key, $kvp.Value, "Process")
+ }
+ }
+
+ if ($compile.Errors.HasErrors) {
+ $msg = "Failed to compile C# code: "
+ foreach ($e in $compile.Errors) {
+ $msg += "`r`n" + $e.ToString()
+ }
+ throw [InvalidOperationException]$msg
+ }
+ $compiled_assembly = $compile.CompiledAssembly
+ }
+
+ $type_accelerator = [PSObject].Assembly.GetType("System.Management.Automation.TypeAccelerators")
+ foreach ($accelerator in $type_accelerators) {
+ $type_name = $accelerator.TypeName
+ $found = $false
+
+ foreach ($assembly_type in $compiled_assembly.GetTypes()) {
+ if ($assembly_type.Name -eq $type_name) {
+ $type_accelerator::Add($accelerator.Name, $assembly_type)
+ $found = $true
+ break
+ }
+ }
+ if (-not $found) {
+ throw "Failed to find compiled class '$type_name' for custom TypeAccelerator."
+ }
+ }
+
+ # return the compiled assembly if PassThru is set.
+ if ($PassThru) {
+ return $compiled_assembly
+ }
+}
+
+Export-ModuleMember -Function Add-CSharpType
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/shell_plugins/pwsh.py b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/shell_plugins/pwsh.py
new file mode 100644
index 000000000..468c54069
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/shell_plugins/pwsh.py
@@ -0,0 +1,376 @@
+# Copyright (c) 2014, Chris Church <chris@ninemoreminutes.com>
+# Copyright (c) 2017 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = '''
+name: powershell
+version_added: historical
+short_description: Cross-Platform PowerShell
+description:
+- The only option when using 'winrm' or 'psrp' as a connection plugin.
+- Can also be used when using 'ssh' as a connection plugin and the C(DefaultShell) has been configured to PowerShell.
+options:
+ async_dir:
+ description:
+ - Directory in which ansible will keep async job information.
+ - Before Ansible 2.8, this was set to C(remote_tmp + "\\.ansible_async").
+ default: '%HOME%/.ansible_async'
+ ini:
+ - section: pwsh
+ key: async_dir
+ vars:
+ - name: ansible_async_dir
+ version_added: '2.8'
+ remote_tmp:
+ description:
+ - Temporary directory to use on targets when copying files to the host.
+ default: '%HOME%/.ansible/tmp'
+ ini:
+ - section: pwsh
+ key: remote_tmp
+ vars:
+ - name: ansible_remote_tmp
+ set_module_language:
+ description:
+ - Controls if we set the locale for modules when executing on the
+ target.
+ - Windows only supports C(no) as an option.
+ type: bool
+ default: 'no'
+ choices: ['no', False]
+ environment:
+ description:
+ - List of dictionaries of environment variables and their values to use when
+ executing commands.
+ type: list
+ default: [{}]
+'''
+# original uses this, but we're copying into this plugin explicitly
+# so we can override windows-isms
+#
+# extends_documentation_fragment:
+# - shell_windows
+
+import base64
+import os
+import re
+import shlex
+import pkgutil
+import xml.etree.ElementTree as ET
+import ntpath
+
+from ansible.module_utils._text import to_bytes, to_text
+from ansible.plugins.shell import ShellBase
+
+
+_common_args = ['pwsh', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted']
+
+
+def _parse_clixml(data, stream="Error"):
+ """
+ Takes a byte string like '#< CLIXML\r\n<Objs...' and extracts the stream
+ message encoded in the XML data. CLIXML is used by PowerShell to encode
+ multiple objects in stderr.
+ """
+ lines = []
+
+ # There are some scenarios where the stderr contains a nested CLIXML element like
+ # '<# CLIXML\r\n<# CLIXML\r\n<Objs>...</Objs><Objs>...</Objs>'.
+ # Parse each individual <Objs> element and add the error strings to our stderr list.
+ # https://github.com/ansible/ansible/issues/69550
+ while data:
+ end_idx = data.find(b"</Objs>") + 7
+ current_element = data[data.find(b"<Objs "):end_idx]
+ data = data[end_idx:]
+
+ clixml = ET.fromstring(current_element)
+ namespace_match = re.match(r'{(.*)}', clixml.tag)
+ namespace = "{%s}" % namespace_match.group(1) if namespace_match else ""
+
+ strings = clixml.findall("./%sS" % namespace)
+ lines.extend([e.text.replace('_x000D__x000A_', '') for e in strings if e.attrib.get('S') == stream])
+
+ return to_bytes('\r\n'.join(lines))
+
+
+class ShellModule(ShellBase):
+
+ # Common shell filenames that this plugin handles
+ # Powershell is handled differently. It's selected when winrm is the
+ # connection
+ COMPATIBLE_SHELLS = frozenset()
+ # Family of shells this has. Must match the filename without extension
+ SHELL_FAMILY = 'pwsh'
+
+ _SHELL_REDIRECT_ALLNULL = '> $null'
+ _SHELL_AND = ';'
+
+ # Used by various parts of Ansible to do Windows specific changes
+ _IS_WINDOWS = True
+
+ # TODO: add binary module support
+
+ def env_prefix(self, **kwargs):
+ # powershell/winrm env handling is handled in the exec wrapper
+ return ""
+
+ # def join_path(self, *args):
+ # # use normpath() to remove doubled slashed and convert forward to backslashes
+ # parts = [ntpath.normpath(self._unquote(arg)) for arg in args]
+
+ # # Becuase ntpath.join treats any component that begins with a backslash as an absolute path,
+ # # we have to strip slashes from at least the beginning, otherwise join will ignore all previous
+ # # path components except for the drive.
+ # return ntpath.join(parts[0], *[part.strip('\\') for part in parts[1:]])
+
+ def get_remote_filename(self, pathname):
+ # powershell requires that script files end with .ps1
+ base_name = os.path.basename(pathname.strip())
+ name, ext = os.path.splitext(base_name.strip())
+ if ext.lower() not in ['.ps1']:
+ return name + '.ps1'
+
+ return base_name.strip()
+
+ def path_has_trailing_slash(self, path):
+ # Allow Windows paths to be specified using either slash.
+ path = self._unquote(path)
+ return path.endswith('/') or path.endswith('\\')
+
+ # def chmod(self, paths, mode):
+ # raise NotImplementedError('chmod is not implemented for Powershell')
+
+ # def chown(self, paths, user):
+ # raise NotImplementedError('chown is not implemented for Powershell')
+
+ # def set_user_facl(self, paths, user, mode):
+ # raise NotImplementedError('set_user_facl is not implemented for Powershell')
+
+ def remove(self, path, recurse=False):
+ path = self._escape(self._unquote(path))
+ if recurse:
+ return self._encode_script('''Remove-Item '%s' -Force -Recurse;''' % path)
+ else:
+ return self._encode_script('''Remove-Item '%s' -Force;''' % path)
+
+ def mkdtemp(self, basefile=None, system=False, mode=None, tmpdir=None):
+ # Windows does not have an equivalent for the system temp files, so
+ # the param is ignored
+ if not basefile:
+ basefile = self.__class__._generate_temp_dir_name()
+ basefile = self._escape(self._unquote(basefile))
+ basetmpdir = tmpdir if tmpdir else self.get_option('remote_tmp')
+
+ script = '''
+ $tmp_path = [System.Environment]::ExpandEnvironmentVariables('%s')
+ $tmp = New-Item -Type Directory -Path $tmp_path -Name '%s'
+ Write-Output -InputObject $tmp.FullName
+ ''' % (basetmpdir, basefile)
+ return self._encode_script(script.strip())
+
+ def expand_user(self, user_home_path, username=''):
+ # PowerShell only supports "~" (not "~username"). Resolve-Path ~ does
+ # not seem to work remotely, though by default we are always starting
+ # in the user's home directory.
+ user_home_path = self._unquote(user_home_path)
+ if user_home_path == '~':
+ script = 'Write-Output (Get-Location).Path'
+ elif user_home_path.startswith('~\\'):
+ script = "Write-Output ((Get-Location).Path + '%s')" % self._escape(user_home_path[1:])
+ else:
+ script = "Write-Output '%s'" % self._escape(user_home_path)
+ return self._encode_script(script)
+
+ def exists(self, path):
+ path = self._escape(self._unquote(path))
+ script = '''
+ If (Test-Path '%s')
+ {
+ $res = 0;
+ }
+ Else
+ {
+ $res = 1;
+ }
+ Write-Output '$res';
+ Exit $res;
+ ''' % path
+ return self._encode_script(script)
+
+ def checksum(self, path, *args, **kwargs):
+ path = self._escape(self._unquote(path))
+ script = '''
+ If (Test-Path -PathType Leaf '%(path)s')
+ {
+ $sp = new-object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider;
+ $fp = [System.IO.File]::Open('%(path)s', [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
+ [System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
+ $fp.Dispose();
+ }
+ ElseIf (Test-Path -PathType Container '%(path)s')
+ {
+ Write-Output "3";
+ }
+ Else
+ {
+ Write-Output "1";
+ }
+ ''' % dict(path=path)
+ return self._encode_script(script)
+
+ def build_module_command(self, env_string, shebang, cmd, arg_path=None):
+ bootstrap_wrapper = pkgutil.get_data("ansible.executor.powershell", "bootstrap_wrapper.ps1")
+
+ # pipelining bypass
+ if cmd == '':
+ return self._encode_script(script=bootstrap_wrapper, strict_mode=False, preserve_rc=False)
+
+ # non-pipelining
+
+ cmd_parts = shlex.split(cmd, posix=False)
+ cmd_parts = list(map(to_text, cmd_parts))
+ if shebang and shebang.lower() == '#!powershell':
+ if not self._unquote(cmd_parts[0]).lower().endswith('.ps1'):
+ # we're running a module via the bootstrap wrapper
+ cmd_parts[0] = '"%s.ps1"' % self._unquote(cmd_parts[0])
+ # HACK begin dirty, dirty hack
+ # we need to override the built-in Ansible.Basic module util
+ # to one that will work on non-Windows platforms.
+ # But, we don't have access to the code that processes those in anything pluggable.
+ # So instead, we're going to replace the bootstrap_wrapper with one that contains a slight modification
+ # that will replace the Ansible.Basic module util contents with the contents of the one in this collection.
+ # This particular way of hacking it will only work because we're relying on the connection being local.
+ # To make this hack work on remote hosts, we'd have to also copy that file's contents or modify the payload
+ # before it made it to the remote host. The reason we can't just embed it in commands as strings is because
+ # it will be too big.
+ local_mu = os.path.join(os.path.dirname(__file__), '..', 'module_utils')
+ ansible_basic_cs = os.path.join(local_mu, 'Ansible.Basic.cs')
+ addtype_ps = os.path.join(local_mu, 'Ansible.ModuleUtils.AddType.psm1')
+ wrapper_hacked = '''
+ &chcp.com 65001 > $null
+ $exec_wrapper_str = $input | Out-String
+ $split_parts = $exec_wrapper_str.Split(@("`0`0`0`0"), 2, [StringSplitOptions]::RemoveEmptyEntries)
+ If (-not $split_parts.Length -eq 2) { throw "invalid payload" }
+ Set-Variable -Name json_raw -Value $split_parts[1]
+ # begin hack
+ ############
+ function Get-EncodedFileContents {
+ param($Path)
+
+ $enc = [System.Text.Encoding]::UTF8
+ $mustring = [System.IO.File]::ReadAllText($Path, $enc)
+ $mubytes = $enc.GetBytes($mustring)
+ $mu64 = [Convert]::ToBase64String($mubytes)
+
+ $mu64
+ }
+
+ $payload_obj = $json_raw | ConvertFrom-Json
+
+ if ($payload_obj.csharp_utils.'Ansible.Basic') {
+ $local_basic_file = '%s'
+ $payload_obj.csharp_utils.'Ansible.Basic' = Get-EncodedFileContents($local_basic_file)
+ }
+
+ if ($payload_obj.powershell_modules.'Ansible.ModuleUtils.AddType') {
+ $local_addtype_file = '%s'
+ $payload_obj.powershell_modules.'Ansible.ModuleUtils.AddType' = Get-EncodedFileContents($local_addtype_file)
+ }
+
+ $json_raw = $payload_obj | ConvertTo-Json -Depth 99
+ ##########
+ # end hack
+ $exec_wrapper = [ScriptBlock]::Create($split_parts[0])
+ &$exec_wrapper
+ ''' % (ansible_basic_cs, addtype_ps)
+ bootstrap_wrapper = wrapper_hacked
+ wrapper_cmd = "cat " + cmd_parts[0] + " | " + self._encode_script(script=bootstrap_wrapper, strict_mode=False, preserve_rc=False)
+ return wrapper_cmd
+ elif shebang and shebang.startswith('#!'):
+ cmd_parts.insert(0, shebang[2:])
+ elif not shebang:
+ # The module is assumed to be a binary
+ cmd_parts[0] = self._unquote(cmd_parts[0])
+ cmd_parts.append(arg_path)
+ script = '''
+ Try
+ {
+ %s
+ %s
+ }
+ Catch
+ {
+ $_obj = @{ failed = $true }
+ If ($_.Exception.GetType)
+ {
+ $_obj.Add('msg', $_.Exception.Message)
+ }
+ Else
+ {
+ $_obj.Add('msg', $_.ToString())
+ }
+ If ($_.InvocationInfo.PositionMessage)
+ {
+ $_obj.Add('exception', $_.InvocationInfo.PositionMessage)
+ }
+ ElseIf ($_.ScriptStackTrace)
+ {
+ $_obj.Add('exception', $_.ScriptStackTrace)
+ }
+ Try
+ {
+ $_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
+ }
+ Catch
+ {
+ }
+ Echo $_obj | ConvertTo-Json -Compress -Depth 99
+ Exit 1
+ }
+ ''' % (env_string, ' '.join(cmd_parts))
+ return self._encode_script(script, preserve_rc=False)
+
+ def wrap_for_exec(self, cmd):
+ return '& %s; exit $LASTEXITCODE' % cmd
+
+ def _unquote(self, value):
+ '''Remove any matching quotes that wrap the given value.'''
+ value = to_text(value or '')
+ m = re.match(r'^\s*?\'(.*?)\'\s*?$', value)
+ if m:
+ return m.group(1)
+ m = re.match(r'^\s*?"(.*?)"\s*?$', value)
+ if m:
+ return m.group(1)
+ return value
+
+ def _escape(self, value):
+ '''Return value escaped for use in PowerShell single quotes.'''
+ # There are 5 chars that need to be escaped in a single quote.
+ # https://github.com/PowerShell/PowerShell/blob/b7cb335f03fe2992d0cbd61699de9d9aafa1d7c1/src/System.Management.Automation/engine/parser/CharTraits.cs#L265-L272
+ return re.compile(u"(['\u2018\u2019\u201a\u201b])").sub(u'\\1\\1', value)
+
+ def _encode_script(self, script, as_list=False, strict_mode=True, preserve_rc=True):
+ '''Convert a PowerShell script to a single base64-encoded command.'''
+ script = to_text(script)
+
+ if script == u'-':
+ cmd_parts = _common_args + ['-Command', '-']
+
+ else:
+ if strict_mode:
+ script = u'Set-StrictMode -Version Latest\r\n%s' % script
+ # try to propagate exit code if present- won't work with begin/process/end-style scripts (ala put_file)
+ # NB: the exit code returned may be incorrect in the case of a successful command followed by an invalid command
+ if preserve_rc:
+ script = u'%s\r\nIf (-not $?) { If (Get-Variable LASTEXITCODE -ErrorAction SilentlyContinue) { exit $LASTEXITCODE } Else { exit 1 } }\r\n'\
+ % script
+ script = '\n'.join([x.strip() for x in script.splitlines() if x.strip()])
+ encoded_script = to_text(base64.b64encode(script.encode('utf-16-le')), 'utf-8')
+ cmd_parts = _common_args + ['-EncodedCommand', encoded_script]
+
+ if as_list:
+ return cmd_parts
+ return ' '.join(cmd_parts)
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/tasks/main.yml
new file mode 100644
index 000000000..f8beefc0d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/tasks/main.yml
@@ -0,0 +1,6 @@
+---
+- name: Set the connection and shell
+ when: ansible_os_family | default('Windows') != 'Windows'
+ set_fact:
+ ansible_connection: "{{ pwsh_ansible_connection }}"
+ ansible_shell_type: "{{ pwsh_ansible_shell_type }}"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/vars/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/vars/main.yml
new file mode 100644
index 000000000..1c61487b4
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_sqlserver_test_plugins/vars/main.yml
@@ -0,0 +1,3 @@
+---
+pwsh_ansible_connection: local_pwsh
+pwsh_ansible_shell_type: pwsh
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/aliases
new file mode 100644
index 000000000..118c01c05
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/aliases
@@ -0,0 +1,2 @@
+windows/setup
+needs/target/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/meta/main.yml
new file mode 100644
index 000000000..b77b99ca8
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/tasks/main.yml
new file mode 100644
index 000000000..acc1dbeb4
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/tasks/main.yml
@@ -0,0 +1,8 @@
+---
+- name: Install Powershell modules
+ ansible.windows.win_shell: |
+ {{ item }}
+ no_log: "{{ ansible_verbosity | int < 3 }}"
+ loop:
+ - "{{ dbatools_install_cmd }}"
+ - "{{ dbops_install_cmd }}"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/vars/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/vars/main.yml
new file mode 100644
index 000000000..977dc70e7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/setup_win_sqlserver/vars/main.yml
@@ -0,0 +1,2 @@
+---
+sqlserver_windows: true
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/tasks/main.yml
new file mode 100644
index 000000000..0b647cc61
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_configure/tasks/main.yml
@@ -0,0 +1,67 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.sp_configure:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["sp_configure"]
+ block:
+ - name: Configure
+ lowlydba.sqlserver.sp_configure:
+ name: "show advanced options"
+ value: 1
+ register: result
+ - assert:
+ that:
+ - result.data.NewValue == 1
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.PreviousValue != None
+
+ - name: Configure in checkmode
+ lowlydba.sqlserver.sp_configure:
+ name: "show advanced options"
+ value: 0
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify unchanged configuration
+ lowlydba.sqlserver.sp_configure:
+ name: "show advanced options"
+ value: 0
+ register: result
+ - assert:
+ that:
+ - result.data.PreviousValue == 1
+ - result.data.NewValue == 0
+ - result is changed
+
+ - name: Unchanged configuration
+ lowlydba.sqlserver.sp_configure:
+ name: "show advanced options"
+ value: 0
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ - name: Config requiring restart
+ lowlydba.sqlserver.sp_configure:
+ name: "ScanForStartupProcedures"
+ value: 1
+ register: result
+ - assert:
+ that:
+ - result is changed
+ - result.data.RestartRequired is true
+
+ always:
+ - name: Reset Option
+ lowlydba.sqlserver.sp_configure:
+ name: "show advanced options"
+ value: 0
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/tasks/main.yml
new file mode 100644
index 000000000..27f226703
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/sp_whoisactive/tasks/main.yml
@@ -0,0 +1,46 @@
+---
+- name: Var block
+ vars:
+ target_database: "master"
+ module_defaults:
+ lowlydba.sqlserver.sp_whoisactive:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ target_database }}"
+ tags: ["sp_whoisactive"]
+ block:
+ - name: Install sp_whoisactive
+ lowlydba.sqlserver.sp_whoisactive:
+ register: result
+ - assert:
+ that:
+ - result.data.Status != None
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.Database == "{{ target_database }}"
+ - result.data.Version != None
+ - result.data.Status in ('Installed', 'Updated')
+ - result is changed
+
+ - name: Update sp_whoisactive
+ lowlydba.sqlserver.sp_whoisactive:
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.Database == "{{ target_database }}"
+ - result.data.Version != None
+ - result.data.Status == 'Updated'
+ - result is changed
+
+ - name: Update sp_whoisactive in checkmode
+ lowlydba.sqlserver.sp_whoisactive:
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/tasks/main.yml
new file mode 100644
index 000000000..003f4e464
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/traceflag/tasks/main.yml
@@ -0,0 +1,90 @@
+---
+- name: Var block
+ vars:
+ trace_flag: "999"
+ module_defaults:
+ lowlydba.sqlserver.traceflag:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ trace_flag: "{{ trace_flag }}"
+ tags: ["traceflag"]
+ block:
+ - name: Set a traceflag
+ lowlydba.sqlserver.traceflag:
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.InstanceName != None
+ - result.data.TraceFlag == {{ trace_flag }}
+
+ - name: Enable an enabled traceflag
+ lowlydba.sqlserver.traceflag:
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.InstanceName != None
+ - result.data.TraceFlag == {{ trace_flag }}
+ - result is not changed
+
+ - name: Disable a traceflag
+ lowlydba.sqlserver.traceflag:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.InstanceName != None
+ - result.data.TraceFlag == {{ trace_flag }}
+ - result is changed
+
+ - name: Disable a disabled traceflag
+ lowlydba.sqlserver.traceflag:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.InstanceName != None
+ - result.data.TraceFlag == {{ trace_flag }}
+ - result is not changed
+
+ - name: Enable a traceflag
+ lowlydba.sqlserver.traceflag:
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.InstanceName != None
+ - result.data.TraceFlag == {{ trace_flag }}
+ - result is changed
+
+ - name: Disable a traceflag in checkmode
+ lowlydba.sqlserver.traceflag:
+ enabled: false
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify unchanged in checkmode
+ lowlydba.sqlserver.traceflag:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.InstanceName != None
+ - result.data.TraceFlag == {{ trace_flag }}
+ - result is changed
+
+ always:
+ - name: Disable a traceflag
+ lowlydba.sqlserver.traceflag:
+ enabled: false
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/aliases
new file mode 100644
index 000000000..4f4b6b91b
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/aliases
@@ -0,0 +1,2 @@
+context/target
+setup/once/setup_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/tasks/main.yml
new file mode 100644
index 000000000..3c377e4d9
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/user/tasks/main.yml
@@ -0,0 +1,115 @@
+---
+- name: Var block
+ vars:
+ login_name: "PhillipJFry"
+ plain_password: "P0pS3cret!23$%"
+ password_expiration_enabled: false
+ password_policy_enforced: false
+ password_must_change: false
+ enabled: false
+ default_database: "master"
+ language: "us_english"
+ default_schema: "dbo"
+ username: "PhillipJFry"
+ database: "master"
+ module_defaults:
+ lowlydba.sqlserver.login:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ default_database: "{{ default_database }}"
+ login: "{{ login_name }}"
+ password: "{{ plain_password }}"
+ password_expiration_enabled: "{{ password_expiration_enabled }}"
+ password_must_change: "{{ password_must_change }}"
+ enabled: "{{ enabled }}"
+ language: "{{ language }}"
+ state: present
+ lowlydba.sqlserver.user:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ database }}"
+ login: "{{ login_name }}"
+ username: "{{ username }}"
+ default_schema: "{{ default_schema }}"
+ state: present
+ tags: ["sqlserver.user"]
+ block:
+ - name: Create login
+ lowlydba.sqlserver.login:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+
+ - name: Create user
+ lowlydba.sqlserver.user:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Database == "{{ database }}"
+ - result.data.DefaultSchema == "{{ default_schema }}"
+ - result.data.Login == "{{ login_name }}"
+ - result.data.Name == "{{ username }}"
+
+ - name: Modify user's schema
+ lowlydba.sqlserver.user:
+ default_schema: "INFORMATION_SCHEMA"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Database == "{{ database }}"
+ - result.data.DefaultSchema == "INFORMATION_SCHEMA"
+ - result.data.Login == "{{ login_name }}"
+ - result.data.Name == "{{ username }}"
+
+ - name: Drop a user
+ lowlydba.sqlserver.user:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result is changed
+
+ - name: Create user in checkmode
+ lowlydba.sqlserver.user:
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify checkmode works
+ lowlydba.sqlserver.user:
+ register: result
+ - assert:
+ that:
+ - result.data != None
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.Database == "{{ database }}"
+ - result.data.DefaultSchema == "{{ default_schema }}"
+ - result.data.Login == "{{ login_name }}"
+ - result.data.Name == "{{ username }}"
+
+ always:
+ - name: Drop user
+ lowlydba.sqlserver.user:
+ state: "absent"
+ - name: Drop login
+ lowlydba.sqlserver.login:
+ state: "absent"
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/aliases
new file mode 100644
index 000000000..53361dd98
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/tasks/main.yml
new file mode 100644
index 000000000..b4142a487
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_listener/tasks/main.yml
@@ -0,0 +1,90 @@
+---
+- name: Var block
+ vars:
+ ag_name: "ShhListen"
+ listener_name: "CanYouHear"
+ cluster_type: "None"
+ failover_mode: "Manual"
+ availability_mode: "AsynchronousCommit"
+ force: true
+ port: 1433
+ module_defaults:
+ lowlydba.sqlserver.availability_group:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ ag_name: "{{ ag_name }}"
+ cluster_type: "{{ cluster_type }}"
+ failover_mode: "{{ failover_mode }}"
+ availability_mode: "{{ availability_mode }}"
+ force: "{{ force }}"
+ lowlydba.sqlserver.ag_listener:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ ag_name: "{{ ag_name }}"
+ listener_name: "{{ listener_name }}"
+ port: "{{ port }}"
+ ip_address: "192.168.6.9"
+ subnet_mask: "255.255.255.0"
+ tags: ["ag_listener"]
+ block:
+ - name: Enable hadr
+ lowlydba.sqlserver.hadr:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ enabled: true
+ force: true
+
+ - name: Create availability group
+ lowlydba.sqlserver.availability_group:
+
+ - name: Create ag listener
+ lowlydba.sqlserver.ag_listener:
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.AvailabilityGroup == ag_name
+ - result.data.Name == listener_name
+ - result.data.PortNumber == port
+ - result is changed
+
+ - name: Change ag listener port
+ lowlydba.sqlserver.ag_listener:
+ port: 1434
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.AvailabilityGroup == ag_name
+ - result.data.Name == listener_name
+ - result.data.PortNumber == 1434
+ - result is changed
+
+ - name: Drop ag listener in checkmode
+ lowlydba.sqlserver.ag_listener:
+ state: absent
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Drop ag listener
+ lowlydba.sqlserver.ag_listener:
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ always:
+ - name: Drop availability group
+ lowlydba.sqlserver.availability_group:
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/aliases
new file mode 100644
index 000000000..681188f50
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/tasks/main.yml
new file mode 100644
index 000000000..8a8990789
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_ag_replica/tasks/main.yml
@@ -0,0 +1,81 @@
+---
+- name: Var block
+ vars:
+ ag_name: "IntAG3"
+ cluster_type: "None"
+ failover_mode: "Manual"
+ dtc_support_enabled: false
+ availability_mode: "AsynchronousCommit"
+ seeding_mode: "Manual"
+ database_health_trigger: true
+ use_last_backup: true
+ healthcheck_timeout: 15000
+ basic_availability_group: false
+ force: true
+ failure_condition_level: "OnServerDown"
+ session_timeout: 15
+ module_defaults:
+ lowlydba.sqlserver.availability_group:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ ag_name: "{{ ag_name }}"
+ cluster_type: "{{ cluster_type }}"
+ failover_mode: "{{ failover_mode }}"
+ dtc_support_enabled: "{{ dtc_support_enabled }}"
+ availability_mode: "{{ availability_mode }}"
+ seeding_mode: "{{ seeding_mode }}"
+ database_health_trigger: "{{ database_health_trigger }}"
+ use_last_backup: "{{ use_last_backup }}"
+ healthcheck_timeout: "{{ healthcheck_timeout }}"
+ basic_availability_group: "{{ basic_availability_group }}"
+ force: "{{ force }}"
+ failure_condition_level: "{{ failure_condition_level }}"
+ lowlydba.sqlserver.ag_replica:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ sql_instance_replica: "{{ sqlserver_instance }}"
+ sql_username_replica: "{{ sqlserver_username }}"
+ sql_password_replica: "{{ sqlserver_password }}"
+ ag_name: "{{ ag_name }}"
+ session_timeout: "{{ session_timeout }}"
+ configure_xe_session: true
+
+ tags: ["ag_replica"]
+ block:
+ - name: Enable hadr
+ lowlydba.sqlserver.hadr:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ enabled: true
+ force: true
+
+ - name: Create availability group
+ lowlydba.sqlserver.availability_group:
+ register: ag
+
+ - name: Set replica
+ lowlydba.sqlserver.ag_replica:
+ session_timeout: 20
+ endpoint_url: "TCP://{{ ag.data.SqlInstance }}:5022"
+ read_only_routing_list: "{{ ag.data.SqlInstance }}"
+ read_only_routing_connection_url: "TCP://{{ ag.data.SqlInstance }}:1433"
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.AvailabilityGroup == ag_name
+ - result.data.AvailabilityMode == availability_mode
+ - result.data.SessionTimeout == 20
+ - result.data.FailoverMode == failover_mode
+ - result.data.EndpointUrl == "TCP://{{ ag.data.SqlInstance }}:5022"
+ - result is changed
+
+ always:
+ - name: Drop availability group
+ lowlydba.sqlserver.availability_group:
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/aliases
new file mode 100644
index 000000000..113cf8502
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/agent_job
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/meta/main.yml
new file mode 100644
index 000000000..903427adb
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - agent_job
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/aliases
new file mode 100644
index 000000000..0657417f7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/agent_job_category
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/meta/main.yml
new file mode 100644
index 000000000..042a349fd
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_category/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - agent_job_category
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/aliases
new file mode 100644
index 000000000..6edbc658d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/agent_job_schedule
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/meta/main.yml
new file mode 100644
index 000000000..1d28c1c83
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_schedule/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - agent_job_schedule
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/aliases
new file mode 100644
index 000000000..8b8c7ccd2
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/agent_job_step
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/meta/main.yml
new file mode 100644
index 000000000..1f8bdef0c
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_agent_job_step/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - agent_job_step
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/aliases
new file mode 100644
index 000000000..681188f50
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/tasks/main.yml
new file mode 100644
index 000000000..cfa1ad7e7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_availability_group/tasks/main.yml
@@ -0,0 +1,109 @@
+---
+- name: Var block
+ vars:
+ ag_name: "IntAG1"
+ cluster_type: "None"
+ failover_mode: "Manual"
+ dtc_support_enabled: false
+ availability_mode: "AsynchronousCommit"
+ seeding_mode: "Automatic"
+ database_health_trigger: true
+ use_last_backup: false
+ healthcheck_timeout: 15000
+ basic_availability_group: false
+ force: false
+ failure_condition_level: "OnServerDown"
+ database: "ag-test-db"
+ module_defaults:
+ lowlydba.sqlserver.availability_group:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ ag_name: "{{ ag_name }}"
+ cluster_type: "{{ cluster_type }}"
+ failover_mode: "{{ failover_mode }}"
+ dtc_support_enabled: "{{ dtc_support_enabled }}"
+ availability_mode: "{{ availability_mode }}"
+ seeding_mode: "{{ seeding_mode }}"
+ database_health_trigger: "{{ database_health_trigger }}"
+ database: "{{ database }}"
+ healthcheck_timeout: "{{ healthcheck_timeout }}"
+ basic_availability_group: "{{ basic_availability_group }}"
+ force: "{{ force }}"
+ allow_null_backup: true
+ failure_condition_level: "{{ failure_condition_level }}"
+ lowlydba.sqlserver.database:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["availability_group"]
+ block:
+ - name: Enable hadr
+ lowlydba.sqlserver.hadr:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ enabled: true
+ force: true
+
+ - name: Create a database
+ lowlydba.sqlserver.database:
+ database: "{{ database }}"
+
+ - name: Create availability group
+ lowlydba.sqlserver.availability_group:
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.AvailabilityGroup == "{{ ag_name }}"
+ - result.data.ClusterType == "{{ cluster_type }}"
+ - result.data.DtcSupportEnabled is false
+ - result.data.AvailabilityReplicas != None
+ - result is changed
+
+ - name: Change availability group
+ lowlydba.sqlserver.availability_group:
+ dtc_support_enabled: true
+ all_ags: true
+ failure_condition_level: "OnServerUnresponsive"
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.AvailabilityGroup == "{{ ag_name }}"
+ - result.data.ClusterType == "{{ cluster_type }}"
+ - result.data.DtcSupportEnabled is true
+ - result.data.AvailabilityReplicas != None
+ - result is changed
+
+ - name: Drop availability group in check mode
+ lowlydba.sqlserver.availability_group:
+ state: absent
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Drop availability group
+ lowlydba.sqlserver.availability_group:
+ state: absent
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ always:
+ - name: Drop availability group
+ lowlydba.sqlserver.availability_group:
+ state: absent
+
+ - name: Drop database
+ lowlydba.sqlserver.database:
+ database: "{{ database }}"
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/aliases
new file mode 100644
index 000000000..f31c12910
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/backup
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/meta/main.yml
new file mode 100644
index 000000000..caa9577e7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_backup/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - backup
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/aliases
new file mode 100644
index 000000000..d92135b7d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/credential
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/meta/main.yml
new file mode 100644
index 000000000..49316406d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_credential/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - credential
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/aliases
new file mode 100644
index 000000000..d65b6b5fa
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/database
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/meta/main.yml
new file mode 100644
index 000000000..e2ce31a8d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_database/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - database
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/aliases
new file mode 100644
index 000000000..5d4e3adea
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/dba_multitool
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/meta/main.yml
new file mode 100644
index 000000000..9db0dd083
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_dba_multitool/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - dba_multitool
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/aliases
new file mode 100644
index 000000000..db95f221c
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/first_responder_kit
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/meta/main.yml
new file mode 100644
index 000000000..26403983d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_first_responder_kit/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - first_responder_kit
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/aliases
new file mode 100644
index 000000000..53361dd98
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/tasks/main.yml
new file mode 100644
index 000000000..b15234a7e
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_hadr/tasks/main.yml
@@ -0,0 +1,53 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.hadr:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ force: true
+ tags: ["hadr"]
+ block:
+ - name: Enable hadr
+ lowlydba.sqlserver.hadr:
+ enabled: true
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.IsHadrEnabled is true
+
+ - name: Disable hadr
+ lowlydba.sqlserver.hadr:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.IsHadrEnabled is false
+ - result is changed
+
+ - name: Checkmode enable hadr
+ lowlydba.sqlserver.hadr:
+ enabled: true
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify checkmode works
+ lowlydba.sqlserver.hadr:
+ enabled: false
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result.data.IsHadrEnabled is false
+ - result is not changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/aliases
new file mode 100644
index 000000000..53361dd98
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/files/1-select-choice.sql b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/files/1-select-choice.sql
new file mode 100644
index 000000000..54a481acb
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/files/1-select-choice.sql
@@ -0,0 +1 @@
+SELECT 'choice';
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/tasks/main.yml
new file mode 100644
index 000000000..7892cabfd
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_install_script/tasks/main.yml
@@ -0,0 +1,72 @@
+---
+- name: Var block
+ vars:
+ path: "{{ role_path }}/files/"
+ dest: "tmp/"
+ database_name: "lowlydba-migration-test"
+ module_defaults:
+ lowlydba.sqlserver.install_script:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ create_database: true
+ no_recurse: true
+ database: "{{ database_name }}"
+ #path: "{{ path }}"
+ schema_version_table: "SchemaVersion"
+ output_file: "output.txt"
+ tags: ["sqlserver.install_script"]
+
+ block:
+ - name: Copy migration script(s)
+ ansible.windows.win_copy:
+ src: "{{ path }}"
+ dest: "{{ dest }}"
+ register: script_file
+
+ - name: Install a script in no log mode
+ lowlydba.sqlserver.install_script:
+ no_log_version: true
+ path: "{{ script_file.dest }}"
+ register: result
+ - assert:
+ that:
+ - result.data.Database == "{{ database_name }}"
+ - result.data.Successful == true
+ - result is changed
+
+ - name: Install a script in checkmode
+ lowlydba.sqlserver.install_script:
+ path: "{{ script_file.dest }}"
+ register: result
+ check_mode: true
+ - assert:
+ that:
+ - result is changed
+
+ - name: Install a script
+ lowlydba.sqlserver.install_script:
+ path: "{{ script_file.dest }}"
+ register: result
+ - assert:
+ that:
+ - result.data.Database == "{{ database_name }}"
+ - result.data.Successful == true
+ - result is changed
+
+ - name: Install same script
+ lowlydba.sqlserver.install_script:
+ path: "{{ script_file.dest }}"
+ register: result
+ - assert:
+ that:
+ - result is not changed
+
+ always:
+ - name: Cleanup database
+ lowlydba.sqlserver.database:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ database_name }}"
+ state: absent
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/aliases
new file mode 100644
index 000000000..0340b3e28
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/instance_info
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/meta/main.yml
new file mode 100644
index 000000000..abcbf15ed
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_instance_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - instance_info
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/aliases
new file mode 100644
index 000000000..391c2f481
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/login
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/meta/main.yml
new file mode 100644
index 000000000..a74c1d5b1
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_login/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - login
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/aliases
new file mode 100644
index 000000000..a5d876908
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/maintenance_solution
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/meta/main.yml
new file mode 100644
index 000000000..7db45301e
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_maintenance_solution/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - maintenance_solution
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/aliases
new file mode 100644
index 000000000..74d59ced7
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/memory
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/meta/main.yml
new file mode 100644
index 000000000..3b6d1394f
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_memory/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - memory
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/aliases
new file mode 100644
index 000000000..bdd247296
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/nonquery
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/meta/main.yml
new file mode 100644
index 000000000..42a2f3dce
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_nonquery/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - nonquery
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/aliases
new file mode 100644
index 000000000..954bb313f
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/resource_governor
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/meta/main.yml
new file mode 100644
index 000000000..eb714ab26
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_resource_governor/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - resource_governor
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/aliases
new file mode 100644
index 000000000..681188f50
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/tasks/main.yml
new file mode 100644
index 000000000..59c80e621
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_restore/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+- name: Var block
+ vars:
+ database_name: "model"
+ restore_database: "model_restore"
+ tags: ["restore"]
+ block:
+ - name: Backup a database
+ lowlydba.sqlserver.backup:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ database_name }}"
+ register: backup_result
+
+ - name: Restore a database
+ lowlydba.sqlserver.restore:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ database: "{{ restore_database }}"
+ path: "{{ backup_result.data.BackupPath }}"
+ replace_db_name_in_file: true
+ block_size: "16kb"
+ destination_file_suffix: "_new"
+ destination_file_prefix: "db_"
+ register: result
+ - assert:
+ that:
+ - result.data.SqlInstance != None
+ - result.data.Database == restore_database
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/aliases
new file mode 100644
index 000000000..b942bc246
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/rg_resource_pool
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/meta/main.yml
new file mode 100644
index 000000000..66db486ba
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_resource_pool/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - rg_resource_pool
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/aliases
new file mode 100644
index 000000000..6cf3ad272
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/rg_workload_group
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/meta/main.yml
new file mode 100644
index 000000000..e556da433
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_rg_workload_group/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - rg_workload_group
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/aliases
new file mode 100644
index 000000000..0dae9becf
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/sa
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/meta/main.yml
new file mode 100644
index 000000000..4183f7974
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sa/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - sa
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/aliases
new file mode 100644
index 000000000..e229d3e89
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/sp_configure
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/meta/main.yml
new file mode 100644
index 000000000..c5d8f4ae8
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_configure/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - sp_configure
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/aliases
new file mode 100644
index 000000000..244177887
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/sp_whoisactive
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/meta/main.yml
new file mode 100644
index 000000000..b356fa027
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_sp_whoisactive/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - sp_whoisactive
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/aliases
new file mode 100644
index 000000000..681188f50
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/tasks/main.yml
new file mode 100644
index 000000000..85123a5b0
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_spn/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+- name: Var block
+ vars:
+ service_account: "NT SERVICE\\MSSQLSERVER"
+ property: "msDS-AllowedToDelegateTo"
+ module_defaults:
+ lowlydba.sqlserver.spn:
+ computer: "{{ sqlserver_instance }}"
+ service_account: "{{ service_account }}"
+ tags: ["spn"]
+ block:
+ # Super limited testing below; no AD available on Github runners
+ # and with how simple this module is, its not worth the cost
+ # to implement a robust solution.
+ # - name: Set SPN
+ # lowlydba.sqlserver.spn:
+ # register: result
+ # - assert:
+ # that:
+ # - result.data.Name != None
+ # - result.data.ServiceAccount == service_account
+ # - result.data.Property == property
+ # - result.data.IsSet is true
+ # - result.data.Notes == "Successfully added SPN"
+ # - result is changed
+
+ - name: Remove spn
+ lowlydba.sqlserver.spn:
+ state: "absent"
+ register: result
+ - assert:
+ that:
+ # - result.data.Name != None
+ # - result.data.ServiceAccount == service_account
+ # - result.data.Property == property
+ # - result.data.IsSet is false
+ # - result.data.Notes == "Successfully removed SPN"
+ - result is not changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/aliases
new file mode 100644
index 000000000..53361dd98
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/aliases
@@ -0,0 +1,4 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/meta/main.yml
new file mode 100644
index 000000000..a33097525
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_sqlserver_test_plugins
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/tasks/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/tasks/main.yml
new file mode 100644
index 000000000..d118cb954
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_tcp_port/tasks/main.yml
@@ -0,0 +1,49 @@
+---
+- name: Var block
+ module_defaults:
+ lowlydba.sqlserver.tcp_port:
+
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ tags: ["tcp_port"]
+ block:
+
+ - name: Get instance info
+ lowlydba.sqlserver.instance_info:
+ sql_instance: "{{ sqlserver_instance }}"
+ sql_username: "{{ sqlserver_username }}"
+ sql_password: "{{ sqlserver_password }}"
+ register: instance
+
+ - name: Set default
+ lowlydba.sqlserver.tcp_port:
+ sql_instance: "{{ instance.data.SqlInstance }}"
+ port: 1433
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+
+ - name: Checkmode
+ lowlydba.sqlserver.tcp_port:
+ sql_instance: "{{ instance.data.SqlInstance }}"
+ port: 1434
+ check_mode: true
+ register: result
+ - assert:
+ that:
+ - result is changed
+
+ - name: Verify checkmode works
+ lowlydba.sqlserver.tcp_port:
+ sql_instance: "{{ instance.data.SqlInstance }}"
+ port: 1433
+ register: result
+ - assert:
+ that:
+ - result.data.ComputerName != None
+ - result.data.InstanceName != None
+ - result.data.SqlInstance != None
+ - result is not changed
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/aliases
new file mode 100644
index 000000000..37ace9c73
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/2
+context/target
+setup/once/setup_win_sqlserver
+needs/target/traceflag
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/meta/main.yml
new file mode 100644
index 000000000..e9b7437d5
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_traceflag/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - traceflag
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/aliases b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/aliases
new file mode 100644
index 000000000..35c77c970
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/aliases
@@ -0,0 +1,5 @@
+windows/all
+windows/group/1
+context/target
+setup/once/setup_win_sqlserver
+needs/target/user
diff --git a/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/meta/main.yml b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/meta/main.yml
new file mode 100644
index 000000000..e9806117d
--- /dev/null
+++ b/ansible_collections/lowlydba/sqlserver/tests/integration/targets/win_user/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - user