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