PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/test/integration/roles/test_win_fetch/tasks/main.yml

https://github.com/ajanthanm/ansible
YAML | 168 lines | 121 code | 31 blank | 16 comment | 0 complexity | 2835ad0a7f7b24d7b529b8a3bdcde23e MD5 | raw file
  1# test code for the fetch module when using winrm connection
  2# (c) 2014, Chris Church <chris@ninemoreminutes.com>
  3
  4# This file is part of Ansible
  5#
  6# Ansible is free software: you can redistribute it and/or modify
  7# it under the terms of the GNU General Public License as published by
  8# the Free Software Foundation, either version 3 of the License, or
  9# (at your option) any later version.
 10#
 11# Ansible is distributed in the hope that it will be useful,
 12# but WITHOUT ANY WARRANTY; without even the implied warranty of
 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14# GNU General Public License for more details.
 15#
 16# You should have received a copy of the GNU General Public License
 17# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
 18
 19- name: clean out the test directory
 20  local_action: file name={{ output_dir|mandatory }} state=absent
 21  tags: me
 22
 23- name: create the test directory
 24  local_action: file name={{ output_dir }} state=directory
 25  tags: me
 26
 27- name: fetch a small file
 28  fetch: src="C:/Windows/win.ini" dest={{ output_dir }}
 29  register: fetch_small
 30
 31- name: check fetch small result
 32  assert:
 33    that:
 34      - "fetch_small.changed"
 35
 36- name: check file created by fetch small
 37  local_action: stat path={{ fetch_small.dest }}
 38  register: fetch_small_stat
 39
 40- name: verify fetched small file exists locally
 41  assert:
 42    that:
 43      - "fetch_small_stat.stat.exists"
 44      - "fetch_small_stat.stat.isreg"
 45      - "fetch_small_stat.stat.md5 == fetch_small.md5sum"
 46
 47- name: fetch the same small file
 48  fetch: src="C:/Windows/win.ini" dest={{ output_dir }}
 49  register: fetch_small_again
 50
 51- name: check fetch small result again
 52  assert:
 53    that:
 54      - "not fetch_small_again.changed"
 55
 56- name: fetch a small file to flat namespace
 57  fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}/" flat=yes
 58  register: fetch_flat
 59
 60- name: check fetch flat result
 61  assert:
 62    that:
 63      - "fetch_flat.changed"
 64
 65- name: check file created by fetch flat
 66  local_action: stat path="{{ output_dir }}/win.ini"
 67  register: fetch_flat_stat
 68
 69- name: verify fetched file exists locally in output_dir
 70  assert:
 71    that:
 72      - "fetch_flat_stat.stat.exists"
 73      - "fetch_flat_stat.stat.isreg"
 74      - "fetch_flat_stat.stat.md5 == fetch_flat.md5sum"
 75
 76- name: fetch a small file to flat directory (without trailing slash)
 77  fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}" flat=yes
 78  register: fetch_flat_dir
 79  ignore_errors: true
 80
 81- name: check fetch flat to directory result
 82  assert:
 83    that:
 84      - "fetch_flat_dir|failed"
 85      - "fetch_flat_dir.msg"
 86
 87- name: fetch a large binary file
 88  fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
 89  register: fetch_large
 90
 91- name: check fetch large binary file result
 92  assert:
 93    that:
 94      - "fetch_large.changed"
 95
 96- name: check file created by fetch large binary
 97  local_action: stat path={{ fetch_large.dest }}
 98  register: fetch_large_stat
 99
100- name: verify fetched large file exists locally
101  assert:
102    that:
103      - "fetch_large_stat.stat.exists"
104      - "fetch_large_stat.stat.isreg"
105      - "fetch_large_stat.stat.md5 == fetch_large.md5sum"
106
107- name: fetch a large binary file again
108  fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
109  register: fetch_large_again
110
111- name: check fetch large binary file result again
112  assert:
113    that:
114      - "not fetch_large_again.changed"
115
116- name: fetch a small file using backslashes in src path
117  fetch: src="C:\Windows\system.ini" dest={{ output_dir }}
118  register: fetch_small_bs
119
120- name: check fetch small result with backslashes
121  assert:
122    that:
123      - "fetch_small_bs.changed"
124
125- name: check file created by fetch small with backslashes
126  local_action: stat path={{ fetch_small_bs.dest }}
127  register: fetch_small_bs_stat
128
129- name: verify fetched small file with backslashes exists locally
130  assert:
131    that:
132      - "fetch_small_bs_stat.stat.exists"
133      - "fetch_small_bs_stat.stat.isreg"
134      - "fetch_small_bs_stat.stat.md5 == fetch_small_bs.md5sum"
135
136- name: attempt to fetch a non-existent file - do not fail on missing
137  fetch: src="C:/this_file_should_not_exist.txt" dest={{ output_dir }}
138  register: fetch_missing_nofail
139
140- name: check fetch missing no fail result
141  assert:
142    that:
143      - "not fetch_missing_nofail|failed"
144      - "fetch_missing_nofail.msg"
145      - "not fetch_missing_nofail|changed"
146
147- name: attempt to fetch a non-existent file - fail on missing
148  fetch: src="C:/this_file_should_not_exist.txt" dest={{ output_dir }} fail_on_missing=yes
149  register: fetch_missing
150  ignore_errors: true
151
152- name: check fetch missing with failure
153  assert:
154    that:
155      - "fetch_missing|failed"
156      - "fetch_missing.msg"
157      - "not fetch_missing|changed"
158
159- name: attempt to fetch a directory
160  fetch: src="C:\Windows" dest={{ output_dir }}
161  register: fetch_dir
162  ignore_errors: true
163
164- name: check fetch directory result
165  assert:
166    that:
167      - "fetch_dir|failed"
168      - "fetch_dir.msg"