Server IP : 85.214.239.14 / Your IP : 18.222.184.207 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/ansible/executor/powershell/ |
Upload File : |
# (c) 2018 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) param( [Parameter(Mandatory = $true)][System.Collections.IDictionary]$Payload ) #AnsibleRequires -Wrapper module_wrapper $ErrorActionPreference = "Stop" Write-AnsibleLog "INFO - starting module_powershell_wrapper" "module_powershell_wrapper" $module_name = $Payload.module_args["_ansible_module_name"] Write-AnsibleLog "INFO - building module payload for '$module_name'" "module_powershell_wrapper" # compile any C# module utils passed in from the controller, Add-CSharpType is # automatically added to the payload manifest if any csharp util is set $csharp_utils = [System.Collections.ArrayList]@() foreach ($csharp_util in $Payload.csharp_utils_module) { Write-AnsibleLog "INFO - adding $csharp_util to list of C# references to compile" "module_powershell_wrapper" $util_code = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Payload.csharp_utils[$csharp_util])) $csharp_utils.Add($util_code) > $null } if ($csharp_utils.Count -gt 0) { $add_type_b64 = $Payload.powershell_modules["Ansible.ModuleUtils.AddType"] $add_type = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($add_type_b64)) New-Module -Name Ansible.ModuleUtils.AddType -ScriptBlock ([ScriptBlock]::Create($add_type)) | Import-Module > $null # add any C# references so the module does not have to do so $new_tmp = [System.Environment]::ExpandEnvironmentVariables($Payload.module_args["_ansible_remote_tmp"]) Add-CSharpType -References $csharp_utils -TempPath $new_tmp -IncludeDebugInfo } if ($Payload.ContainsKey("coverage") -and $null -ne $host.Runspace -and $null -ne $host.Runspace.Debugger) { $entrypoint = $payload.coverage_wrapper $params = @{ Payload = $Payload } } else { # get the common module_wrapper code and invoke that to run the module $module = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Payload.module_entry)) $variables = [System.Collections.ArrayList]@(@{ Name = "complex_args"; Value = $Payload.module_args; Scope = "Global" }) $entrypoint = $Payload.module_wrapper $params = @{ Scripts = @($script:common_functions, $module) Variables = $variables Environment = $Payload.environment Modules = $Payload.powershell_modules ModuleName = $module_name } } $entrypoint = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($entrypoint)) $entrypoint = [ScriptBlock]::Create($entrypoint) try { &$entrypoint @params } catch { # failed to invoke the PowerShell module, capture the exception and # output a pretty error for Ansible to parse $result = @{ msg = "Failed to invoke PowerShell module: $($_.Exception.Message)" failed = $true exception = (Format-AnsibleException -ErrorRecord $_) } Write-Output -InputObject (ConvertTo-Json -InputObject $result -Depth 99 -Compress) $host.SetShouldExit(1) } Write-AnsibleLog "INFO - ending module_powershell_wrapper" "module_powershell_wrapper"