Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed: win_copy failure from a VirtualBox share to a local path #33576

Merged

Conversation

ashumkin
Copy link
Contributor

@ashumkin ashumkin commented Dec 5, 2017

SUMMARY

In the case when a source file/folder is on a VirtualBox share then win_copy task fails.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/modules/windows/win_copy.ps1

ANSIBLE VERSION
ansible 2.4.2.0
  config file = /data/ansible/ansible.cfg
  configured module search path = [u'/home/server/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]
ADDITIONAL INFORMATION

Create a playbook with a win_copy task

  - name: Copy file from VirtualBox share
    win_copy:
      src: \\vboxsvr\share\file
      dest: c:\local\path
      remote_src: true

Run it against a host

At first time task fails. But file c:\local\path appears (as it intended to). Subsequent task calls succeed (as file already exists).

before
TASK [Copy file from VirtualBox share] ********************************************************************************************************************************************************************************************
task path: /data/ansible/quickbuild-agents.yml:56
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_copy.ps1
<172.20...> ESTABLISH WINRM CONNECTION FOR USER: IEUser on PORT 5985 TO 172.20...
EXEC (via pipeline wrapper)
fatal: [172.20...]: FAILED! => {
    "changed": false, 
    "dest": "c:\\local\\path", 
    "module_stderr": "An error occurred while creating the pipeline.\r\n    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordE \r\n   xception\r\n    + FullyQualifiedErrorId : RuntimeException\r\n \r\nException calling \"GetAccessControl\" with \"0\" argument(s): \"Method failed with \r\nunexpected error code 1.\"\r\nAt line:95 char:13\r\n+             $dest_file.SetAccessControl($source_file.GetAccessControl ...\r\n+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordE \r\n   xception\r\n    + FullyQualifiedErrorId : InvalidOperationException\r\n \r\n\r\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 1, 
    "src": "\\\\vboxsvr\\share\\file"
}
        to retry, use: --limit @/data/ansible/quickbuild-agents.retry
  
PLAY RECAP ********************************************************************************************************************************************************************************************************
172.20...             : ok=0    changed=0    unreachable=0    failed=1 

The reason is that .GetAccessControl method fails somehow for a file/folder on a VirtualBox share.

  PS c:\Users\vboxuser> $file = Get-Item -Path \\vboxsvr\share\file
  PS c:\Users\vboxuser> $file.GetAccessControl();
  Exception calling "GetAccessControl" with "0" argument(s): "Method
  failed with unexpected error code 1."
  ...

Fix it by suppressing the error, just print out a warning.

after
TASK [Copy file from VirtualBox share] ********************************************************************************************************************************************************************************************
task path: /data/ansible/quickbuild-agents.yml:56
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_copy.ps1
<172.20...> ESTABLISH WINRM CONNECTION FOR USER: IEUser on PORT 5985 TO 172.20...
EXEC (via pipeline wrapper)
 [WARNING]: Fail to copy access control

changed: [172.20...] => {
    "changed": true, 
    "checksum": "8f9185b1fb80dee64e511e222c1a9742eff7837f", 
    "dest": "c:\\local\\path", 
    "operation": "file_copy", 
    "original_basename": "file", 
    "size": 134122400, 
    "src": "\\\\vboxsvr\\share\\file"
}

@ansibot
Copy link
Contributor

ansibot commented Dec 5, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bugfix_pull_request core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community labels Dec 5, 2017
@jborean93
Copy link
Contributor

Looks like VirtualBox doesn't uses SMBv1 when presenting a network share and that doesn't support enumerating ACL's hence the error. We've spoken about this internally and think we should just get rid of the ACL stuff in win_copy because;

  • There is a bug right now and it isn't actually working
  • When copying a file in Windows manually, it does not bring across the ACL of the source file anyway
  • We can add in a future option that copies the ACL but we should set a flag instead to do this

If you can update your PR to remove the ACL stuff we can merge and backport to 2.4.

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Dec 6, 2017
In the case when a source file/folder is on a VirtualBox share then
win_copy task fails.
E.g.
  - name: Copy file from VirtualBox share
    win_copy:
      src: \\vboxsvr\share\file
      dest: c:\local\path
      remote_src: true

The reason is that .GetAccessControl method fails somehow for a
file/folder on a VirtualBox share.

  PS c:\Users\vboxuser> $file = Get-Item -Path \\vboxsvr\share\file
  PS c:\Users\vboxuser> $file.GetAccessControl();
  Exception calling "GetAccessControl" with "0" argument(s): "Method
  failed with unexpected error code 1."
  ...

<Jordan Borean (jborean93@gmail.com)> (@jborean93) said (see GitHub PR
!33576):

> ... we should just get rid of the ACL stuff in win_copy because;
>
> - There is a bug right now and it isn't actually working
> - When copying a file in Windows manually, it does not bring across the
>   ACL of the source file anyway
> - We can add in a future option that copies the ACL but we should set a
>   flag instead to do this

So, remove the ACL stuff

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Reviewed-by: <Jordan Borean (jborean93@gmail.com)>
@ashumkin ashumkin force-pushed the win_copy_failure-on-virtualbox-share branch from 220d8cc to 185bdeb Compare December 6, 2017 07:41
@ashumkin
Copy link
Contributor Author

ashumkin commented Dec 6, 2017

@jborean93, Thank you

I've updated the PR. Removed the ACL stuff and updated the commit message.

@jborean93 jborean93 merged commit f136567 into ansible:devel Dec 6, 2017
jborean93 pushed a commit that referenced this pull request Dec 6, 2017
@jborean93
Copy link
Contributor

Thanks for the fix @ashumkin, I've cherry-picked the changes to the stable-2.4 branch so it will be available in the 2.4.3.0 beta 1 release.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants