Skip to content

Commit

Permalink
Add multitool module (#81)
Browse files Browse the repository at this point in the history
* initial commit

* getting testy

* bump to 0.7.0

* test with branch

* fix changelog merge
  • Loading branch information
lowlydba authored May 21, 2022
1 parent b19edab commit 1931363
Show file tree
Hide file tree
Showing 10 changed files with 301 additions and 98 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ lowlydba.sqlserver Release Notes
.. contents:: Topics


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
======

Expand All @@ -13,6 +26,11 @@ Release Summary

Adding new SPN module

Minor Changes
-------------

- Remove CI support for Ansible 2.10

New Modules
-----------

Expand Down
205 changes: 108 additions & 97 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,135 +4,146 @@ releases:
changes:
release_summary: It's a release! First version to publish to Ansible Galaxy.
fragments:
- v0.1.0_summary.yml
- 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'
- 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'
- v0.1.1_summary.yml
release_date: "2022-03-31"
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)
- 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
- 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'
- 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.
- 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
- 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'
- 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.
- 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)
- 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
- 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'
- 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
- 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
- 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'
- 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
- release-summary-0-6-0.yml
modules:
- description: Configures SPNs for SQL Server.
name: spn
namespace: ''
release_date: '2022-05-20'
- 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"
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace: lowlydba
name: sqlserver
version: 0.6.0
version: 0.7.0
readme: README.md
authors:
- John McCall (github.com/lowlydba)
Expand Down
65 changes: 65 additions & 0 deletions plugins/modules/dba_multitool.ps1
Original file line number Diff line number Diff line change
@@ -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.95" }

$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)", $_)
}
Loading

0 comments on commit 1931363

Please sign in to comment.