win_copy: allow src to have invalid windows chars (#31392)

* win_copy: allow src to have invalid windows chars

* create file with colon instead of avoid checkout errors
pull/31402/head
Jordan Borean 7 years ago committed by GitHub
parent 14b9a6b350
commit c4b51009f0

@ -473,6 +473,8 @@ class ActionModule(ActionBase):
symlinks=source_files['symlinks']
)
)
# src is not required for query, will fail path validation is src has unix allowed chars
query_args.pop('src', None)
query_args.pop('content', None)
query_return = self._execute_module(module_args=query_args, task_vars=task_vars)

@ -28,7 +28,7 @@
- name: fail to copy an encrypted file without the password set
win_copy:
src: '{{role_path}}/files-vault/vault-file'
src: '{{role_path}}/files-different/vault/vault-file'
dest: '{{test_win_copy_path}}\file'
register: fail_copy_encrypted_file
ignore_errors: yes # weird failed_when doesn't work in this case
@ -37,11 +37,11 @@
assert:
that:
- fail_copy_encrypted_file|failed
- fail_copy_encrypted_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-vault/vault-file'
- fail_copy_encrypted_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-different/vault/vault-file'
- name: fail to copy a directory with an encrypted file without the password
win_copy:
src: '{{role_path}}/files-vault'
src: '{{role_path}}/files-different/vault'
dest: '{{test_win_copy_path}}'
register: fail_copy_directory_with_enc_file
ignore_errors: yes
@ -50,7 +50,7 @@
assert:
that:
- fail_copy_directory_with_enc_file|failed
- fail_copy_directory_with_enc_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-vault/vault-file'
- fail_copy_directory_with_enc_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-different/vault/vault-file'
- name: copy with content (check mode)
win_copy:
@ -412,6 +412,37 @@
register: fail_folder_to_file
failed_when: "'object at parent directory path is already a file' not in fail_folder_to_file.msg"
# https://github.com/ansible/ansible/issues/31336
- name: create file with colon in the name
copy:
dest: '{{role_path}}/files-different/colon:file'
content: test
delegate_to: localhost
- name: copy a file with colon as a source
win_copy:
src: '{{role_path}}/files-different/colon:file'
dest: '{{test_win_copy_path}}\colon.file'
register: copy_file_with_colon
- name: get result of file with colon as a source
win_stat:
path: '{{test_win_copy_path}}\colon.file'
register: copy_file_with_colon_result
- name: assert results of copy a file with colon as a source
assert:
that:
- copy_file_with_colon|changed
- copy_file_with_colon_result.stat.exists == True
- copy_file_with_colon_result.stat.checksum == "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"
- name: remove file with colon in the name
file:
path: '{{role_path}}/files-different/colon:file'
state: absent
delegate_to: localhost
- name: remove test folder after local to remote tests
win_file:
path: '{{test_win_copy_path}}'

Loading…
Cancel
Save