From 03261b3053c39d1fb88ee904bf51ae664d0f88aa Mon Sep 17 00:00:00 2001 From: Xyon Date: Wed, 29 Aug 2018 00:42:59 +0100 Subject: [PATCH] Add new session parameter to win_psexec (#44263) * Add new session parameter to win_psexec * Indicate which version the session option was added in * Added changelog fragment and minor edit on doc entry --- changelogs/fragments/win_psexec_session-selection.yaml | 2 ++ lib/ansible/modules/windows/win_psexec.ps1 | 4 ++++ lib/ansible/modules/windows/win_psexec.py | 7 +++++++ 3 files changed, 13 insertions(+) create mode 100644 changelogs/fragments/win_psexec_session-selection.yaml diff --git a/changelogs/fragments/win_psexec_session-selection.yaml b/changelogs/fragments/win_psexec_session-selection.yaml new file mode 100644 index 00000000000..881b4de5132 --- /dev/null +++ b/changelogs/fragments/win_psexec_session-selection.yaml @@ -0,0 +1,2 @@ +minor_changes: +- win_psexec - Added the ``session`` option to specify a session to start the process in diff --git a/lib/ansible/modules/windows/win_psexec.ps1 b/lib/ansible/modules/windows/win_psexec.ps1 index 1dc43c4a433..720e111b313 100644 --- a/lib/ansible/modules/windows/win_psexec.ps1 +++ b/lib/ansible/modules/windows/win_psexec.ps1 @@ -24,6 +24,7 @@ $elevated = Get-AnsibleParam -obj $params -name "elevated" -type "bool" -default $limited = Get-AnsibleParam -obj $params -name "limited" -type "bool" -default $false $system = Get-AnsibleParam -obj $params -name "system" -type "bool" -default $false $interactive = Get-AnsibleParam -obj $params -name "interactive" -type "bool" -default $false +$session = Get-AnsibleParam -obj $params -name "session" -type "int" $priority = Get-AnsibleParam -obj $params -name "priority" -type "str" -validateset "background","low","belownormal","abovenormal","high","realtime" $timeout = Get-AnsibleParam -obj $params -name "timeout" -type "int" $extra_opts = Get-AnsibleParam -obj $params -name "extra_opts" -type "list" @@ -83,6 +84,9 @@ If ($system -eq $true) { If ($interactive -eq $true) { $arguments += "-i" + If ($session -ne $null) { + $arguments += $session + } } If ($limited -eq $true) { diff --git a/lib/ansible/modules/windows/win_psexec.py b/lib/ansible/modules/windows/win_psexec.py index 6196e7809a3..166238204f4 100644 --- a/lib/ansible/modules/windows/win_psexec.py +++ b/lib/ansible/modules/windows/win_psexec.py @@ -65,6 +65,13 @@ options: - Run the program so that it interacts with the desktop on the remote system. type: bool default: 'no' + session: + description: + - Specifies the session ID to use. + - This parameter works in conjunction with I(interactive). + - It has no effect when I(interactive) is set to C(no). + type: int + version_added: '2.7' limited: description: - Run the command as limited user (strips the Administrators group and allows only privileges assigned to the Users group).