Reputation: 11
During the playbook execution, task is failing dur to error "Access is denied".
Error message looks slightly different depending on tested method, but all of them has one exact sentence "access is denied" and "UnauthorizedAccessException".
Machine credentials used to run a playbook is admin account of the target host (PC client), and also this account has been added to "share" and "security" privileges in the task destination (share folder on the server). Both PC Client and Server are in the same VLAN and are accessible from one to another.
AWX Template Extra variables:
---
hostsHMI: all
fileshare_path: vars/DEV.yml
Main playbook (it's only one piece of a playbook, there are few other task which have no problem with execution)
-
name: 'Configure HMI client'
hosts: "{{ hostsHMI }}"
serial: 1
ignore_unreachable: true
vars_files:
- "{{ fileshare_path }}"
tasks:
-
name: 'Include tasks for instalation'
import_tasks: instalation_tasks/Full_setup.yml
Full Setup playbook - powershell module and command
-
name: Copying reg file to a share folder
ansible.windows.win_powershell:
script: |
$sourcePath = 'C:\Client Install Files\*_Client_Registry.reg'
$destinationPath = '{{ share_path }}'
Copy-Item -Path $sourcePath -Destination $destinationPath
tags:
- reg_copy
Error output:
{
"changed": true,
"invocation": {
"module_args": {
"depth": 2,
"removes": null,
"chdir": null,
"parameters": null,
"creates": null,
"executable": null,
"error_action": "continue",
"arguments": null,
"script": "$sourcePath = 'C:\\Client Install Files\\*_Client_Registry.reg'\n$destinationPath = '\\\\[FullServerName]\\Share\\[FolderName]'\nCopy-Item -Path $sourcePath -Destination $destinationPath\n"
}
},
"result": {},
"host_out": "",
"host_err": "",
"output": [],
"error": [
{
"script_stack_trace": "at <ScriptBlock>, <No file>: line 3",
"fully_qualified_error_id": "System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand",
"exception": {
"inner_exception": {
"inner_exception": null,
"message": "Access is denied",
"source": null,
"help_link": null,
"type": "System.ComponentModel.Win32Exception",
"hresult": -2147467259
},
"message": "Access is denied",
"source": "System.Management.Automation",
"help_link": null,
"type": "System.UnauthorizedAccessException",
"hresult": -2147024891
},
"target_object": null,
"error_details": null,
"output": "Copy-Item : Access is denied\r\nAt line:3 char:1\r\n+ Copy-Item -Path $sourcePath -Destination $destinationPath\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException\r\n + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand\r\n \r\n",
"pipeline_iteration_info": [],
"category_info": {
"target_name": "",
"target_type": "",
"activity": "Copy-Item",
"category_id": 0,
"reason": "UnauthorizedAccessException",
"category": "NotSpecified"
}
}
],
"warning": [],
"verbose": [],
"debug": [],
"information": [],
"_ansible_no_log": false
}
same situation is when I try to use win_copy
module.
And I actually testes these PS command directly being remotly connected to the client - it work perfectly without access issues.
Upvotes: 0
Views: 32