summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/windows/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/community/windows/plugins')
-rw-r--r--ansible_collections/community/windows/plugins/modules/psexec.py2
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_auto_logon.ps17
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_credential.ps13
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_credential.py2
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_dns_record.ps129
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_dns_record.py17
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_domain_computer.py4
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_domain_group.py4
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_domain_group_membership.py4
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_domain_object_info.py4
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_domain_ou.py4
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_domain_user.py4
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_format.ps18
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_iis_webapppool.py8
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_inet_proxy.ps12
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_mapped_drive.ps12
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_nssm.ps155
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_nssm.py7
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_partition.ps17
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_psmodule.ps199
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_psmodule.py6
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_psmodule_info.ps12
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_rabbitmq_plugin.ps115
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_rds_rap.ps110
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_region.ps16
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_regmerge.ps131
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_regmerge.py25
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_robocopy.ps110
-rw-r--r--ansible_collections/community/windows/plugins/modules/win_scheduled_task.ps113
29 files changed, 167 insertions, 223 deletions
diff --git a/ansible_collections/community/windows/plugins/modules/psexec.py b/ansible_collections/community/windows/plugins/modules/psexec.py
index 36541ca67..c2d96f293 100644
--- a/ansible_collections/community/windows/plugins/modules/psexec.py
+++ b/ansible_collections/community/windows/plugins/modules/psexec.py
@@ -283,7 +283,7 @@ EXAMPLES = r'''
$sec_protocols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault
$sec_protocols = $sec_protocols -bor [Net.SecurityProtocolType]::Tls12
[Net.ServicePointManager]::SecurityProtocol = $sec_protocols
- $url = "https://github.com/ansible/ansible/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
+ $url = "https://github.com/ansible/ansible-documentation/raw/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
Invoke-Expression ((New-Object Net.WebClient).DownloadString($url))
exit
delegate_to: localhost
diff --git a/ansible_collections/community/windows/plugins/modules/win_auto_logon.ps1 b/ansible_collections/community/windows/plugins/modules/win_auto_logon.ps1
index 66a20dd9e..ee76c4f7a 100644
--- a/ansible_collections/community/windows/plugins/modules/win_auto_logon.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_auto_logon.ps1
@@ -53,7 +53,6 @@ if ($state -eq 'absent') {
Add-CSharpType -AnsibleModule $module -References @'
using Microsoft.Win32.SafeHandles;
using System;
-using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Text;
@@ -154,8 +153,6 @@ namespace Ansible.WinAutoLogon
{
internal SafeLsaMemory() : base(true) { }
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
-
protected override bool ReleaseHandle()
{
return NativeMethods.LsaFreeMemory(handle) == 0;
@@ -171,8 +168,6 @@ namespace Ansible.WinAutoLogon
base.SetHandle(ptr);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
-
protected override bool ReleaseHandle()
{
if (handle != IntPtr.Zero)
@@ -185,8 +180,6 @@ namespace Ansible.WinAutoLogon
{
internal SafeLsaHandle() : base(true) { }
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
-
protected override bool ReleaseHandle()
{
return NativeMethods.LsaClose(handle) == 0;
diff --git a/ansible_collections/community/windows/plugins/modules/win_credential.ps1 b/ansible_collections/community/windows/plugins/modules/win_credential.ps1
index b39bff57e..72fd6960c 100644
--- a/ansible_collections/community/windows/plugins/modules/win_credential.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_credential.ps1
@@ -60,7 +60,6 @@ using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Text;
@@ -223,7 +222,6 @@ namespace Ansible.CredentialManager
{
public SafeCredentialBuffer() : base(true) { }
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
NativeMethods.CredFree(handle);
@@ -242,7 +240,6 @@ namespace Ansible.CredentialManager
{
base.SetHandle(handle);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
diff --git a/ansible_collections/community/windows/plugins/modules/win_credential.py b/ansible_collections/community/windows/plugins/modules/win_credential.py
index fd605f0d0..ca942d926 100644
--- a/ansible_collections/community/windows/plugins/modules/win_credential.py
+++ b/ansible_collections/community/windows/plugins/modules/win_credential.py
@@ -97,7 +97,7 @@ options:
- When C(absent), the credential specified by I(name) and I(type) is
removed.
- When C(present), the credential specified by I(name) and I(type) is
- removed.
+ added.
type: str
choices: [ absent, present ]
default: present
diff --git a/ansible_collections/community/windows/plugins/modules/win_dns_record.ps1 b/ansible_collections/community/windows/plugins/modules/win_dns_record.ps1
index f19d9d3c4..5212d1ace 100644
--- a/ansible_collections/community/windows/plugins/modules/win_dns_record.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_dns_record.ps1
@@ -17,6 +17,7 @@ $spec = @{
value = @{ type = "list"; elements = "str"; default = @() ; aliases = @( 'values' ) }
weight = @{ type = "int" }
zone = @{ type = "str"; required = $true }
+ zone_scope = @{ type = "str" }
computer_name = @{ type = "str" }
}
required_if = @(, @("type", "SRV", @("port", "priority", "weight")))
@@ -34,6 +35,7 @@ $type = $module.Params.type
$values = $module.Params.value
$weight = $module.Params.weight
$zone = $module.Params.zone
+$zone_scope = $module.Params.zone_scope
$dns_computer_name = $module.Params.computer_name
$extra_args = @{}
@@ -42,6 +44,9 @@ $extra_args_new_records = @{}
if ($null -ne $dns_computer_name) {
$extra_args.ComputerName = $dns_computer_name
}
+if ($null -ne $zone_scope) {
+ $extra_args.ZoneScope = $zone_scope
+}
if ($aging -eq $true) {
$extra_args_new_records.AgeRecord = $true
}
@@ -118,7 +123,8 @@ if ($null -ne $records) {
$record_value = $record.RecordData.$(Get-DnsServerResourceRecordDataPropertyName).ToString()
if ((-Not $required_values.ContainsKey($record_value)) -Or (-Not $record_aging_old -eq $aging)) {
$record | Remove-DnsServerResourceRecord -ZoneName $zone -Force -WhatIf:$module.CheckMode @extra_args
- $changes.before += "[$zone] $($record.HostName) $($record.TimeToLive.TotalSeconds) IN $type $record_value`n"
+ $changes.before += "[$zone{0}] $($record.HostName) $($record.TimeToLive.TotalSeconds) IN $type $record_value`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
$module.Result.changed = $true
}
else {
@@ -136,10 +142,12 @@ if ($null -ne $records) {
Set-DnsServerResourceRecord -ZoneName $zone -OldInputObject $record -NewInputObject $new_record -WhatIf:$module.CheckMode @extra_args
$changes.before += -join @(
- "[$zone] $($record.HostName) $($record.TimeToLive.TotalSeconds) IN "
+ "[$zone{0}] $($record.HostName) $($record.TimeToLive.TotalSeconds) IN " `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
"$type $record_value $record_port_old $record_weight_old $record_priority_old`n"
)
- $changes.after += "[$zone] $($record.HostName) $($ttl.TotalSeconds) IN $type $record_value $port $weight $priority`n"
+ $changes.after += "[$zone{0}] $($record.HostName) $($ttl.TotalSeconds) IN $type $record_value $port $weight $priority`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
$module.Result.changed = $true
}
}
@@ -149,8 +157,10 @@ if ($null -ne $records) {
$new_record = $record.Clone()
$new_record.TimeToLive = $ttl
Set-DnsServerResourceRecord -ZoneName $zone -OldInputObject $record -NewInputObject $new_record -WhatIf:$module.CheckMode @extra_args
- $changes.before += "[$zone] $($record.HostName) $($record.TimeToLive.TotalSeconds) IN $type $record_value`n"
- $changes.after += "[$zone] $($record.HostName) $($ttl.TotalSeconds) IN $type $record_value`n"
+ $changes.before += "[$zone{0}] $($record.HostName) $($record.TimeToLive.TotalSeconds) IN $type $record_value`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
+ $changes.after += "[$zone{0}] $($record.HostName) $($ttl.TotalSeconds) IN $type $record_value`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
$module.Result.changed = $true
}
}
@@ -184,7 +194,8 @@ if ($null -ne $values -and $values.Count -gt 0) {
catch {
$module.FailJson("Error adding DNS $type resource $name in zone $zone with value $value", $_)
}
- $changes.after += "[$zone] $name $($ttl.TotalSeconds) IN $type $value`n"
+ $changes.after += "[$zone{0}] $name $($ttl.TotalSeconds) IN $type $value`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
}
$module.Result.changed = $true
}
@@ -199,12 +210,14 @@ else {
$records_end = Get-DnsServerResourceRecord -ZoneName $zone -Name $name -RRType $type -Node -ErrorAction:Ignore @extra_args | Sort-Object
$module.Diff.before = @(
$records | ForEach-Object {
- "[$zone] $($_.HostName) $($_.TimeToLive.TotalSeconds) IN $type $($_.RecordData.$(Get-DnsServerResourceRecordDataPropertyName).ToString())`n"
+ "[$zone{0}] $($_.HostName) $($_.TimeToLive.TotalSeconds) IN $type $($_.RecordData.$(Get-DnsServerResourceRecordDataPropertyName).ToString())`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
}
) -join ''
$module.Diff.after = @(
$records_end | ForEach-Object {
- "[$zone] $($_.HostName) $($_.TimeToLive.TotalSeconds) IN $type $($_.RecordData.$(Get-DnsServerResourceRecordDataPropertyName).ToString())`n"
+ "[$zone{0}] $($_.HostName) $($_.TimeToLive.TotalSeconds) IN $type $($_.RecordData.$(Get-DnsServerResourceRecordDataPropertyName).ToString())`n" `
+ -f ("", "/$zone_scope")[$null -ne $zone_scope]
}
) -join ''
}
diff --git a/ansible_collections/community/windows/plugins/modules/win_dns_record.py b/ansible_collections/community/windows/plugins/modules/win_dns_record.py
index 38692e311..97242c949 100644
--- a/ansible_collections/community/windows/plugins/modules/win_dns_record.py
+++ b/ansible_collections/community/windows/plugins/modules/win_dns_record.py
@@ -91,6 +91,13 @@ options:
- The zone must already exist.
required: yes
type: str
+ zone_scope:
+ description:
+ - The name of the zone scope to manage (eg C(ScopeAZ)).
+ - The zone must already exist.
+ required: no
+ type: str
+ version_added: 2.0.0
computer_name:
description:
- Specifies a DNS server.
@@ -193,6 +200,16 @@ EXAMPLES = r'''
type: "TXT"
value: "justavalue"
zone: "example.com"
+
+# Demostrate creating a A record to Zone Scope
+
+- name: Create database server record
+ community.windows.win_dns_record:
+ name: "cgyl1404p.amer.example.com"
+ type: "A"
+ value: "10.1.1.1"
+ zone: "amer.example.com"
+ zone_scope: "external"
'''
RETURN = r'''
diff --git a/ansible_collections/community/windows/plugins/modules/win_domain_computer.py b/ansible_collections/community/windows/plugins/modules/win_domain_computer.py
index aff0f4687..b19b0760e 100644
--- a/ansible_collections/community/windows/plugins/modules/win_domain_computer.py
+++ b/ansible_collections/community/windows/plugins/modules/win_domain_computer.py
@@ -13,6 +13,10 @@ description:
- Create, read, update and delete computers in Active Directory using a
windows bridge computer to launch New-ADComputer, Get-ADComputer,
Set-ADComputer, Remove-ADComputer and Move-ADObject powershell commands.
+deprecated:
+ removed_in: 3.0.0
+ why: This module has been moved into the C(microsoft.ad) collection.
+ alternative: Use the M(microsoft.ad.computer) module instead.
options:
name:
description:
diff --git a/ansible_collections/community/windows/plugins/modules/win_domain_group.py b/ansible_collections/community/windows/plugins/modules/win_domain_group.py
index b761055e8..729f6f6f7 100644
--- a/ansible_collections/community/windows/plugins/modules/win_domain_group.py
+++ b/ansible_collections/community/windows/plugins/modules/win_domain_group.py
@@ -11,6 +11,10 @@ short_description: Creates, modifies or removes domain groups
description:
- Creates, modifies or removes groups in Active Directory.
- For local groups, use the M(ansible.windows.win_group) module instead.
+deprecated:
+ removed_in: 3.0.0
+ why: This module has been moved into the C(microsoft.ad) collection.
+ alternative: Use the M(microsoft.ad.group) module instead.
options:
attributes:
description:
diff --git a/ansible_collections/community/windows/plugins/modules/win_domain_group_membership.py b/ansible_collections/community/windows/plugins/modules/win_domain_group_membership.py
index 5e10ac3b2..d3e0901f9 100644
--- a/ansible_collections/community/windows/plugins/modules/win_domain_group_membership.py
+++ b/ansible_collections/community/windows/plugins/modules/win_domain_group_membership.py
@@ -11,6 +11,10 @@ short_description: Manage Windows domain group membership
description:
- Allows the addition and removal of domain users
and domain groups from/to a domain group.
+deprecated:
+ removed_in: 3.0.0
+ why: This module has been moved into the C(microsoft.ad) collection.
+ alternative: Use the M(microsoft.ad.group) module instead.
options:
name:
description:
diff --git a/ansible_collections/community/windows/plugins/modules/win_domain_object_info.py b/ansible_collections/community/windows/plugins/modules/win_domain_object_info.py
index c7efac7fe..ddd0ab2d0 100644
--- a/ansible_collections/community/windows/plugins/modules/win_domain_object_info.py
+++ b/ansible_collections/community/windows/plugins/modules/win_domain_object_info.py
@@ -10,6 +10,10 @@ module: win_domain_object_info
short_description: Gather information an Active Directory object
description:
- Gather information about multiple Active Directory object(s).
+deprecated:
+ removed_in: 3.0.0
+ why: This module has been moved into the C(microsoft.ad) collection.
+ alternative: Use the M(microsoft.ad.object_info) module instead.
options:
domain_password:
description:
diff --git a/ansible_collections/community/windows/plugins/modules/win_domain_ou.py b/ansible_collections/community/windows/plugins/modules/win_domain_ou.py
index e144b8373..30ad0ed86 100644
--- a/ansible_collections/community/windows/plugins/modules/win_domain_ou.py
+++ b/ansible_collections/community/windows/plugins/modules/win_domain_ou.py
@@ -18,6 +18,10 @@ description:
- Manage Active Directory Organizational Units
- Adds, Removes and Modifies Active Directory Organizational Units
- Task should be delegated to a Windows Active Directory Domain Controller
+deprecated:
+ removed_in: 3.0.0
+ why: This module has been moved into the C(microsoft.ad) collection.
+ alternative: Use the M(microsoft.ad.ou) module instead.
options:
name:
description:
diff --git a/ansible_collections/community/windows/plugins/modules/win_domain_user.py b/ansible_collections/community/windows/plugins/modules/win_domain_user.py
index aee5efd0a..3e7290fff 100644
--- a/ansible_collections/community/windows/plugins/modules/win_domain_user.py
+++ b/ansible_collections/community/windows/plugins/modules/win_domain_user.py
@@ -9,6 +9,10 @@ module: win_domain_user
short_description: Manages Windows Active Directory user accounts
description:
- Manages Windows Active Directory user accounts.
+deprecated:
+ removed_in: 3.0.0
+ why: This module has been moved into the C(microsoft.ad) collection.
+ alternative: Use the M(microsoft.ad.user) module instead.
options:
name:
description:
diff --git a/ansible_collections/community/windows/plugins/modules/win_format.ps1 b/ansible_collections/community/windows/plugins/modules/win_format.ps1
index 0746fbe47..86d918e0b 100644
--- a/ansible_collections/community/windows/plugins/modules/win_format.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_format.ps1
@@ -74,7 +74,13 @@ function Get-AnsibleVolume {
if ($null -ne $DriveLetter) {
try {
- $volume = Get-Volume -DriveLetter $DriveLetter
+ # This needs to be a two step process so that we can support Windows failover cluster disks.
+ # With Windows failover cluster disks every node sees every disk participating in that cluster.
+ # For example a clustered disk in a three node cluster will show up three times.
+ # Fortunatly we can differentiate local from remote disk as only local disk will ever have a disk number.
+ # So with that we just ignore all disk without a number which will result in a local disk being picked.
+ $partition = Get-Partition -DriveLetter $DriveLetter | Where-Object { $null -ne $_.DiskNumber }
+ $volume = Get-Volume -Partition $partition
}
catch {
$module.FailJson("There was an error retrieving the volume using drive_letter $($DriveLetter): $($_.Exception.Message)", $_)
diff --git a/ansible_collections/community/windows/plugins/modules/win_iis_webapppool.py b/ansible_collections/community/windows/plugins/modules/win_iis_webapppool.py
index 7cca2e3bf..5397b9df5 100644
--- a/ansible_collections/community/windows/plugins/modules/win_iis_webapppool.py
+++ b/ansible_collections/community/windows/plugins/modules/win_iis_webapppool.py
@@ -94,6 +94,14 @@ EXAMPLES = r'''
managedRuntimeVersion: v4.0
autoStart: no
+- name: Creates an application pool with "No Managed Code" for .Net compatibility
+ community.windows.win_iis_webapppool:
+ name: AnotherAppPool
+ state: started
+ attributes:
+ managedRuntimeVersion: ''
+ autoStart: false
+
# In the below example we are setting attributes in child element processModel
# https://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel
- name: Manage child element and set identity of application pool
diff --git a/ansible_collections/community/windows/plugins/modules/win_inet_proxy.ps1 b/ansible_collections/community/windows/plugins/modules/win_inet_proxy.ps1
index 769a8f725..e210057c9 100644
--- a/ansible_collections/community/windows/plugins/modules/win_inet_proxy.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_inet_proxy.ps1
@@ -68,7 +68,6 @@ $win_inet_invoke = @'
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
-using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Ansible.WinINetProxy
@@ -197,7 +196,6 @@ namespace Ansible.WinINetProxy
base.SetHandle(handle);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
diff --git a/ansible_collections/community/windows/plugins/modules/win_mapped_drive.ps1 b/ansible_collections/community/windows/plugins/modules/win_mapped_drive.ps1
index 210ae223a..ff1898884 100644
--- a/ansible_collections/community/windows/plugins/modules/win_mapped_drive.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_mapped_drive.ps1
@@ -41,7 +41,6 @@ Add-CSharpType -AnsibleModule $module -References @'
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
-using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Ansible.MappedDrive
@@ -160,7 +159,6 @@ namespace Ansible.MappedDrive
base.SetHandle(handle);
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
diff --git a/ansible_collections/community/windows/plugins/modules/win_nssm.ps1 b/ansible_collections/community/windows/plugins/modules/win_nssm.ps1
index 3b951cf19..966780552 100644
--- a/ansible_collections/community/windows/plugins/modules/win_nssm.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_nssm.ps1
@@ -31,7 +31,6 @@ $description = Get-AnsibleParam -obj $params -name 'description' -type 'str'
$application = Get-AnsibleParam -obj $params -name "application" -type "path"
$appDirectory = Get-AnsibleParam -obj $params -name "working_directory" -aliases "app_directory", "chdir" -type "path"
-$appParameters = Get-AnsibleParam -obj $params -name "app_parameters"
$appArguments = Get-AnsibleParam -obj $params -name "arguments" -aliases "app_parameters_free_form"
$stdoutFile = Get-AnsibleParam -obj $params -name "stdout_file" -type "path"
@@ -46,7 +45,6 @@ $app_rotate_online = Get-AnsibleParam -obj $params -name "app_rotate_online" -ty
$app_stop_method_console = Get-AnsibleParam -obj $params -name "app_stop_method_console" -type "int"
$app_stop_method_skip = Get-AnsibleParam -obj $params -name "app_stop_method_skip" -type "int" -validateset 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-# Deprecated options, will be removed in a major release after 2021-07-01.
$startMode = Get-AnsibleParam -obj $params -name "start_mode" -type "str" -default "auto" -validateset $start_modes_map.Keys -resultobj $result
$dependencies = Get-AnsibleParam -obj $params -name "dependencies" -type "list"
$user = Get-AnsibleParam -obj $params -name "username" -type "str" -aliases "user"
@@ -297,27 +295,6 @@ function Stop-NssmService {
}
}
-function Add-DepByDate {
- [CmdletBinding()]
- param(
- [Parameter(Mandatory = $true)]
- [String]$Message,
-
- [Parameter(Mandatory = $true)]
- [String]$Date
- )
-
- # Legacy doesn't natively support deprecate by date, need to do this manually until we use Ansible.Basic
- if (-not $result.ContainsKey('deprecations')) {
- $result.deprecations = @()
- }
- $result.deprecations += @{
- msg = $Message
- date = $Date
- collection_name = "community.windows"
- }
-}
-
Function ConvertTo-NormalizedUser {
[CmdletBinding()]
param (
@@ -380,38 +357,6 @@ Function ConvertTo-NormalizedUser {
}
}
-if (($null -ne $appParameters) -and ($null -ne $appArguments)) {
- Fail-Json $result "'app_parameters' and 'arguments' are mutually exclusive but have both been set."
-}
-
-# Backward compatibility for old parameters style. Remove the block bellow in 2.12
-if ($null -ne $appParameters) {
- $dep = @{
- Message = "The parameter 'app_parameters' will be removed soon, use 'arguments' instead"
- Date = "2022-07-01"
- }
- Add-DepByDate @dep
-
- if ($appParameters -isnot [string]) {
- Fail-Json -obj $result -message "The app_parameters parameter must be a string representing a dictionary."
- }
-
- # Convert dict-as-string form to list
- $escapedAppParameters = $appParameters.TrimStart("@").TrimStart("{").TrimEnd("}").Replace("; ", "`n").Replace("\", "\\")
- $appParametersHash = ConvertFrom-StringData -StringData $escapedAppParameters
-
- $appParamsArray = @()
- $appParametersHash.GetEnumerator() | Foreach-Object {
- if ($_.Name -ne "_") {
- $appParamsArray += $_.Name
- }
- $appParamsArray += $_.Value
- }
- $appArguments = @($appParamsArray)
-
- # The rest of the code should use only the new $appArguments variable
-}
-
if ($state -ne 'absent') {
if ($null -eq $application) {
Fail-Json -obj $result -message "The application parameter must be defined when the state is not absent."
diff --git a/ansible_collections/community/windows/plugins/modules/win_nssm.py b/ansible_collections/community/windows/plugins/modules/win_nssm.py
index d79f638b8..8cc434a5a 100644
--- a/ansible_collections/community/windows/plugins/modules/win_nssm.py
+++ b/ansible_collections/community/windows/plugins/modules/win_nssm.py
@@ -56,17 +56,10 @@ options:
description:
- Path to receive error output.
type: path
- app_parameters:
- description:
- - A string representing a dictionary of parameters to be passed to the application when it starts.
- - DEPRECATED since v2.8, please use I(arguments) instead.
- - This is mutually exclusive with I(arguments).
- type: str
arguments:
description:
- Parameters to be passed to the application when it starts.
- This can be either a simple string or a list.
- - This is mutually exclusive with I(app_parameters).
aliases: [ app_parameters_free_form ]
type: str
dependencies:
diff --git a/ansible_collections/community/windows/plugins/modules/win_partition.ps1 b/ansible_collections/community/windows/plugins/modules/win_partition.ps1
index 6e4517690..a6ce1d5c4 100644
--- a/ansible_collections/community/windows/plugins/modules/win_partition.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_partition.ps1
@@ -100,7 +100,12 @@ if ($null -ne $disk_number -and $null -ne $partition_number) {
# Check if drive_letter is either auto-assigned or a character from A-Z
elseif ($drive_letter -and $drive_letter -ne "auto" -and -not ($disk_number -and $partition_number)) {
if ($drive_letter -match "^[a-zA-Z]$") {
- $ansible_partition = Get-Partition -DriveLetter $drive_letter -ErrorAction SilentlyContinue
+ # This step need to be a bit more complex so that we can support Windows failover cluster disks.
+ # With Windows failover cluster disks every node sees every disk participating in that cluster.
+ # For example a clustered disk in a three node cluster will show up three times.
+ # Fortunatly we can differentiate local from remote disk as only local disk will ever have a disk number.
+ # So with that we just ignore all disk without a number which will result in a local disk being picked.
+ $ansible_partition = Get-Partition -DriveLetter $drive_letter -ErrorAction SilentlyContinue | Where-Object { $null -ne $_.DiskNumber }
}
else {
$module.FailJson("Incorrect usage of drive_letter: specify a drive letter from A-Z or use 'auto' to automatically assign a drive letter")
diff --git a/ansible_collections/community/windows/plugins/modules/win_psmodule.ps1 b/ansible_collections/community/windows/plugins/modules/win_psmodule.ps1
index f755e8dda..788519143 100644
--- a/ansible_collections/community/windows/plugins/modules/win_psmodule.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_psmodule.ps1
@@ -18,7 +18,6 @@ $maximum_version = Get-AnsibleParam -obj $params -name "maximum_version" -type "
$repo = Get-AnsibleParam -obj $params -name "repository" -type "str"
$repo_user = Get-AnsibleParam -obj $params -name "username" -type "str"
$repo_pass = Get-AnsibleParam -obj $params -name "password" -type "str"
-$url = Get-AnsibleParam -obj $params -name "url" -type str
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "present", "absent", "latest"
$allow_clobber = Get-AnsibleParam -obj $params -name "allow_clobber" -type "bool" -default $false
$skip_publisher_check = Get-AnsibleParam -obj $params -name "skip_publisher_check" -type "bool" -default $false
@@ -255,8 +254,11 @@ Function Install-PsModule {
"Repository", "Credential")
$ht = Add-DefinedParameter -Hashtable $ht -ParametersNames $ParametersNames
- # When module require License Acceptance, `-Force` is mandatory to skip interactive prompt
- if ((Find-Module @ht).AdditionalMetadata.requireLicenseAcceptance) {
+ # When module require License Acceptance, or repository is Untrusted.
+ # `-Force` is mandatory to skip interactive prompt
+ $psgetModuleInfo = Find-Module @ht
+ if (($psgetModuleInfo.AdditionalMetadata.requireLicenseAcceptance -eq "True") -or
+ ((Get-PSRepository -Name $psgetModuleInfo.Repository).InstallationPolicy -eq "Untrusted")) {
$ht["Force"] = $true
}
else {
@@ -363,82 +365,6 @@ Function Find-LatestPsModule {
$LatestModuleVersion
}
-Function Install-Repository {
- Param(
- [Parameter(Mandatory = $true)]
- [string]$Name,
- [Parameter(Mandatory = $true)]
- [string]$Url,
- [bool]$CheckMode
- )
- # Legacy doesn't natively support deprecate by date, need to do this manually until we use Ansible.Basic
- if (-not $result.ContainsKey('deprecations')) {
- $result.deprecations = @()
- }
- $msg = -join @(
- "Adding a repo with this module is deprecated, the repository parameter should only be used to select a repo. "
- "Use community.windows.win_psrepository to manage repos"
- )
- $result.deprecations += @{
- msg = $msg
- date = "2021-07-01"
- collection_name = "community.windows"
- }
- # Install NuGet provider if needed.
- Install-NugetProvider -CheckMode $CheckMode
-
- $Repos = (Get-PSRepository).SourceLocation
-
- # If repository isn't already present, try to register it as trusted.
- if ($Repos -notcontains $Url) {
- try {
- if ( -not ($CheckMode) ) {
- Register-PSRepository -Name $Name -SourceLocation $Url -InstallationPolicy Trusted -ErrorAction Stop
- }
- $result.changed = $true
- $result.repository_changed = $true
- }
- catch {
- $ErrorMessage = "Problems registering $($Name) repository: $($_.Exception.Message)"
- Fail-Json $result $ErrorMessage
- }
- }
-}
-
-Function Remove-Repository {
- Param(
- [Parameter(Mandatory = $true)]
- [string]$Name,
- [bool]$CheckMode
- )
- # Legacy doesn't natively support deprecate by date, need to do this manually until we use Ansible.Basic
- if (-not $result.ContainsKey('deprecations')) {
- $result.deprecations = @()
- }
- $result.deprecations += @{
- msg = "Removing a repo with this module is deprecated, use community.windows.win_psrepository to manage repos"
- date = "2021-07-01"
- collection_name = "community.windows"
- }
-
- $Repo = (Get-PSRepository).Name
-
- # Try to remove the repository
- if ($Repo -contains $Name) {
- try {
- if ( -not ($CheckMode) ) {
- Unregister-PSRepository -Name $Name -ErrorAction Stop
- }
- $result.changed = $true
- $result.repository_changed = $true
- }
- catch [ System.Exception ] {
- $ErrorMessage = "Problems unregistering $($Name)repository: $($_.Exception.Message)"
- Fail-Json $result $ErrorMessage
- }
- }
-}
-
# Check PowerShell version, fail if < 5.0 and required modules are not installed
$PsVersion = $PSVersionTable.PSVersion
if ($PsVersion.Major -lt 5 ) {
@@ -469,11 +395,11 @@ if ( $allow_prerelease -and $state -eq "absent" ) {
if ( ($state -eq "latest") -and
( $required_version -or $minimum_version -or $maximum_version ) ) {
- $ErrorMessage = "When the parameter state is equal 'latest' you can use any of required_version, minimum_version, maximum_version."
+ $ErrorMessage = "When the parameter state is equal to 'latest' you can't use any of required_version, minimum_version, maximum_version."
Fail-Json $result $ErrorMessage
}
-if ( $repo -and (-not $url) ) {
+if ( $repo ) {
$RepositoryExists = Get-PSRepository -Name $repo -ErrorAction SilentlyContinue
if ( $null -eq $RepositoryExists) {
$ErrorMessage = "The repository $repo doesn't exist."
@@ -498,13 +424,6 @@ if ( ($allow_clobber -or $allow_prerelease -or $skip_publisher_check -or
Import-Module -Name PackageManagement, PowerShellGet -Force
if ($state -eq "present") {
- if (($repo) -and ($url)) {
- Install-Repository -Name $repo -Url $url -CheckMode $check_mode
- }
- else {
- $ErrorMessage = "Repository Name and Url are mandatory if you want to add a new repository"
- }
-
if ($name) {
$ht = @{
Name = $name
@@ -524,10 +443,6 @@ if ($state -eq "present") {
}
}
elseif ($state -eq "absent") {
- if ($repo) {
- Remove-Repository -Name $repo -CheckMode $check_mode
- }
-
if ($name) {
$ht = @{
Name = $Name
diff --git a/ansible_collections/community/windows/plugins/modules/win_psmodule.py b/ansible_collections/community/windows/plugins/modules/win_psmodule.py
index ce2053aad..c3b3cbb5e 100644
--- a/ansible_collections/community/windows/plugins/modules/win_psmodule.py
+++ b/ansible_collections/community/windows/plugins/modules/win_psmodule.py
@@ -95,12 +95,6 @@ options:
required: no
default: false
version_added: '1.13.0'
- url:
- description:
- - URL of the custom repository to register.
- - DEPRECATED, will be removed in a major release after C(2021-07-01), please use the
- M(community.windows.win_psrepository) module instead.
- type: str
notes:
- PowerShell modules needed
- PowerShellGet >= 1.6.0
diff --git a/ansible_collections/community/windows/plugins/modules/win_psmodule_info.ps1 b/ansible_collections/community/windows/plugins/modules/win_psmodule_info.ps1
index b0932a79c..080949af2 100644
--- a/ansible_collections/community/windows/plugins/modules/win_psmodule_info.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_psmodule_info.ps1
@@ -263,7 +263,7 @@ function Add-ModuleRepositoryInfo {
Process {
$moduleName = $InputObject.Name
- $installed = if ($installedModules.Contains($moduleName)) {
+ $installed = if ($installedModules -and $installedModules.Contains($moduleName)) {
# we know at least one version of this module was installed from PowerShellGet
# if the version of this local modle matches what we got it in the initial installed module list
# use it
diff --git a/ansible_collections/community/windows/plugins/modules/win_rabbitmq_plugin.ps1 b/ansible_collections/community/windows/plugins/modules/win_rabbitmq_plugin.ps1
index f4ac711c6..dbe914042 100644
--- a/ansible_collections/community/windows/plugins/modules/win_rabbitmq_plugin.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_rabbitmq_plugin.ps1
@@ -6,33 +6,30 @@
#Requires -Module Ansible.ModuleUtils.Legacy
function Get-EnabledPlugin($rabbitmq_plugins_cmd) {
- $list_plugins_cmd = "$rabbitmq_plugins_cmd list -E -m"
try {
- $enabled_plugins = @(Invoke-Expression "& $list_plugins_cmd" | Where-Object { $_ })
+ $enabled_plugins = @(& $rabbitmq_plugins_cmd list -E -m | Where-Object { $_ })
return , $enabled_plugins
}
catch {
- Fail-Json -obj $result -message "Can't execute `"$($list_plugins_cmd)`": $($_.Exception.Message)"
+ Fail-Json -obj $result -message "Can't execute '$rabbitmq_plugins_cmd list -E -m': $($_.Exception.Message)"
}
}
function Enable-Plugin($rabbitmq_plugins_cmd, $plugin_name) {
- $enable_plugin_cmd = "$rabbitmq_plugins_cmd enable $plugin_name"
try {
- Invoke-Expression "& $enable_plugin_cmd"
+ & $rabbitmq_plugins_cmd enable $plugin_name
}
catch {
- Fail-Json -obj $result -message "Can't execute `"$($enable_plugin_cmd)`": $($_.Exception.Message)"
+ Fail-Json -obj $result -message "Can't execute '$rabbitmq_plugins_cmd enable $plugin_name': $($_.Exception.Message)"
}
}
function Disable-Plugin($rabbitmq_plugins_cmd, $plugin_name) {
- $enable_plugin_cmd = "$rabbitmq_plugins_cmd disable $plugin_name"
try {
- Invoke-Expression "& $enable_plugin_cmd"
+ & $rabbitmq_plugins_cmd disable $plugin_name
}
catch {
- Fail-Json -obj $result -message "Can't execute `"$($enable_plugin_cmd)`": $($_.Exception.Message)"
+ Fail-Json -obj $result -message "Can't execute '$rabbitmq_plugins_cmd disable $plugin_name': $($_.Exception.Message)"
}
}
diff --git a/ansible_collections/community/windows/plugins/modules/win_rds_rap.ps1 b/ansible_collections/community/windows/plugins/modules/win_rds_rap.ps1
index 956a812dd..2c4bb65bc 100644
--- a/ansible_collections/community/windows/plugins/modules/win_rds_rap.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_rds_rap.ps1
@@ -140,6 +140,11 @@ if ($null -ne $user_groups) {
$user_groups = @($user_groups)
}
+# Ensure RemoteDesktopServices module is loaded
+if ($null -eq (Get-Module -Name RemoteDesktopServices -ErrorAction SilentlyContinue)) {
+ Import-Module -Name RemoteDesktopServices
+}
+
# Validate computer group parameter
if ($computer_group_type -eq "allow_any" -and $null -ne $computer_group) {
Add-Warning -obj $result -message "Parameter 'computer_group' ignored because the computer_group_type is set to allow_any."
@@ -165,11 +170,6 @@ if ($null -ne $allowed_ports) {
}
}
-# Ensure RemoteDesktopServices module is loaded
-if ($null -eq (Get-Module -Name RemoteDesktopServices -ErrorAction SilentlyContinue)) {
- Import-Module -Name RemoteDesktopServices
-}
-
# Check if a RAP with the given name already exists
$rap_exist = Test-Path -LiteralPath "RDS:\GatewayServer\RAP\$name"
diff --git a/ansible_collections/community/windows/plugins/modules/win_region.ps1 b/ansible_collections/community/windows/plugins/modules/win_region.ps1
index 90713c12e..796854051 100644
--- a/ansible_collections/community/windows/plugins/modules/win_region.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_region.ps1
@@ -186,7 +186,11 @@ Function Get-UserLocaleName {
return $user_locale
}
-Function Get-ValidGeoId($cultures) {
+Function Get-ValidGeoId {
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingEmptyCatchBlock', '',
+ Justification = 'We dont care about the error here')]
+ param($cultures)
+
$geo_ids = @()
foreach ($culture in $cultures) {
try {
diff --git a/ansible_collections/community/windows/plugins/modules/win_regmerge.ps1 b/ansible_collections/community/windows/plugins/modules/win_regmerge.ps1
index 8d511cc20..20942ba0e 100644
--- a/ansible_collections/community/windows/plugins/modules/win_regmerge.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_regmerge.ps1
@@ -7,6 +7,10 @@
#Requires -Module Ansible.ModuleUtils.CommandUtil
#Requires -Module Ansible.ModuleUtils.Legacy
+[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSCustomUseLiteralPath', '',
+ Justification = 'This module has supported wildcard comparison since it was created')]
+param()
+
Function Convert-RegistryPath {
Param (
[parameter(Mandatory = $True)]
@@ -24,17 +28,34 @@ $result = @{
}
$params = Parse-Args $args
-$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true -resultobj $result
+$path = Get-AnsibleParam -obj $params -name "path" -type "path" -resultobj $result
+$content = Get-AnsibleParam -obj $params -name "content" -type "str" -resultobj $result
$compare_to = Get-AnsibleParam -obj $params -name "compare_to" -type "str" -resultobj $result
+if ( !$path -and !$content ) {
+ Fail-Json -obj $result -message "Missing required arguments: path or content. At lease one must be provided."
+}
+
+if ( $path -and $content ) {
+ Fail-Json -obj $result -message "Extra arguments: path or content. Only one must be provided."
+}
+
+if ( $content ) {
+ $path = [System.IO.Path]::GetTempFileName()
+
+ Set-Content -LiteralPath $path -Value $content
+
+ $remove_path = $True
+}
+
# check it looks like a reg key, warn if key not present - will happen first time
# only accepting PS-Drive style key names (starting with HKLM etc, not HKEY_LOCAL_MACHINE etc)
$do_comparison = $False
-If ($compare_to) {
+If ( $compare_to ) {
$compare_to_key = $params.compare_to.ToString()
- If (Test-Path $compare_to_key -pathType container ) {
+ If (Test-Path $compare_to_key -PathType container ) {
$do_comparison = $True
}
Else {
@@ -96,4 +117,8 @@ Else {
$result.compared = $false
}
+if ( $remove_path ) {
+ Remove-Item $path
+}
+
Exit-Json $result
diff --git a/ansible_collections/community/windows/plugins/modules/win_regmerge.py b/ansible_collections/community/windows/plugins/modules/win_regmerge.py
index 073f54c9a..62c9be08c 100644
--- a/ansible_collections/community/windows/plugins/modules/win_regmerge.py
+++ b/ansible_collections/community/windows/plugins/modules/win_regmerge.py
@@ -21,8 +21,12 @@ options:
description:
- The full path including file name to the registry file on the remote machine to be merged
type: path
- required: yes
- compare_key:
+ content:
+ description:
+ - When used instead of O(path), merges the value specified into the Windows registry. It must not include the Byte Order Mark.
+ type: str
+ version_added: 2.2.0
+ compare_to:
description:
- The parent key to use when comparing the contents of the registry to the contents of the file. Needs to be in HKLM or HKCU part of registry.
Use a PS-Drive style path for example HKLM:\SOFTWARE not HKEY_LOCAL_MACHINE\SOFTWARE
@@ -53,6 +57,23 @@ EXAMPLES = r'''
community.windows.win_regmerge:
path: C:\autodeploy\myCompany-settings.reg
compare_to: HKLM:\SOFTWARE\myCompany
+
+- name: Merge in a registry file specified as content without comparing to current registry
+ community.windows.win_regmerge:
+ content: |
+ Windows Registry Editor Version 5.00
+
+ [HKEY_LOCAL_MACHINE\SOFTWARE\myCompany]
+ "ExampleKey"=dword:00000001
+
+- name: Compare and merge registry file specified as content
+ community.windows.win_regmerge:
+ content: |
+ Windows Registry Editor Version 5.00
+
+ [HKEY_LOCAL_MACHINE\SOFTWARE\myCompany]
+ "ExampleKey"=dword:00000001
+ compare_to: HKLM:\SOFTWARE\myCompany
'''
RETURN = r'''
diff --git a/ansible_collections/community/windows/plugins/modules/win_robocopy.ps1 b/ansible_collections/community/windows/plugins/modules/win_robocopy.ps1
index 2d3e05805..4975d2566 100644
--- a/ansible_collections/community/windows/plugins/modules/win_robocopy.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_robocopy.ps1
@@ -5,6 +5,10 @@
#Requires -Module Ansible.ModuleUtils.Legacy
+[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSCustomUseLiteralPath', '',
+ Justification = 'This module has supported wildcard comparison since it was created')]
+param()
+
$params = Parse-Args $args -supports_check_mode $true
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
@@ -33,12 +37,12 @@ Function SearchForError($cmd_output, $default_msg) {
}
if ($separator_count -ne 3) {
- if (Select-String -InputObject $line -pattern "^(\s+)?(\-+)(\s+)?$") {
+ if (Select-String -InputObject $line -Pattern "^(\s+)?(\-+)(\s+)?$") {
$separator_count += 1
}
}
else {
- if (Select-String -InputObject $line -pattern "error") {
+ if (Select-String -InputObject $line -Pattern "error") {
$error_msg = $line
break
}
@@ -75,7 +79,7 @@ else {
}
$result.flags = $flags
-$result.cmd = "$robocopy $robocopy_opts"
+$result.cmd = "robocopy $robocopy_opts"
Try {
$robocopy_output = &robocopy $robocopy_opts
diff --git a/ansible_collections/community/windows/plugins/modules/win_scheduled_task.ps1 b/ansible_collections/community/windows/plugins/modules/win_scheduled_task.ps1
index 02cd012f8..fd1f52135 100644
--- a/ansible_collections/community/windows/plugins/modules/win_scheduled_task.ps1
+++ b/ansible_collections/community/windows/plugins/modules/win_scheduled_task.ps1
@@ -814,19 +814,6 @@ for ($i = 0; $i -lt $triggers.Count; $i++) {
}
if ($trigger.ContainsKey("repetition")) {
- if ($trigger.repetition -is [Array]) {
- # Legacy doesn't natively support deprecate by date, need to do this manually until we use Ansible.Basic
- if (-not $result.ContainsKey('deprecations')) {
- $result.deprecations = @()
- }
- $result.deprecations += @{
- msg = "repetition is a list, should be defined as a dict"
- date = "2021-07-01"
- collection_name = "community.windows"
- }
- $trigger.repetition = $trigger.repetition[0]
- }
-
$interval_timespan = $null
if ($trigger.repetition.ContainsKey("interval") -and $null -ne $trigger.repetition.interval) {
$interval_timespan = Test-XmlDurationFormat -key "interval" -value $trigger.repetition.interval