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

win_copy isn't working. #569

Open
ertanci opened this issue Nov 20, 2023 · 1 comment
Open

win_copy isn't working. #569

ertanci opened this issue Nov 20, 2023 · 1 comment

Comments

@ertanci
Copy link

ertanci commented Nov 20, 2023

SUMMARY

I can't copy folder from ansible server to windows server using win_copy module

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win-copy

ANSIBLE VERSION
ansible [core 2.14.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/**/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/**/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Sep 14 2023, 10:46:13) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/usr/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
CONFIGURATION
CONFIG_FILE() = /etc/ansible/ansible.cfg
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

NAME="Red Hat Enterprise Linux"
VERSION="8.8 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.8 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.8
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.8"

STEPS TO REPRODUCE
---
- name: Delete older log
  hosts: test_2019
  vars_files:
    - /etc/ansible/vault/vault.yml
  gather_facts: no
  tasks:
   - name: Old log clear ps file copy
     win_copy:
       src: /home/***/source.ps1'
       dest: c:\

ACTUAL RESULTS
TASK [Old log clear ps file copy] ****************************************************************************************************************************************************************************
task path: /home/***/ert/mypipe.yml:8
redirecting (type: action) ansible.builtin.win_copy to ansible.windows.win_copy
Using module file /usr/lib/python3.11/site-packages/ansible/modules/windows/win_copy.ps1
Pipelining is enabled.
<***> ESTABLISH WINRM CONNECTION FOR USER: **\** on PORT 5985 TO ***
<***> WINRM CONNECT: transport=ntlm endpoint=http://***:5985/wsman
<***> WINRM OPEN SHELL: C71EFB9A-625D-4533-BFF2-E3489716D2B3
EXEC (via pipeline wrapper)
<***> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-EncodedCommand', '***']
<***> WINRM RESULT '<Response code 0, out "{"changed":false,"ms", err "#< CLIXML\r\n#< CLIXML">'
<***> WINRM CLOSE SHELL: C71EFB9A-625D-4533-BFF2-E3489716D2B3
fatal: [***]: FAILED! => {
    "changed": false,
    "msg": "Cannot copy src file: '/home/***/source.ps1' as it does not exist"
}
@jborean93
Copy link
Collaborator

jborean93 commented Feb 6, 2024

Sorry I missed this one over the end of year break. The error message is interesting as it is acting like remote_src: true is potentially set causing the module to try and find the src configured on the remote target. The only two times this ever happens is at

Fail-Json -obj $result -message "Cannot copy src file: '$src' as it does not exist"

and

Fail-Json -obj $result -message "Cannot copy src file: '$src' as it does not exist"

The first example is if remote_src: true was set and the second example happens when copying a single file. In the latter case the action plugin overwrites src with the path to the temporary source path that was copied to the host so it should never be the original src defined in the Ansible task. Are you sure you haven't set remote_src: true in your example or as module defaults?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants