1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/win_fetch/tasks/main.yml

172 lines
5 KiB
YAML
Raw Normal View History

# test code for the fetch module when using winrm connection
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: define host-specific output_dir
set_fact:
output_dir: "{{ output_dir }}/{{ inventory_hostname }}"
- name: clean out the test directory
local_action: file name={{ output_dir|mandatory }} state=absent
run_once: true
- name: create the test directory
local_action: file name={{ output_dir }} state=directory
run_once: true
- name: fetch a small file
fetch: src="C:/Windows/win.ini" dest={{ output_dir }}
register: fetch_small
- name: check fetch small result
assert:
that:
- "fetch_small.changed"
- name: check file created by fetch small
local_action: stat path={{ fetch_small.dest }}
register: fetch_small_stat
- name: verify fetched small file exists locally
assert:
that:
- "fetch_small_stat.stat.exists"
- "fetch_small_stat.stat.isreg"
- "fetch_small_stat.stat.md5 == fetch_small.md5sum"
- name: fetch the same small file
fetch: src="C:/Windows/win.ini" dest={{ output_dir }}
register: fetch_small_again
- name: check fetch small result again
assert:
that:
- "not fetch_small_again.changed"
- name: fetch a small file to flat namespace
fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}/" flat=yes
register: fetch_flat
- name: check fetch flat result
assert:
that:
- "fetch_flat.changed"
- name: check file created by fetch flat
local_action: stat path="{{ output_dir }}/win.ini"
register: fetch_flat_stat
- name: verify fetched file exists locally in output_dir
assert:
that:
- "fetch_flat_stat.stat.exists"
- "fetch_flat_stat.stat.isreg"
- "fetch_flat_stat.stat.md5 == fetch_flat.md5sum"
Fixes for WinRM/PowerShell support in v2. - Add support for inserting module args into PowerShell modules. Fixes #11661. - Support Windows paths containing spaces. Applies changes from #10727 to v2. Fixes #9999. Should also fix ansible/ansible-modules-core#944 and ansible/ansible-modules-core#1007. - Change how execution policy is set for running remote scripts. Applies changes from #11092 to v2. Also fixes ansible/ansible-modules-core#1776. - Use codepage 65001 (UTF-8) for WinRM connection instead of default (CP437), convert command to UTF-8 and results from UTF-8. Replaces changes from #10024. Fixes #11198. - Close WinRM connection when task completes. - Use win_stat, win_file and win_copy modules instead of stat, file and copy when called from within other action plugins (only when using WinRM+PowerShell). - Unquote Windows path arguments before passing to win_stat, win_file, win_copy and slurp modules (only when using WinRM/PowerShell). - Check for win_ping module to determine if core modules are missing (only when using WinRM/PowerShell). - Add stdout_lines to result from running low level commands (so stdout_lines is available when using raw/script). - Update copy action plugin to use shell functions for joining paths and checking for trailing slash. - Update fetch action plugin to unquote source path when using Windows paths. - Add win_copy and win_template action plugins that inherit from copy and template. - Support running .bat and .cmd scripts using default system encoding instead of UTF-8. - Always send PowerShell commands as base64-encoded blobs to allow for running simple PowerShell commands via raw. - Support running modules on Windows with interpreters other than PowerShell. - Update integration tests to support above changes and test unicode fixes. - Add test for win_user error from ansible/ansible-modules-core#1241 (fixed by ansible/ansible-modules-core#1774). - Add test for additional win_stat output values (implemented by ansible/ansible-modules-core#1473). - Add test for OS architecture and name from setup.ps1 (implemented by ansible/ansible-modules-core#1100). All WinRM integration tests pass for me with these changes.
2015-07-24 18:39:54 +02:00
#- name: fetch a small file to flat directory (without trailing slash)
# fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}" flat=yes
# register: fetch_flat_dir
Fixes for WinRM/PowerShell support in v2. - Add support for inserting module args into PowerShell modules. Fixes #11661. - Support Windows paths containing spaces. Applies changes from #10727 to v2. Fixes #9999. Should also fix ansible/ansible-modules-core#944 and ansible/ansible-modules-core#1007. - Change how execution policy is set for running remote scripts. Applies changes from #11092 to v2. Also fixes ansible/ansible-modules-core#1776. - Use codepage 65001 (UTF-8) for WinRM connection instead of default (CP437), convert command to UTF-8 and results from UTF-8. Replaces changes from #10024. Fixes #11198. - Close WinRM connection when task completes. - Use win_stat, win_file and win_copy modules instead of stat, file and copy when called from within other action plugins (only when using WinRM+PowerShell). - Unquote Windows path arguments before passing to win_stat, win_file, win_copy and slurp modules (only when using WinRM/PowerShell). - Check for win_ping module to determine if core modules are missing (only when using WinRM/PowerShell). - Add stdout_lines to result from running low level commands (so stdout_lines is available when using raw/script). - Update copy action plugin to use shell functions for joining paths and checking for trailing slash. - Update fetch action plugin to unquote source path when using Windows paths. - Add win_copy and win_template action plugins that inherit from copy and template. - Support running .bat and .cmd scripts using default system encoding instead of UTF-8. - Always send PowerShell commands as base64-encoded blobs to allow for running simple PowerShell commands via raw. - Support running modules on Windows with interpreters other than PowerShell. - Update integration tests to support above changes and test unicode fixes. - Add test for win_user error from ansible/ansible-modules-core#1241 (fixed by ansible/ansible-modules-core#1774). - Add test for additional win_stat output values (implemented by ansible/ansible-modules-core#1473). - Add test for OS architecture and name from setup.ps1 (implemented by ansible/ansible-modules-core#1100). All WinRM integration tests pass for me with these changes.
2015-07-24 18:39:54 +02:00
#- name: check fetch flat to directory result
# assert:
# that:
# - "not fetch_flat_dir|changed"
- name: fetch a large binary file
fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
register: fetch_large
- name: check fetch large binary file result
assert:
that:
- "fetch_large.changed"
- name: check file created by fetch large binary
local_action: stat path={{ fetch_large.dest }}
register: fetch_large_stat
- name: verify fetched large file exists locally
assert:
that:
- "fetch_large_stat.stat.exists"
- "fetch_large_stat.stat.isreg"
- "fetch_large_stat.stat.md5 == fetch_large.md5sum"
- name: fetch a large binary file again
fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
register: fetch_large_again
- name: check fetch large binary file result again
assert:
that:
- "not fetch_large_again.changed"
- name: fetch a small file using backslashes in src path
Fixes for WinRM/PowerShell support in v2. - Add support for inserting module args into PowerShell modules. Fixes #11661. - Support Windows paths containing spaces. Applies changes from #10727 to v2. Fixes #9999. Should also fix ansible/ansible-modules-core#944 and ansible/ansible-modules-core#1007. - Change how execution policy is set for running remote scripts. Applies changes from #11092 to v2. Also fixes ansible/ansible-modules-core#1776. - Use codepage 65001 (UTF-8) for WinRM connection instead of default (CP437), convert command to UTF-8 and results from UTF-8. Replaces changes from #10024. Fixes #11198. - Close WinRM connection when task completes. - Use win_stat, win_file and win_copy modules instead of stat, file and copy when called from within other action plugins (only when using WinRM+PowerShell). - Unquote Windows path arguments before passing to win_stat, win_file, win_copy and slurp modules (only when using WinRM/PowerShell). - Check for win_ping module to determine if core modules are missing (only when using WinRM/PowerShell). - Add stdout_lines to result from running low level commands (so stdout_lines is available when using raw/script). - Update copy action plugin to use shell functions for joining paths and checking for trailing slash. - Update fetch action plugin to unquote source path when using Windows paths. - Add win_copy and win_template action plugins that inherit from copy and template. - Support running .bat and .cmd scripts using default system encoding instead of UTF-8. - Always send PowerShell commands as base64-encoded blobs to allow for running simple PowerShell commands via raw. - Support running modules on Windows with interpreters other than PowerShell. - Update integration tests to support above changes and test unicode fixes. - Add test for win_user error from ansible/ansible-modules-core#1241 (fixed by ansible/ansible-modules-core#1774). - Add test for additional win_stat output values (implemented by ansible/ansible-modules-core#1473). - Add test for OS architecture and name from setup.ps1 (implemented by ansible/ansible-modules-core#1100). All WinRM integration tests pass for me with these changes.
2015-07-24 18:39:54 +02:00
fetch: src="C:\\Windows\\system.ini" dest={{ output_dir }}
register: fetch_small_bs
- name: check fetch small result with backslashes
assert:
that:
- "fetch_small_bs.changed"
- name: check file created by fetch small with backslashes
local_action: stat path={{ fetch_small_bs.dest }}
register: fetch_small_bs_stat
- name: verify fetched small file with backslashes exists locally
assert:
that:
- "fetch_small_bs_stat.stat.exists"
- "fetch_small_bs_stat.stat.isreg"
- "fetch_small_bs_stat.stat.md5 == fetch_small_bs.md5sum"
- name: attempt to fetch a non-existent file - do not fail on missing
fetch: src="C:/this_file_should_not_exist.txt" dest={{ output_dir }}
register: fetch_missing_nofail
- name: check fetch missing no fail result
assert:
that:
- "not fetch_missing_nofail|failed"
- "fetch_missing_nofail.msg"
- "not fetch_missing_nofail|changed"
- name: attempt to fetch a non-existent file - fail on missing
fetch: src="~/this_file_should_not_exist.txt" dest={{ output_dir }} fail_on_missing=yes
register: fetch_missing
ignore_errors: true
- name: check fetch missing with failure
assert:
that:
- "fetch_missing|failed"
- "fetch_missing.msg"
- "not fetch_missing|changed"
- name: attempt to fetch a directory
Fixes for WinRM/PowerShell support in v2. - Add support for inserting module args into PowerShell modules. Fixes #11661. - Support Windows paths containing spaces. Applies changes from #10727 to v2. Fixes #9999. Should also fix ansible/ansible-modules-core#944 and ansible/ansible-modules-core#1007. - Change how execution policy is set for running remote scripts. Applies changes from #11092 to v2. Also fixes ansible/ansible-modules-core#1776. - Use codepage 65001 (UTF-8) for WinRM connection instead of default (CP437), convert command to UTF-8 and results from UTF-8. Replaces changes from #10024. Fixes #11198. - Close WinRM connection when task completes. - Use win_stat, win_file and win_copy modules instead of stat, file and copy when called from within other action plugins (only when using WinRM+PowerShell). - Unquote Windows path arguments before passing to win_stat, win_file, win_copy and slurp modules (only when using WinRM/PowerShell). - Check for win_ping module to determine if core modules are missing (only when using WinRM/PowerShell). - Add stdout_lines to result from running low level commands (so stdout_lines is available when using raw/script). - Update copy action plugin to use shell functions for joining paths and checking for trailing slash. - Update fetch action plugin to unquote source path when using Windows paths. - Add win_copy and win_template action plugins that inherit from copy and template. - Support running .bat and .cmd scripts using default system encoding instead of UTF-8. - Always send PowerShell commands as base64-encoded blobs to allow for running simple PowerShell commands via raw. - Support running modules on Windows with interpreters other than PowerShell. - Update integration tests to support above changes and test unicode fixes. - Add test for win_user error from ansible/ansible-modules-core#1241 (fixed by ansible/ansible-modules-core#1774). - Add test for additional win_stat output values (implemented by ansible/ansible-modules-core#1473). - Add test for OS architecture and name from setup.ps1 (implemented by ansible/ansible-modules-core#1100). All WinRM integration tests pass for me with these changes.
2015-07-24 18:39:54 +02:00
fetch: src="C:\\Windows" dest={{ output_dir }}
register: fetch_dir
ignore_errors: true
- name: check fetch directory result
assert:
that:
# Doesn't fail anymore, only returns a message.
- "not fetch_dir|changed"
- "fetch_dir.msg"